install.php 2.0 KB

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