Merge branch 'w35_MDL-35072_m24_mancleanup' of git://github.com/skodak/moodle
This commit is contained in:
@@ -20,8 +20,7 @@
|
||||
* The general idea behind this file is that any errors should throw exceptions
|
||||
* which will be returned and acted upon by the calling AJAX script.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -32,8 +31,7 @@ require('../../config.php');
|
||||
require_once($CFG->dirroot.'/enrol/locallib.php');
|
||||
require_once($CFG->dirroot.'/group/lib.php');
|
||||
|
||||
// Must have the sesskey
|
||||
$id = required_param('id', PARAM_INT); // course id
|
||||
$id = required_param('id', PARAM_INT); // Course id.
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
|
||||
$PAGE->set_url(new moodle_url('/enrol/ajax.php', array('id'=>$id, 'action'=>$action)));
|
||||
@@ -49,7 +47,7 @@ require_login($course);
|
||||
require_capability('moodle/course:enrolreview', $context);
|
||||
require_sesskey();
|
||||
|
||||
echo $OUTPUT->header(); // send headers
|
||||
echo $OUTPUT->header(); // Send headers.
|
||||
|
||||
$manager = new course_enrolment_manager($PAGE, $course);
|
||||
|
||||
@@ -135,4 +133,4 @@ switch ($action) {
|
||||
throw new enrol_ajax_exception('unknowajaxaction');
|
||||
}
|
||||
|
||||
echo json_encode($outcome);
|
||||
echo json_encode($outcome);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +17,7 @@
|
||||
/**
|
||||
* This file contains form for bulk changing user enrolments.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage enrol
|
||||
* @package enrol_manual
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -29,7 +27,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
require_once("$CFG->dirroot/enrol/bulkchange_forms.php");
|
||||
|
||||
/**
|
||||
* The form to collect required information when bulk editing users enrolments
|
||||
* The form to collect required information when bulk editing users enrolments.
|
||||
*
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
|
||||
@@ -26,6 +26,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$capabilities = array(
|
||||
|
||||
/* Add, edit or remove manual enrol instance. */
|
||||
'enrol/manual:config' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
@@ -34,6 +35,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
/* Enrol anybody. */
|
||||
'enrol/manual:enrol' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
@@ -43,6 +45,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
/* Manage enrolments of users. */
|
||||
'enrol/manual:manage' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
@@ -52,6 +55,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
/* Unenrol anybody (including self) - watch out for data loss. */
|
||||
'enrol/manual:unenrol' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
@@ -61,6 +65,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
/* Unenrol self - watch out for data loss. */
|
||||
'enrol/manual:unenrolself' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
@@ -69,4 +74,3 @@ $capabilities = array(
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +17,7 @@
|
||||
/**
|
||||
* Manual enrol plugin installation script
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -19,8 +18,7 @@
|
||||
* Adds new instance of enrol_manual to specified course
|
||||
* or edits current instance.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -49,14 +47,14 @@ $plugin = enrol_get_plugin('manual');
|
||||
if ($instances = $DB->get_records('enrol', array('courseid'=>$course->id, 'enrol'=>'manual'), 'id ASC')) {
|
||||
$instance = array_shift($instances);
|
||||
if ($instances) {
|
||||
// oh - we allow only one instance per course!!
|
||||
// Oh - we allow only one instance per course!!
|
||||
foreach ($instances as $del) {
|
||||
$plugin->delete_instance($del);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
require_capability('moodle/course:enrolconfig', $context);
|
||||
// no instance yet, we have to add new instance
|
||||
// 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 = new stdClass();
|
||||
$instance->id = null;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -19,8 +18,7 @@
|
||||
* Adds new instance of enrol_manual to specified course
|
||||
* or edits current instance.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -62,4 +60,4 @@ class enrol_manual_edit_form extends moodleform {
|
||||
|
||||
$this->set_data($instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,46 +20,42 @@
|
||||
* This page allows the current user to edit a manual user enrolment.
|
||||
* It is not compatible with the frontpage.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../../config.php');
|
||||
require_once("$CFG->dirroot/enrol/locallib.php");
|
||||
require_once("$CFG->dirroot/enrol/renderer.php"); // Required for the course enrolment manager table
|
||||
require_once("$CFG->dirroot/enrol/renderer.php"); // Required for the course enrolment manager table.
|
||||
require_once("$CFG->dirroot/enrol/manual/editenrolment_form.php");
|
||||
|
||||
$ueid = required_param('ue', PARAM_INT); // user enrolment id
|
||||
$ueid = required_param('ue', PARAM_INT); // User enrolment id.
|
||||
$filter = optional_param('ifilter', 0, PARAM_INT);
|
||||
|
||||
// Get the user enrolment object
|
||||
$ue = $DB->get_record('user_enrolments', array('id' => $ueid), '*', MUST_EXIST);
|
||||
// Get the user for whom the enrolment is
|
||||
$user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST);
|
||||
// Get the course the enrolment is to
|
||||
list($ctxsql, $ctxjoin) = context_instance_preload_sql('c.id', CONTEXT_COURSE, 'ctx');
|
||||
$sql = "SELECT c.* $ctxsql
|
||||
// Get the user enrolment object.
|
||||
$ue = $DB->get_record('user_enrolments', array('id' => $ueid), '*', MUST_EXIST);
|
||||
// Get the user for whom the enrolment is.
|
||||
$user = $DB->get_record('user', array('id'=>$ue->userid), '*', MUST_EXIST);
|
||||
// Get the course the enrolment is to.
|
||||
$sql = "SELECT c.*
|
||||
FROM {course} c
|
||||
LEFT JOIN {enrol} e ON e.courseid = c.id
|
||||
$ctxjoin
|
||||
JOIN {enrol} e ON e.courseid = c.id
|
||||
WHERE e.id = :enrolid";
|
||||
$params = array('enrolid' => $ue->enrolid);
|
||||
$course = $DB->get_record_sql($sql, $params, MUST_EXIST);
|
||||
context_instance_preload($course);
|
||||
|
||||
// Make sure its not the front page course
|
||||
// Make sure its not the front page course.
|
||||
if ($course->id == SITEID) {
|
||||
redirect(new moodle_url('/'));
|
||||
}
|
||||
|
||||
// Obviously
|
||||
// Obviously.
|
||||
require_login($course);
|
||||
// Make sure the user can manage manual enrolments for this course
|
||||
// Make sure the user can manage manual enrolments for this course.
|
||||
require_capability("enrol/manual:manage", context_course::instance($course->id, MUST_EXIST));
|
||||
|
||||
// Get the enrolment manager for this course
|
||||
// Get the enrolment manager for this course.
|
||||
$manager = new course_enrolment_manager($PAGE, $course, $filter);
|
||||
// Get an enrolment users table object. Doign this will automatically retrieve the the URL params
|
||||
// relating to table the user was viewing before coming here, and allows us to return the user to the
|
||||
@@ -70,7 +66,7 @@ $table = new course_enrolment_users_table($manager, $PAGE);
|
||||
$usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id));
|
||||
// The URl to return the user too after this screen.
|
||||
$returnurl = new moodle_url($usersurl, $manager->get_url_params()+$table->get_url_params());
|
||||
// The URL of this page
|
||||
// The URL of this page.
|
||||
$url = new moodle_url('/enrol/manual/editenrolment.php', $returnurl->params());
|
||||
|
||||
$PAGE->set_url($url);
|
||||
@@ -88,9 +84,7 @@ $mform->set_data($PAGE->url->params());
|
||||
// Check the form hasn't been cancelled
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect($returnurl);
|
||||
} else if ($mform->is_submitted() && $mform->is_validated() && confirm_sesskey()) {
|
||||
// The forms been submit, validated and the sesskey has been checked ... edit the enrolment.
|
||||
$data = $mform->get_data();
|
||||
} else if ($data = $mform->get_data()) {
|
||||
if ($manager->edit_enrolment($ue, $data)) {
|
||||
redirect($returnurl);
|
||||
}
|
||||
@@ -107,4 +101,4 @@ $PAGE->navbar->add($fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading($fullname);
|
||||
$mform->display();
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +17,7 @@
|
||||
/**
|
||||
* Contains the form used to edit manual enrolments for a user.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2011 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -80,4 +78,4 @@ class enrol_manual_user_enrolment_form extends moodleform {
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/**
|
||||
* External course participation api.
|
||||
*
|
||||
@@ -32,7 +31,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
require_once("$CFG->libdir/externallib.php");
|
||||
|
||||
/**
|
||||
* Manual enrolment external functions
|
||||
* Manual enrolment external functions.
|
||||
*
|
||||
* @package enrol_manual
|
||||
* @category external
|
||||
@@ -43,7 +42,7 @@ require_once("$CFG->libdir/externallib.php");
|
||||
class enrol_manual_external extends external_api {
|
||||
|
||||
/**
|
||||
* Returns description of method parameters
|
||||
* Returns description of method parameters.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
* @since Moodle 2.2
|
||||
@@ -68,7 +67,7 @@ class enrol_manual_external extends external_api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enrolment of users
|
||||
* Enrolment of users.
|
||||
*
|
||||
* Function throw an exception at the first error encountered.
|
||||
* @param array $enrolments An array of user enrolment
|
||||
@@ -82,24 +81,24 @@ class enrol_manual_external extends external_api {
|
||||
$params = self::validate_parameters(self::enrol_users_parameters(),
|
||||
array('enrolments' => $enrolments));
|
||||
|
||||
$transaction = $DB->start_delegated_transaction(); //rollback all enrolment if an error occurs
|
||||
//(except if the DB doesn't support it)
|
||||
$transaction = $DB->start_delegated_transaction(); // Rollback all enrolment if an error occurs
|
||||
// (except if the DB doesn't support it).
|
||||
|
||||
//retrieve the manual enrolment plugin
|
||||
// Retrieve the manual enrolment plugin.
|
||||
$enrol = enrol_get_plugin('manual');
|
||||
if (empty($enrol)) {
|
||||
throw new moodle_exception('manualpluginnotinstalled', 'enrol_manual');
|
||||
}
|
||||
|
||||
foreach ($params['enrolments'] as $enrolment) {
|
||||
// Ensure the current user is allowed to run this function in the enrolment context
|
||||
// Ensure the current user is allowed to run this function in the enrolment context.
|
||||
$context = context_course::instance($enrolment['courseid'], IGNORE_MISSING);
|
||||
self::validate_context($context);
|
||||
|
||||
//check that the user has the permission to manual enrol
|
||||
// Check that the user has the permission to manual enrol.
|
||||
require_capability('enrol/manual:enrol', $context);
|
||||
|
||||
//throw an exception if user is not able to assign the role
|
||||
// Throw an exception if user is not able to assign the role.
|
||||
$roles = get_assignable_roles($context);
|
||||
if (!key_exists($enrolment['roleid'], $roles)) {
|
||||
$errorparams = new stdClass();
|
||||
@@ -109,7 +108,7 @@ class enrol_manual_external extends external_api {
|
||||
throw new moodle_exception('wsusercannotassign', 'enrol_manual', '', $errorparams);
|
||||
}
|
||||
|
||||
//check manual enrolment plugin instance is enabled/exist
|
||||
// Check manual enrolment plugin instance is enabled/exist.
|
||||
$enrolinstances = enrol_get_instances($enrolment['courseid'], true);
|
||||
foreach ($enrolinstances as $courseenrolinstance) {
|
||||
if ($courseenrolinstance->enrol == "manual") {
|
||||
@@ -123,7 +122,7 @@ class enrol_manual_external extends external_api {
|
||||
throw new moodle_exception('wsnoinstance', 'enrol_manual', $errorparams);
|
||||
}
|
||||
|
||||
//check that the plugin accept enrolment (it should always the case, it's hard coded in the plugin)
|
||||
// Check that the plugin accept enrolment (it should always the case, it's hard coded in the plugin).
|
||||
if (!$enrol->allow_enrol($instance)) {
|
||||
$errorparams = new stdClass();
|
||||
$errorparams->roleid = $enrolment['roleid'];
|
||||
@@ -132,7 +131,7 @@ class enrol_manual_external extends external_api {
|
||||
throw new moodle_exception('wscannotenrol', 'enrol_manual', '', $errorparams);
|
||||
}
|
||||
|
||||
//finally proceed the enrolment
|
||||
// Finally proceed the enrolment.
|
||||
$enrolment['timestart'] = isset($enrolment['timestart']) ? $enrolment['timestart'] : 0;
|
||||
$enrolment['timeend'] = isset($enrolment['timeend']) ? $enrolment['timeend'] : 0;
|
||||
$enrolment['status'] = (isset($enrolment['suspend']) && !empty($enrolment['suspend'])) ?
|
||||
@@ -147,7 +146,7 @@ class enrol_manual_external extends external_api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value
|
||||
* Returns description of method result value.
|
||||
*
|
||||
* @return null
|
||||
* @since Moodle 2.2
|
||||
@@ -159,7 +158,7 @@ class enrol_manual_external extends external_api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated manual enrolment external functions
|
||||
* Deprecated manual enrolment external functions.
|
||||
*
|
||||
* @package enrol_manual
|
||||
* @copyright 2011 Jerome Mouneyrac
|
||||
@@ -172,7 +171,7 @@ class enrol_manual_external extends external_api {
|
||||
class moodle_enrol_manual_external extends external_api {
|
||||
|
||||
/**
|
||||
* Returns description of method parameters
|
||||
* Returns description of method parameters.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
* @since Moodle 2.0
|
||||
@@ -199,7 +198,7 @@ class moodle_enrol_manual_external extends external_api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value
|
||||
* Returns description of method result value.
|
||||
*
|
||||
* @return nul
|
||||
* @since Moodle 2.0
|
||||
|
||||
+11
-13
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +17,7 @@
|
||||
/**
|
||||
* Manual enrolment plugin main library file.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -29,22 +27,22 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class enrol_manual_plugin extends enrol_plugin {
|
||||
|
||||
public function roles_protected() {
|
||||
// users may tweak the roles later
|
||||
// Users may tweak the roles later.
|
||||
return false;
|
||||
}
|
||||
|
||||
public function allow_enrol(stdClass $instance) {
|
||||
// users with enrol cap may unenrol other users manually manually
|
||||
// Users with enrol cap may unenrol other users manually manually.
|
||||
return true;
|
||||
}
|
||||
|
||||
public function allow_unenrol(stdClass $instance) {
|
||||
// users with unenrol cap may unenrol other users manually manually
|
||||
// Users with unenrol cap may unenrol other users manually manually.
|
||||
return true;
|
||||
}
|
||||
|
||||
public function allow_manage(stdClass $instance) {
|
||||
// users with manage cap may tweak period and status
|
||||
// Users with manage cap may tweak period and status.
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -52,7 +50,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
* Returns link to manual enrol UI if exists.
|
||||
* Does the access control tests automatically.
|
||||
*
|
||||
* @param object $instance
|
||||
* @param stdClass $instance
|
||||
* @return moodle_url
|
||||
*/
|
||||
public function get_manual_enrol_link($instance) {
|
||||
@@ -96,7 +94,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns edit icons for the page with list of instances
|
||||
* Returns edit icons for the page with list of instances.
|
||||
* @param stdClass $instance
|
||||
* @return array
|
||||
*/
|
||||
@@ -145,7 +143,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
|
||||
/**
|
||||
* Add new instance of enrol plugin with default settings.
|
||||
* @param object $course
|
||||
* @param stdClass $course
|
||||
* @return int id of new instance, null if can not be created
|
||||
*/
|
||||
public function add_default_instance($course) {
|
||||
@@ -155,7 +153,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
|
||||
/**
|
||||
* Add new instance of enrol plugin.
|
||||
* @param object $course
|
||||
* @param stdClass $course
|
||||
* @param array instance fields
|
||||
* @return int id of new instance, null if can not be created
|
||||
*/
|
||||
@@ -260,7 +258,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an array of the user enrolment actions
|
||||
* Gets an array of the user enrolment actions.
|
||||
*
|
||||
* @param course_enrolment_manager $manager
|
||||
* @param stdClass $ue A user enrolment object
|
||||
@@ -284,7 +282,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* The manual plugin has several bulk operations that can be performed
|
||||
* The manual plugin has several bulk operations that can be performed.
|
||||
* @param course_enrolment_manager $manager
|
||||
* @return array
|
||||
*/
|
||||
|
||||
+12
-14
@@ -17,8 +17,7 @@
|
||||
/**
|
||||
* Auxiliary manual user enrolment lib, the main purpose is to lower memory requirements...
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -30,7 +29,7 @@ require_once($CFG->dirroot . '/enrol/locallib.php');
|
||||
|
||||
|
||||
/**
|
||||
* Enrol candidates
|
||||
* Enrol candidates.
|
||||
*/
|
||||
class enrol_manual_potential_participant extends user_selector_base {
|
||||
protected $enrolid;
|
||||
@@ -42,12 +41,12 @@ class enrol_manual_potential_participant extends user_selector_base {
|
||||
|
||||
/**
|
||||
* Candidate users
|
||||
* @param <type> $search
|
||||
* @param string $search
|
||||
* @return array
|
||||
*/
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
//by default wherecondition retrieves all users except the deleted, not confirmed and guest
|
||||
// By default wherecondition retrieves all users except the deleted, not confirmed and guest.
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
$params['enrolid'] = $this->enrolid;
|
||||
|
||||
@@ -92,7 +91,7 @@ class enrol_manual_potential_participant extends user_selector_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enroled users
|
||||
* Enrolled users.
|
||||
*/
|
||||
class enrol_manual_current_participant extends user_selector_base {
|
||||
protected $courseid;
|
||||
@@ -105,12 +104,12 @@ class enrol_manual_current_participant extends user_selector_base {
|
||||
|
||||
/**
|
||||
* Candidate users
|
||||
* @param <type> $search
|
||||
* @param string $search
|
||||
* @return array
|
||||
*/
|
||||
public function find_users($search) {
|
||||
global $DB;
|
||||
//by default wherecondition retrieves all users except the deleted, not confirmed and guest
|
||||
// By default wherecondition retrieves all users except the deleted, not confirmed and guest.
|
||||
list($wherecondition, $params) = $this->search_sql($search, 'u');
|
||||
$params['enrolid'] = $this->enrolid;
|
||||
|
||||
@@ -182,7 +181,6 @@ class enrol_manual_editselectedusers_operation extends enrol_bulk_enrolment_oper
|
||||
/**
|
||||
* Processes the bulk operation request for the given userids with the provided properties.
|
||||
*
|
||||
* @global moodle_database $DB
|
||||
* @param course_enrolment_manager $manager
|
||||
* @param array $userids
|
||||
* @param stdClass $properties The data returned by the form.
|
||||
@@ -194,7 +192,7 @@ class enrol_manual_editselectedusers_operation extends enrol_bulk_enrolment_oper
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get all of the user enrolment id's
|
||||
// Get all of the user enrolment id's.
|
||||
$ueids = array();
|
||||
$instances = array();
|
||||
foreach ($users as $user) {
|
||||
@@ -237,15 +235,15 @@ class enrol_manual_editselectedusers_operation extends enrol_bulk_enrolment_oper
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update the modifierid
|
||||
// Update the modifierid.
|
||||
$updatesql[] = 'modifierid = :modifierid';
|
||||
$params['modifierid'] = (int)$USER->id;
|
||||
|
||||
// Update the time modified
|
||||
// Update the time modified.
|
||||
$updatesql[] = 'timemodified = :timemodified';
|
||||
$params['timemodified'] = time();
|
||||
|
||||
// Build the SQL statement
|
||||
// Build the SQL statement.
|
||||
$updatesql = join(', ', $updatesql);
|
||||
$sql = "UPDATE {user_enrolments}
|
||||
SET $updatesql
|
||||
@@ -353,4 +351,4 @@ class enrol_manual_deleteselectedusers_operation extends enrol_bulk_enrolment_op
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
/**
|
||||
* Manual user enrolment UI.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -47,7 +46,7 @@ $roles = get_assignable_roles($context);
|
||||
$roles = array('0'=>get_string('none')) + $roles;
|
||||
|
||||
if (!isset($roles[$roleid])) {
|
||||
// weird - security always first!
|
||||
// Weird - security always first!
|
||||
$roleid = 0;
|
||||
}
|
||||
|
||||
@@ -88,14 +87,14 @@ $timeformat = get_string('strftimedatefullshort');
|
||||
$today = time();
|
||||
$today = make_timestamp(date('Y', $today), date('m', $today), date('d', $today), 0, 0, 0);
|
||||
|
||||
// enrolment start
|
||||
// Enrolment start.
|
||||
$basemenu = array();
|
||||
if ($course->startdate > 0) {
|
||||
$basemenu[2] = get_string('coursestart') . ' (' . userdate($course->startdate, $timeformat) . ')';
|
||||
}
|
||||
$basemenu[3] = get_string('today') . ' (' . userdate($today, $timeformat) . ')' ;
|
||||
|
||||
// process add and removes
|
||||
// Process add and removes.
|
||||
if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$userstoassign = $potentialuserselector->get_selected_users();
|
||||
if (!empty($userstoassign)) {
|
||||
@@ -126,7 +125,7 @@ if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
}
|
||||
}
|
||||
|
||||
// Process incoming role unassignments
|
||||
// Process incoming role unassignments.
|
||||
if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) {
|
||||
$userstounassign = $currentuserselector->get_selected_users();
|
||||
if (!empty($userstounassign)) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +17,7 @@
|
||||
/**
|
||||
* Manual enrolment plugin settings and presets.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -55,4 +53,3 @@ if ($ADMIN->fulltree) {
|
||||
get_string('defaultrole', 'role'), '', $student->id, $options));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
@@ -18,8 +17,7 @@
|
||||
/**
|
||||
* Manual enrolment plugin - support for user self unenrolment.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
@@ -41,7 +39,7 @@ require_login($course);
|
||||
|
||||
$plugin = enrol_get_plugin('manual');
|
||||
|
||||
// security defined inside following function
|
||||
// Security defined inside following function.
|
||||
if (!$plugin->get_unenrolself_link($instance)) {
|
||||
redirect(new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||
}
|
||||
@@ -51,7 +49,7 @@ $PAGE->set_title($plugin->get_instance_name($instance));
|
||||
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
$plugin->unenrol_user($instance, $USER->id);
|
||||
add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //there should be userid somewhere!
|
||||
add_to_log($course->id, 'course', 'unenrol', '../enrol/users.php?id='.$course->id, $course->id); //TODO: there should be userid somewhere!
|
||||
redirect(new moodle_url('/index.php'));
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
/**
|
||||
* Manual enrolment plugin version specification.
|
||||
*
|
||||
* @package enrol
|
||||
* @subpackage manual
|
||||
* @package enrol_manual
|
||||
* @copyright 2010 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user