install.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. $table = 'vchamilo';
  13. $tablename = Database::get_main_table($table);
  14. $sql = "CREATE TABLE IF NOT EXISTS $tablename (
  15. `id` int(11) NOT NULL AUTO_INCREMENT,
  16. `sitename` varchar(80) NOT NULL,
  17. `institution` varchar(80) NOT NULL,
  18. `root_web` varchar(120),
  19. `db_host` varchar(80) NOT NULL,
  20. `db_user` varchar(16) DEFAULT 'root',
  21. `db_password` varchar(32),
  22. `table_prefix` varchar(16),
  23. `db_prefix` varchar(16),
  24. `main_database` varchar(60) DEFAULT 'chamilo',
  25. `url_append` varchar(32),
  26. `course_folder` varchar(80),
  27. `visible` int(1),
  28. `lastcrongap` int(11),
  29. `lastcron` int(11),
  30. `croncount` int(11),
  31. PRIMARY KEY (`id`)
  32. ) DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
  33. ";
  34. Database::query($sql);
  35. $table = 'vchamilo_config';
  36. $tablename = Database::get_main_table($table);
  37. $sql = "CREATE TABLE IF NOT EXISTS $tablename (
  38. `id` int(11) NOT NULL AUTO_INCREMENT,
  39. `component` int(11) NOT NULL,
  40. `name` varchar(64) NOT NULL,
  41. `value` varchar(255) NOT NULL,
  42. `longvalue` varchar(255) NOT NULL,
  43. PRIMARY KEY (id)
  44. )
  45. ";
  46. Database::query($sql);
  47. api_add_setting(0, 'vchamilo_cron_lasthost', 'vchamilo', 'setting', 'Plugins');
  48. api_add_setting(0, 'vchamilo_vcrontime', 'vchamilo', 'setting', 'Plugins');
  49. api_add_setting(0, 'vchamilo_vcrontickperiod', 'vchamilo', 'setting', 'Plugins');
  50. // create root storage directory for templates
  51. global $_configuration;
  52. if (!is_dir($_configuration['root_sys'].'plugin/vchamilo/templates')){
  53. mkdir($_configuration['root_sys'].'plugin/vchamilo/templates', 0777, true);
  54. }