editinstance.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 ($id) {
  21. $mode = 'update';
  22. } else {
  23. $mode = $registeronly ? 'register' : 'add' ;
  24. }
  25. $vhost = [];
  26. if ($id) {
  27. $sql = "SELECT * FROM vchamilo WHERE id = $id";
  28. $result = Database::query($sql);
  29. $vhost = Database::fetch_array($result, 'ASSOC');
  30. }
  31. $form = new InstanceForm($plugininstance, $mode, $vhost);
  32. if ($data = $form->get_data()) {
  33. include api_get_path(SYS_PLUGIN_PATH).'vchamilo/views/editinstance.controller.php';
  34. }
  35. if ($id) {
  36. $vhost['vid'] = $vhost['id'];
  37. unset($vhost['id']);
  38. $form->set_data($vhost);
  39. } else {
  40. $vhost['db_host'] = 'localhost';
  41. $vhost['registeronly'] = $registeronly;
  42. $form->set_data($vhost);
  43. }
  44. $content = $form->return_form();
  45. $interbreadcrumb[] = array('url' => 'manage.php', 'name' => get_lang('VChamilo'));
  46. $tpl = new Template(get_lang('Instance'), true, true, false, true, false);
  47. $tpl->assign('content', $content);
  48. $tpl->display_one_col_template();