-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathactivate.php
More file actions
executable file
·30 lines (25 loc) · 862 Bytes
/
Copy pathactivate.php
File metadata and controls
executable file
·30 lines (25 loc) · 862 Bytes
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
<?php
require_once(dirname(__FILE__) . '/../../config.php');
require_once(dirname(__FILE__) . '/locallib.php');
require_login();
$PAGE->set_context(context_system::instance());
$PAGE->set_url(new moodle_url('/enrol/easy/activate.php'));
$plugin = 'easy';
$manualplugin = enrol_get_plugin($plugin);
$courses = $DB->get_recordset_select('course', 'category > 0', null, '', 'id');
foreach ($courses as $course) {
$instanceid = null;
$instances = enrol_get_instances($course->id, true);
foreach ($instances as $inst) {
if ($inst->enrol == $plugin) {
$instanceid = (int)$inst->id;
break;
}
}
if (empty($instanceid)) {
$instanceid = $manualplugin->add_default_instance($course);
if (empty($instanceid)) {
$instanceid = $manualplugin->add_instance($course);
}
}
}