MDL-23502 manual enrol plugin is not part of course edit screen any more
[moodle.git] / enrol / manual / edit_form.php
CommitLineData
eafb7a72
PS
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * Adds new instance of enrol_manual to specified course
20 * or edits current instance.
21 *
22 * @package enrol
23 * @subpackage manual
24 * @copyright 2010 Petr Skoda {@link http://skodak.org}
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
27
28defined('MOODLE_INTERNAL') || die;
29
30require_once($CFG->libdir.'/formslib.php');
31
32class enrol_manual_edit_form extends moodleform {
33
34 function definition() {
35 $mform = $this->_form;
36
37 list($instance, $plugin, $context) = $this->_customdata;
38
39 $mform->addElement('header', 'header', get_string('pluginname', 'enrol_manual'));
40
41 $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
42 ENROL_INSTANCE_DISABLED => get_string('no'));
43 $mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
44 $mform->addHelpButton('status', 'status', 'enrol_manual');
45 $mform->setDefault('status', $plugin->get_config('status'));
46
47 $mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), array('optional' => true, 'defaultunit' => 86400));
48 $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
49 $mform->disabledIf('enrolperiod', 'status', 'noteq', ENROL_INSTANCE_ENABLED);
50
51 if ($instance->id) {
52 $roles = get_default_enrol_roles($context, $instance->roleid);
53 } else {
54 $roles = get_default_enrol_roles($context, $plugin->get_config('roleid'));
55 }
56 $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
57 $mform->setDefault('roleid', $plugin->get_config('roleid'));
58 $mform->disabledIf('roleid', 'status', 'noteq', ENROL_INSTANCE_ENABLED);
59
60 $mform->addElement('hidden', 'courseid');
61
62 $this->add_action_buttons();
63
64 $this->set_data($instance);
65 }
66}