|
1
|
|
|
<?php |
|
2
|
|
|
/* For license terms, see /license.txt */ |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Plugin class for the NotebookTeacher plugin. |
|
6
|
|
|
* |
|
7
|
|
|
* @package chamilo.plugin.notebookteacher |
|
8
|
|
|
* |
|
9
|
|
|
* @author Jose Angel Ruiz <[email protected]> |
|
10
|
|
|
*/ |
|
11
|
|
|
class NotebookTeacherPlugin extends Plugin |
|
12
|
|
|
{ |
|
13
|
|
|
const TABLE_NOTEBOOKTEACHER = 'plugin_notebook_teacher'; |
|
14
|
|
|
public $isCoursePlugin = true; |
|
15
|
|
|
|
|
16
|
|
|
protected function __construct() |
|
17
|
|
|
{ |
|
18
|
|
|
parent::__construct( |
|
19
|
|
|
'1.1', |
|
20
|
|
|
'Jose Angel Ruiz - NoSoloRed (original author), Julio Montoya', |
|
21
|
|
|
[ |
|
22
|
|
|
'enable_plugin_notebookteacher' => 'boolean', |
|
23
|
|
|
] |
|
24
|
|
|
); |
|
25
|
|
|
|
|
26
|
|
|
$this->isAdminPlugin = true; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @return NotebookTeacherPlugin |
|
31
|
|
|
*/ |
|
32
|
|
|
public static function create() |
|
33
|
|
|
{ |
|
34
|
|
|
static $result = null; |
|
35
|
|
|
|
|
36
|
|
|
return $result ? $result : $result = new self(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* This method creates the tables required to this plugin. |
|
41
|
|
|
*/ |
|
42
|
|
|
public function install() |
|
43
|
|
|
{ |
|
44
|
|
|
//Installing course settings |
|
45
|
|
|
$this->install_course_fields_in_all_courses(); |
|
46
|
|
|
|
|
47
|
|
|
$tablesToBeCompared = [self::TABLE_NOTEBOOKTEACHER]; |
|
48
|
|
|
$em = Database::getManager(); |
|
49
|
|
|
$cn = $em->getConnection(); |
|
50
|
|
|
$sm = $cn->getSchemaManager(); |
|
51
|
|
|
$tables = $sm->tablesExist($tablesToBeCompared); |
|
52
|
|
|
|
|
53
|
|
|
if ($tables) { |
|
54
|
|
|
return false; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png'; |
|
58
|
|
|
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png'; |
|
59
|
|
|
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png'; |
|
60
|
|
|
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png'; |
|
61
|
|
|
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png'; |
|
62
|
|
|
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png'; |
|
63
|
|
|
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png'; |
|
64
|
|
|
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png'; |
|
65
|
|
|
copy($srcfile1, $dstfile1); |
|
66
|
|
|
copy($srcfile2, $dstfile2); |
|
67
|
|
|
copy($srcfile3, $dstfile3); |
|
68
|
|
|
copy($srcfile4, $dstfile4); |
|
69
|
|
|
|
|
70
|
|
|
require_once api_get_path(SYS_PLUGIN_PATH).'notebookteacher/database.php'; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* This method drops the plugin tables. |
|
75
|
|
|
*/ |
|
76
|
|
|
public function uninstall() |
|
77
|
|
|
{ |
|
78
|
|
|
// Deleting course settings. |
|
79
|
|
|
$this->uninstall_course_fields_in_all_courses($this->course_settings); |
|
80
|
|
|
|
|
81
|
|
|
$tablesToBeDeleted = [self::TABLE_NOTEBOOKTEACHER]; |
|
82
|
|
|
foreach ($tablesToBeDeleted as $tableToBeDeleted) { |
|
83
|
|
|
$table = Database::get_main_table($tableToBeDeleted); |
|
84
|
|
|
$sql = "DROP TABLE IF EXISTS $table"; |
|
85
|
|
|
Database::query($sql); |
|
86
|
|
|
} |
|
87
|
|
|
$this->manageTab(false); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function update() |
|
91
|
|
|
{ |
|
92
|
|
|
$tableNotebookTeacher = self::TABLE_NOTEBOOKTEACHER; |
|
93
|
|
|
|
|
94
|
|
|
$sql = 'SHOW COLUMNS FROM '.$tableNotebookTeacher.' WHERE Field = "student_id"'; |
|
95
|
|
|
$rs = Database::query($sql); |
|
96
|
|
|
if (Database::num_rows($rs) === 0) { |
|
97
|
|
|
$sql = "ALTER TABLE ".$tableNotebookTeacher." ADD student_id INT( 10 ) UNSIGNED NOT NULL AFTER user_id"; |
|
98
|
|
|
Database::query($sql); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
$srcfile1 = __DIR__.'/../resources/img/64/notebookteacher.png'; |
|
102
|
|
|
$srcfile2 = __DIR__.'/../resources/img/64/notebookteacher_na.png'; |
|
103
|
|
|
$srcfile3 = __DIR__.'/../resources/img/32/notebookteacher.png'; |
|
104
|
|
|
$srcfile4 = __DIR__.'/../resources/img/22/notebookteacher.png'; |
|
105
|
|
|
$dstfile1 = __DIR__.'/../../../main/img/icons/64/notebookteacher.png'; |
|
106
|
|
|
$dstfile2 = __DIR__.'/../../../main/img/icons/64/notebookteacher_na.png'; |
|
107
|
|
|
$dstfile3 = __DIR__.'/../../../main/img/icons/32/notebookteacher.png'; |
|
108
|
|
|
$dstfile4 = __DIR__.'/../../../main/img/notebookteacher.png'; |
|
109
|
|
|
copy($srcfile1, $dstfile1); |
|
110
|
|
|
copy($srcfile2, $dstfile2); |
|
111
|
|
|
copy($srcfile3, $dstfile3); |
|
112
|
|
|
copy($srcfile4, $dstfile4); |
|
113
|
|
|
|
|
114
|
|
|
Display::display_header(get_lang(ucfirst(self::TABLE_NOTEBOOKTEACHER))); |
|
115
|
|
|
echo 'Plugin actualizado'; |
|
116
|
|
|
Display::display_footer(); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|