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