editinstance.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. $cidReset = true;
  3. define('CHAMILO_INTERNAL', true);
  4. global $plugininstance;
  5. require_once '../../../main/inc/global.inc.php';
  6. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib.php';
  7. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/lib/vchamilo_plugin.class.php';
  8. require_once api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/editinstance_form.php';
  9. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_PLUGIN_PATH).'vchamilo/js/host_form.js" type="text/javascript" language="javascript"></script>';
  10. // get parameters
  11. $id = isset($_REQUEST['vid']) ? $_REQUEST['vid'] : '';
  12. $action = isset($_REQUEST['what']) ? $_REQUEST['what'] : '';
  13. $registeronly = isset($_REQUEST['registeronly']) ? $_REQUEST['registeronly'] : 0;
  14. $plugininstance = VChamiloPlugin::create();
  15. $thisurl = api_get_path(WEB_PLUGIN_PATH).'vchamilo/views/manage.php';
  16. $course_real_root = vchamilo_get_config('vchamilo', 'course_real_root');
  17. $homePath = vchamilo_get_config('vchamilo', 'home_real_root');
  18. if (empty($course_real_root) || empty($homePath)) {
  19. api_not_allowed('You have to setup the course real root');
  20. }
  21. // security
  22. api_protect_admin_script();
  23. if ($id) {
  24. $mode = 'update';
  25. } else {
  26. $mode = $registeronly ? 'register' : 'add' ;
  27. }
  28. $form = new InstanceForm($plugininstance, $mode);
  29. $form->definition();
  30. $actions = '';
  31. $message = '';
  32. if ($data = $form->get_data()) {
  33. include api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/editinstance.controller.php';
  34. }
  35. if ($id) {
  36. $sql = "SELECT * FROM vchamilo WHERE id = $id";
  37. $result = Database::query($sql);
  38. $vhost = Database::fetch_array($result);
  39. $vhost['vid'] = $vhost['id'];
  40. unset($vhost['id']);
  41. $form->set_data($vhost);
  42. } else {
  43. $data = array();
  44. $data['db_host'] = 'localhost';
  45. $data['single_database'] = 1;
  46. $data['registeronly'] = $registeronly;
  47. $form->set_data($data);
  48. }
  49. $content = $form->return_form();
  50. $interbreadcrumb[] = array('url' => 'manage.php', 'name' => get_lang('VChamilo'));
  51. $tpl = new Template(get_lang('Instances'), true, true, false, true, false);
  52. $tpl->assign('actions', $actions);
  53. $tpl->assign('message', $message);
  54. $tpl->assign('content', $content);
  55. $tpl->display_one_col_template();