Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/enrol/mnet/addinstance.php
Go to the documentation of this file.
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(dirname(dirname(dirname(__FILE__))).'/config.php');
00028 require_once($CFG->dirroot.'/enrol/mnet/addinstance_form.php');
00029 require_once($CFG->dirroot.'/mnet/service/enrol/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 require_login($course);
00037 require_capability('moodle/course:enrolconfig', $context);
00038 
00039 $PAGE->set_url('/enrol/mnet/addinstance.php', array('id'=>$course->id));
00040 $PAGE->set_pagelayout('standard');
00041 
00042 // Try and make the manage instances node on the navigation active
00043 $courseadmin = $PAGE->settingsnav->get('courseadmin');
00044 if ($courseadmin && $courseadmin->get('users') && $courseadmin->get('users')->get('manageinstances')) {
00045     $courseadmin->get('users')->get('manageinstances')->make_active();
00046 }
00047 
00048 $enrol = enrol_get_plugin('mnet');
00049 // make sure we were allowed to get here form the Enrolment methods page
00050 if (!$enrol->get_newinstance_link($course->id)) {
00051     redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
00052 }
00053 $service = mnetservice_enrol::get_instance();
00054 $mform = new enrol_mnet_addinstance_form(null, array('course'=>$course, 'enrol'=>$enrol, 'service'=>$service));
00055 
00056 if ($mform->is_cancelled()) {
00057     redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
00058 
00059 } else if ($data = $mform->get_data()) {
00060     $enrol->add_instance($course, array('customint1'=>$data->hostid, 'roleid'=>$data->roleid, 'name'=>$data->name));
00061     redirect(new moodle_url('/enrol/instances.php', array('id'=>$course->id)));
00062 }
00063 
00064 $PAGE->set_heading($course->fullname);
00065 $PAGE->set_title(get_string('pluginname', 'enrol_mnet'));
00066 
00067 echo $OUTPUT->header();
00068 $mform->display();
00069 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations