|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 require('../../config.php'); 00028 require_once("$CFG->dirroot/enrol/meta/addinstance_form.php"); 00029 require_once("$CFG->dirroot/enrol/meta/locallib.php"); 00030 00031 $id = required_param('id', PARAM_INT); // course id 00032 00033 $course = $DB->get_record('course', array('id'=>$id), '*', MUST_EXIST); 00034 $context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST); 00035 00036 $PAGE->set_url('/enrol/meta/addinstance.php', array('id'=>$course->id)); 00037 $PAGE->set_pagelayout('admin'); 00038 00039 navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id'=>$course->id))); 00040 00041 require_login($course); 00042 require_capability('moodle/course:enrolconfig', $context); 00043 00044 $enrol = enrol_get_plugin('meta'); 00045 if (!$enrol->get_newinstance_link($course->id)) { 00046 redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id))); 00047 } 00048 00049 $mform = new enrol_meta_addinstance_form(NULL, $course); 00050 00051 if ($mform->is_cancelled()) { 00052 redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id))); 00053 00054 } else if ($data = $mform->get_data()) { 00055 $eid = $enrol->add_instance($course, array('customint1'=>$data->link)); 00056 enrol_meta_sync($course->id); 00057 redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id))); 00058 } 00059 00060 $PAGE->set_heading($course->fullname); 00061 $PAGE->set_title(get_string('pluginname', 'enrol_meta')); 00062 00063 echo $OUTPUT->header(); 00064 00065 $mform->display(); 00066 00067 echo $OUTPUT->footer();