[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Form to add an instance of enrol_mnet plugin 19 * 20 * @package enrol_mnet 21 * @copyright 2010 David Mudrak <[email protected]> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 require_once("$CFG->libdir/formslib.php"); 28 29 class enrol_mnet_addinstance_form extends moodleform { 30 function definition() { 31 global $CFG, $DB; 32 33 $mform = $this->_form; 34 $course = $this->_customdata['course']; 35 $enrol = $this->_customdata['enrol']; 36 $service = $this->_customdata['service']; 37 $coursecontext = context_course::instance($course->id); 38 39 $subscribers = $service->get_remote_subscribers(); 40 $hosts = array(0 => get_string('remotesubscribersall', 'enrol_mnet')); 41 foreach ($subscribers as $hostid => $subscriber) { 42 $hosts[$hostid] = $subscriber->appname.': '.$subscriber->hostname.' ('.$subscriber->hosturl.')'; 43 } 44 $roles = get_assignable_roles($coursecontext); 45 46 $mform->addElement('header','general', get_string('pluginname', 'enrol_mnet')); 47 48 $mform->addElement('select', 'hostid', get_string('remotesubscriber', 'enrol_mnet'), $hosts); 49 $mform->addHelpButton('hostid', 'remotesubscriber', 'enrol_mnet'); 50 $mform->addRule('hostid', get_string('required'), 'required', null, 'client'); 51 52 $mform->addElement('select', 'roleid', get_string('roleforremoteusers', 'enrol_mnet'), $roles); 53 $mform->addHelpButton('roleid', 'roleforremoteusers', 'enrol_mnet'); 54 $mform->addRule('roleid', get_string('required'), 'required', null, 'client'); 55 $mform->setDefault('roleid', $enrol->get_config('roleid')); 56 57 $mform->addElement('text', 'name', get_string('instancename', 'enrol_mnet')); 58 $mform->addHelpButton('name', 'instancename', 'enrol_mnet'); 59 $mform->setType('name', PARAM_TEXT); 60 61 $mform->addElement('hidden', 'id', null); 62 $mform->setType('id', PARAM_INT); 63 64 $this->add_action_buttons(); 65 66 $this->set_data(array('id'=>$course->id)); 67 } 68 69 /** 70 * Do not allow multiple instances for single remote host 71 * 72 * @param array $data raw form data 73 * @param array $files 74 * @return array of errors 75 */ 76 function validation($data, $files) { 77 global $DB; 78 79 $errors = array(); 80 81 if ($DB->record_exists('enrol', array('enrol' => 'mnet', 'courseid' => $data['id'], 'customint1' => $data['hostid']))) { 82 $errors['hostid'] = get_string('error_multiplehost', 'enrol_mnet'); 83 } 84 85 return $errors; 86 } 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |