Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/enrol/mnet/lib.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 defined('MOODLE_INTERNAL') || die();
00028 
00032 class enrol_mnet_plugin extends enrol_plugin {
00033 
00040     public function get_instance_name($instance) {
00041         global $DB;
00042 
00043         if (empty($instance)) {
00044             $enrol = $this->get_name();
00045             return get_string('pluginname', 'enrol_'.$enrol);
00046 
00047         } else if (empty($instance->name)) {
00048             $enrol = $this->get_name();
00049             if ($role = $DB->get_record('role', array('id'=>$instance->roleid))) {
00050                 $role = role_get_name($role, get_context_instance(CONTEXT_COURSE, $instance->courseid));
00051             } else {
00052                 $role = get_string('error');
00053             }
00054             if (empty($instance->customint1)) {
00055                 $host = get_string('remotesubscribersall', 'enrol_mnet');
00056             } else {
00057                 $host = $DB->get_field('mnet_host', 'name', array('id'=>$instance->customint1));
00058             }
00059             return get_string('pluginname', 'enrol_'.$enrol) . ' (' . format_string($host) . ' - ' . $role .')';
00060 
00061         } else {
00062             return format_string($instance->name);
00063         }
00064     }
00065 
00074     public function get_newinstance_link($courseid) {
00075         global $CFG, $DB;
00076         require_once($CFG->dirroot.'/mnet/service/enrol/locallib.php');
00077 
00078         $service = mnetservice_enrol::get_instance();
00079         if (!$service->is_available()) {
00080             return null;
00081         }
00082         $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
00083         if (!has_capability('moodle/course:enrolconfig', $coursecontext)) {
00084             return null;
00085         }
00086         $subscribers = $service->get_remote_subscribers();
00087         if (empty($subscribers)) {
00088             return null;
00089         }
00090 
00091         return new moodle_url('/enrol/mnet/addinstance.php', array('id'=>$courseid));
00092     }
00093 }
 All Data Structures Namespaces Files Functions Variables Enumerations