|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Plugin class for the Test2Pdf plugin. |
|
4
|
|
|
* |
|
5
|
|
|
* @package chamilo.plugin.test2pdf |
|
6
|
|
|
* |
|
7
|
|
|
* @author Jose Angel Ruiz <[email protected]> |
|
8
|
|
|
*/ |
|
9
|
|
|
class Test2pdfPlugin extends Plugin |
|
10
|
|
|
{ |
|
11
|
|
|
public $isCoursePlugin = true; |
|
12
|
|
|
|
|
13
|
|
|
protected function __construct() |
|
14
|
|
|
{ |
|
15
|
|
|
parent::__construct( |
|
16
|
|
|
'1.0', |
|
17
|
|
|
'Jose Angel Ruiz - NoSoloRed (original author)', |
|
18
|
|
|
[ |
|
19
|
|
|
'enable_plugin' => 'boolean', |
|
20
|
|
|
] |
|
21
|
|
|
); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @return StaticPlugin |
|
26
|
|
|
*/ |
|
27
|
|
|
public static function create() |
|
28
|
|
|
{ |
|
29
|
|
|
static $result = null; |
|
30
|
|
|
|
|
31
|
|
|
return $result ? $result : $result = new self(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* This method creates the tables required to this plugin. |
|
36
|
|
|
*/ |
|
37
|
|
|
public function install() |
|
38
|
|
|
{ |
|
39
|
|
|
//Installing course settings |
|
40
|
|
|
$this->setCourseToolDefaultVisibility(false); |
|
41
|
|
|
$this->install_course_fields_in_all_courses(); |
|
42
|
|
|
|
|
43
|
|
|
$list = [ |
|
44
|
|
|
'/64/test2pdf.png', |
|
45
|
|
|
'/64/test2pdf_na.png', |
|
46
|
|
|
'/32/test2pdf.png', |
|
47
|
|
|
'/32/test2pdf_na.png', |
|
48
|
|
|
'/22/test2pdf.png', |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
$res = true; |
|
52
|
|
|
foreach ($list as $file) { |
|
53
|
|
|
$source = __DIR__.'/../resources/img/'.$file; |
|
54
|
|
|
$destination = __DIR__.'/../../../main/img/icons/'.$file; |
|
55
|
|
|
$res = @copy($source, $destination); |
|
56
|
|
|
if (!$res) { |
|
57
|
|
|
break; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
if (!$res) { |
|
62
|
|
|
$warning = 'Test2PDF plugin icons could not be copied to main/img/ because of folder permissions. |
|
63
|
|
|
To fix, give web server user permissions to write to main/img/ before enabling this plugin.'; |
|
64
|
|
|
Display::addFlash(Display::return_message($warning, 'warning')); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* This method drops the plugin tables. |
|
70
|
|
|
*/ |
|
71
|
|
|
public function uninstall() |
|
72
|
|
|
{ |
|
73
|
|
|
// Deleting course settings. |
|
74
|
|
|
$this->uninstall_course_fields_in_all_courses($this->course_settings); |
|
75
|
|
|
$this->manageTab(false); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|