editinstance.php 2.0 KB

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