Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/plugin/notebookteacher/src/notebookteacher_plugin.clas...

124 lines
4.0 KiB

<?php
/* For license terms, see /license.txt */
/**
* Description of notebookteacher_plugin.
*
* @package chamilo.plugin.notebookteacher
*
* @author Jose Angel Ruiz <desarrollo@nosolored.com>
*/
/**
* Plugin class for the NotebookTeacher plugin.
*/
class NotebookTeacherPlugin extends Plugin
{
const TABLE_NOTEBOOKTEACHER = 'plugin_notebook_teacher';
public $isCoursePlugin = true;
protected function __construct()
{
parent::__construct(
'1.1',
'Jose Angel Ruiz - NoSoloRed (original author)',
[
'enable_plugin_notebookteacher' => 'boolean',
]
);
$this->isAdminPlugin = true;
}
/**
* @return StaticPlugin
*/
public static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
/**
* This method creates the tables required to this plugin.
*/
public function install()
{
//Installing course settings
$this->install_course_fields_in_all_courses();
$tablesToBeCompared = [
self::TABLE_NOTEBOOKTEACHER,
];
$em = Database::getManager();
$cn = $em->getConnection();
$sm = $cn->getSchemaManager();
$tables = $sm->tablesExist($tablesToBeCompared);
if ($tables) {
return false;
}
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png';
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png';
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png';
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png';
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png';
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png';
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png';
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png';
copy($srcfile1, $dstfile1);
copy($srcfile2, $dstfile2);
copy($srcfile3, $dstfile3);
copy($srcfile4, $dstfile4);
require_once api_get_path(SYS_PLUGIN_PATH).'notebookteacher/database.php';
}
/**
* This method drops the plugin tables.
*/
public function uninstall()
{
//Deleting course settings
$this->uninstall_course_fields_in_all_courses($this->course_settings);
$tablesToBeDeleted = [
TABLE_NOTEBOOKTEACHER,
];
foreach ($tablesToBeDeleted as $tableToBeDeleted) {
$table = Database::get_main_table($tableToBeDeleted);
$sql = "DROP TABLE IF EXISTS $table";
Database::query($sql);
}
$this->manageTab(false);
}
public function update()
{
$tableNotebookTeacher = self::TABLE_NOTEBOOKTEACHER;
$sql = 'SHOW COLUMNS FROM '.$tableNotebookTeacher.' WHERE Field = "student_id"';
$rs = Database::query($sql);
if (Database::num_rows($rs) === 0) {
$sql = "ALTER TABLE ".$tableNotebookTeacher." ADD student_id INT( 10 ) UNSIGNED NOT NULL AFTER user_id";
Database::query($sql);
}
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png';
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png';
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png';
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png';
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png';
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png';
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png';
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png';
copy($srcfile1, $dstfile1);
copy($srcfile2, $dstfile2);
copy($srcfile3, $dstfile3);
copy($srcfile4, $dstfile4);
Display::display_header(get_lang(ucfirst(self::TABLE_NOTEBOOKTEACHER)));
echo 'Plugin actualizado';
Display::display_footer();
}
}