__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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.
//
// Moodle 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 Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Adds new instance of an enrolment plugin to specified course or edits current instance.
*
* @package core_enrol
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require('../config.php');
require_once('editinstance_form.php');
$courseid = required_param('courseid', PARAM_INT);
$type = required_param('type', PARAM_COMPONENT);
$instanceid = optional_param('id', 0, PARAM_INT);
$return = optional_param('returnurl', 0, PARAM_LOCALURL);
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST);
$plugin = enrol_get_plugin($type);
if (!$plugin) {
throw new moodle_exception('invaliddata', 'error');
}
require_login($course);
if (!has_any_capability(['enrol/' . $type . ':config', 'moodle/course:editcoursewelcomemessage'], $context)) {
throw new \moodle_exception('nopermissiontoaccesspage', 'error');
}
$url = new moodle_url('/enrol/editinstance.php', ['courseid' => $course->id, 'id' => $instanceid, 'type' => $type]);
$PAGE->set_url($url);
$PAGE->set_pagelayout('admin');
$PAGE->set_docs_path('enrol/' . $type . '/edit');
if (empty($return)) {
$return = new moodle_url('/enrol/instances.php', array('id' => $course->id));
}
if (!enrol_is_enabled($type)) {
redirect($return);
}
if ($instanceid) {
$instance = $DB->get_record('enrol', array('courseid' => $course->id, 'enrol' => $type, 'id' => $instanceid), '*', MUST_EXIST);
if ($instance->status == ENROL_INSTANCE_DISABLED) { // The instance is currently disabled.
navigation_node::override_active_url(new moodle_url('/enrol/instances.php', ['id' => $course->id]));
$name = $instance->name ?: get_string('pluginname', 'enrol_' . $type);
$PAGE->navbar->add($name, $url);
}
} else {
require_capability('moodle/course:enrolconfig', $context);
// No instance yet, we have to add new instance.
navigation_node::override_active_url(new moodle_url('/enrol/instances.php', array('id' => $course->id)));
$instance = (object)$plugin->get_instance_defaults();
$instance->id = null;
$instance->courseid = $course->id;
$instance->status = ENROL_INSTANCE_ENABLED; // Do not use default for automatically created instances here.
$PAGE->navbar->add(get_string('pluginname', 'enrol_' . $type), $url);
}
$mform = new enrol_instance_edit_form(null, array($instance, $plugin, $context, $type, $return));
if ($mform->is_cancelled()) {
redirect($return);
} else if ($data = $mform->get_data()) {
if ($instance->id) {
$reset = false;
if (isset($data->status)) {
$reset = ($instance->status != $data->status);
}
foreach ($data as $key => $value) {
$instance->$key = $value;
}
$instance->timemodified = time();
$plugin->update_instance($instance, $data);
if ($reset) {
$context->mark_dirty();
}
} else {
$fields = (array) $data;
$plugin->add_instance($course, $fields);
}
redirect($return);
}
$PAGE->set_heading($course->fullname);
$PAGE->set_title(get_string('pluginname', 'enrol_' . $type));
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('pluginname', 'enrol_' . $type));
$mform->display();
echo $OUTPUT->footer();
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| category | Folder | 0777 |
|
|
| classes | Folder | 0777 |
|
|
| cohort | Folder | 0777 |
|
|
| database | Folder | 0777 |
|
|
| fee | Folder | 0777 |
|
|
| flatfile | Folder | 0777 |
|
|
| guest | Folder | 0777 |
|
|
| imsenterprise | Folder | 0777 |
|
|
| ldap | Folder | 0777 |
|
|
| lti | Folder | 0777 |
|
|
| manual | Folder | 0777 |
|
|
| meta | Folder | 0777 |
|
|
| mnet | Folder | 0777 |
|
|
| paypal | Folder | 0777 |
|
|
| self | Folder | 0777 |
|
|
| tests | Folder | 0777 |
|
|
| yui | Folder | 0777 |
|
|
| README.txt | File | 245 B | 0777 |
|
| UPGRADING.md | File | 498 B | 0777 |
|
| ajax.php | File | 5.38 KB | 0777 |
|
| bulkchange_forms.php | File | 4.4 KB | 0777 |
|
| editenrolment.php | File | 3.94 KB | 0777 |
|
| editenrolment_form.php | File | 3.36 KB | 0777 |
|
| editinstance.php | File | 3.97 KB | 0777 |
|
| editinstance_form.php | File | 2.64 KB | 0777 |
|
| externallib.php | File | 64.7 KB | 0777 |
|
| index.php | File | 4.3 KB | 0777 |
|
| instances.php | File | 12.9 KB | 0777 |
|
| locallib.php | File | 61.63 KB | 0777 |
|
| otherusers.php | File | 4.01 KB | 0777 |
|
| renameroles.php | File | 2.1 KB | 0777 |
|
| renderer.php | File | 24.24 KB | 0777 |
|
| test_settings.php | File | 2.36 KB | 0777 |
|
| unenroluser.php | File | 3.22 KB | 0777 |
|
| upgrade.txt | File | 8.11 KB | 0777 |
|
| users_forms.php | File | 6.94 KB | 0777 |
|