install.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /* PHP code to install the plugin
  3. * For example:
  4. *
  5. // To query something to the database
  6. $table = Database::get_main_table(TABLE_MAIN_USER); // TABLE_MAIN_USER is a constant check the main/inc/database.constants.inc.php
  7. $sql = "SELECT firstname, lastname FROM $table_users ";
  8. $users = Database::query($sql);
  9. You can also use the Chamilo classes
  10. $users = UserManager::get_user_list();
  11. */
  12. api_protect_admin_script();
  13. $table = 'vchamilo';
  14. $tablename = Database::get_main_table($table);
  15. $sql = "
  16. CREATE TABLE IF NOT EXISTS $tablename (
  17. id int NOT NULL AUTO_INCREMENT,
  18. sitename varchar(80) NOT NULL,
  19. slug varchar(255) NOT NULL,
  20. institution varchar(80) NOT NULL,
  21. root_web varchar(120),
  22. db_host varchar(80) NOT NULL,
  23. db_user varchar(16) DEFAULT 'root',
  24. db_password varchar(32),
  25. table_prefix varchar(16),
  26. db_prefix varchar(16),
  27. main_database varchar(60) DEFAULT 'chamilo',
  28. url_append varchar(32),
  29. course_folder varchar(80),
  30. visible int,
  31. lastcrongap int,
  32. lastcron int,
  33. croncount int,
  34. template varchar(255),
  35. password_encryption varchar(255),
  36. archive_url varchar(255),
  37. home_url varchar(255),
  38. upload_url varchar(255),
  39. course_url varchar(255),
  40. css_theme_folder varchar(255),
  41. PRIMARY KEY (id)
  42. ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
  43. ";
  44. /*ALTER TABLE vchamilo ADD COLUMN archive_url varchar(255);
  45. ALTER TABLE vchamilo ADD COLUMN home_url varchar(255);
  46. ALTER TABLE vchamilo ADD COLUMN upload_url varchar(255);
  47. ALTER TABLE vchamilo ADD COLUMN course_url varchar(255);*/
  48. Database::query($sql);
  49. $table = 'vchamilo_config';
  50. $tablename = Database::get_main_table($table);
  51. // TODO: rename "name" and "value" fields - these are reserved keywords
  52. $sql = "CREATE TABLE IF NOT EXISTS $tablename (
  53. id int(11) NOT NULL AUTO_INCREMENT,
  54. component int(11) NOT NULL,
  55. `name` varchar(64) NOT NULL,
  56. `value` varchar(255) NOT NULL,
  57. longvalue varchar(255) NOT NULL,
  58. PRIMARY KEY (id)
  59. )
  60. ";
  61. Database::query($sql);
  62. api_add_setting(0, 'vchamilo_cron_lasthost', 'vchamilo', 'setting', 'Plugins');
  63. api_add_setting(0, 'vchamilo_vcrontime', 'vchamilo', 'setting', 'Plugins');
  64. api_add_setting(0, 'vchamilo_vcrontickperiod', 'vchamilo', 'setting', 'Plugins');
  65. // create root storage directory for templates
  66. global $_configuration;
  67. if (!is_dir($_configuration['root_sys'].'plugin/vchamilo/templates')) {
  68. $mode = api_get_permissions_for_new_directories();
  69. mkdir($_configuration['root_sys'].'plugin/vchamilo/templates', $mode, true);
  70. }