-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd.php
77 lines (62 loc) · 2.86 KB
/
add.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* SHEBanG enrolment plugin/module for SunGard HE Banner(r) data import
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Fred Woolard <[email protected]>
* @copyright (c) 2010 Appalachian State Universtiy, Boone, NC
* @license GNU General Public License version 3
* @package enrol
* @subpackage shebang
*/
require('../../config.php');
require_once("./lib.php");
require_once("./add_form.php");
$course = $DB->get_record('course', array('id' => required_param('id', PARAM_INT)), '*', MUST_EXIST);
require_login($course);
$manage_page_url = new moodle_url('/enrol/instances.php', array('id' => $course->id));
$plugin_short_name = 'shebang';
$plugin_name = 'enrol_shebang';
if (!enrol_is_enabled($plugin_short_name)) {
redirect($manage_page_url);
}
$plugin = enrol_get_plugin($plugin_short_name);
if (null == $plugin->get_newinstance_link($course->id)) {
// Either failed has_capability() checks or
// enrol instance already present in course
redirect($manage_page_url);
}
$PAGE->set_url('/enrol/{$plugin_short_name}/add.php', array('id' => $course->id));
$PAGE->set_pagelayout('admin');
$PAGE->set_title(get_string('pluginname', $plugin_name));
$PAGE->set_heading($course->fullname);
navigation_node::override_active_url($manage_page_url);
// Prompt for (or display current) idnumber
$edit_idnumber = has_capability('moodle/course:changeidnumber', context_course::instance($course->id));
$mform = new enrol_shebang_add_form(null, array('edit_idnumber' => $edit_idnumber));
$mform->set_data(array('id' => $course->id, 'idnumber' => $course->idnumber));
if ($mform->is_cancelled()) {
redirect($manage_page_url);
} elseif ($data = $mform->get_data()) {
$plugin->add_instance($course, null);
if ($edit_idnumber) {
$DB->update_record('course', array('id' => $course->id, 'idnumber' => $data->idnumber));
}
redirect($manage_page_url);
}
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', $plugin_name));
$mform->display();
echo $OUTPUT->footer();