weekly release 2.4dev
[moodle.git] / enrol / manual / edit_form.php
CommitLineData
eafb7a72 1<?php
eafb7a72
PS
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 * Adds new instance of enrol_manual to specified course
19 * or edits current instance.
20 *
6f6c9e5c 21 * @package enrol_manual
eafb7a72
PS
22 * @copyright 2010 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
97795859 26defined('MOODLE_INTERNAL') || die();
eafb7a72
PS
27
28require_once($CFG->libdir.'/formslib.php');
29
30class enrol_manual_edit_form extends moodleform {
31
32 function definition() {
33 $mform = $this->_form;
34
35 list($instance, $plugin, $context) = $this->_customdata;
36
37 $mform->addElement('header', 'header', get_string('pluginname', 'enrol_manual'));
38
39 $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'),
40 ENROL_INSTANCE_DISABLED => get_string('no'));
41 $mform->addElement('select', 'status', get_string('status', 'enrol_manual'), $options);
42 $mform->addHelpButton('status', 'status', 'enrol_manual');
43 $mform->setDefault('status', $plugin->get_config('status'));
44
45 $mform->addElement('duration', 'enrolperiod', get_string('defaultperiod', 'enrol_manual'), array('optional' => true, 'defaultunit' => 86400));
46 $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
94f630e3 47 $mform->addHelpButton('enrolperiod', 'defaultperiod', 'enrol_manual');
eafb7a72
PS
48
49 if ($instance->id) {
50 $roles = get_default_enrol_roles($context, $instance->roleid);
51 } else {
52 $roles = get_default_enrol_roles($context, $plugin->get_config('roleid'));
53 }
54 $mform->addElement('select', 'roleid', get_string('defaultrole', 'role'), $roles);
55 $mform->setDefault('roleid', $plugin->get_config('roleid'));
eafb7a72
PS
56
57 $mform->addElement('hidden', 'courseid');
58
684784c8 59 $this->add_action_buttons(true, ($instance->id ? null : get_string('addinstance', 'enrol')));
eafb7a72
PS
60
61 $this->set_data($instance);
62 }
6f6c9e5c 63}