test2pdf_plugin.class.php 1.9 KB

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