MDL-23232 added support for enrol_plugin->all_enrol() which indicates plugin allows users to add new enrolments manually
This commit is contained in:
+2
-2
@@ -629,7 +629,7 @@ class course_enrolment_manager {
|
||||
public function enrol_cohort_users($cohortid, $roleid) {
|
||||
global $DB;
|
||||
require_capability('moodle/course:enrolconfig', $this->get_context());
|
||||
require_capability('enrol/manual:manage', $this->get_context());
|
||||
require_capability('enrol/manual:enrol', $this->get_context());
|
||||
$instances = $this->get_enrolment_instances();
|
||||
$instance = false;
|
||||
foreach ($instances as $i) {
|
||||
@@ -643,7 +643,7 @@ class course_enrolment_manager {
|
||||
}
|
||||
$plugin = enrol_get_plugin('manual');
|
||||
|
||||
$sql = "SELECT com.userid
|
||||
$sql = "SELECT com.userid
|
||||
FROM {cohort_members} com
|
||||
LEFT JOIN (
|
||||
SELECT *
|
||||
|
||||
@@ -34,7 +34,7 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'enrol/manual:manage' => array(
|
||||
'enrol/manual:enrol' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
@@ -43,6 +43,14 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'enrol/manual:manage' => array(
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'legacy' => array(
|
||||
'manager' => CAP_ALLOW,
|
||||
'editingteacher' => CAP_ALLOW,
|
||||
)
|
||||
),
|
||||
|
||||
'enrol/manual:unenrol' => array(
|
||||
'captype' => 'write',
|
||||
|
||||
@@ -29,7 +29,8 @@ $string['defaultperiod_desc'] = 'Default length of the default enrolment period
|
||||
$string['enrolledincourserole'] = 'Enrolled in "{$a->course}" as "{$a->role}"';
|
||||
$string['enrolusers'] = 'Enrol users';
|
||||
$string['manual:config'] = 'Configure manual enrol instances';
|
||||
$string['manual:manage'] = 'Manage enrolled users';
|
||||
$string['manual:enrol'] = 'Enrol users';
|
||||
$string['manual:manage'] = 'Manage user enrolments';
|
||||
$string['manual:unenrol'] = 'Unenrol users from the course';
|
||||
$string['manual:unenrolself'] = 'Unenrol self from the course';
|
||||
$string['pluginname'] = 'Manual enrolments';
|
||||
|
||||
@@ -32,6 +32,11 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function allow_enrol(stdClass $instance) {
|
||||
// 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
|
||||
return true;
|
||||
@@ -65,7 +70,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $instance->courseid, MUST_EXIST);
|
||||
|
||||
if (!has_capability('enrol/manual:manage', $context)) {
|
||||
if (!has_capability('enrol/manual:manage', $context) or !has_capability('enrol/manual:enrol', $context) or !has_capability('enrol/manual:unenrol', $context)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ $course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
|
||||
|
||||
require_login($course);
|
||||
require_capability('enrol/manual:enrol', $context);
|
||||
require_capability('enrol/manual:manage', $context);
|
||||
require_capability('enrol/manual:unenrol', $context);
|
||||
|
||||
$instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'manual'), '*', MUST_EXIST);
|
||||
if ($roleid < 0) {
|
||||
|
||||
@@ -23,4 +23,4 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$plugin->version = 2010061500;
|
||||
$plugin->version = 2010071200;
|
||||
|
||||
+15
-3
@@ -749,13 +749,25 @@ abstract class enrol_plugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this plugin allow manual enrolments?
|
||||
*
|
||||
* @param stdClass $instance course enrol instance
|
||||
* All plugins allowing this must implement 'enrol/xxx:enrol' capability
|
||||
*
|
||||
* @return bool - true means user with 'enrol/xxx:enrol' may enrol others freely, trues means nobody may add more enrolments manually
|
||||
*/
|
||||
public function allow_enrol(stdClass $instance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does this plugin allow manual unenrolments?
|
||||
*
|
||||
* @param stdClass $instance course enrol instance
|
||||
* ALl plugins allowing this must implement 'enrol/xxx:unenrol' capability
|
||||
* All plugins allowing this must implement 'enrol/xxx:unenrol' capability
|
||||
*
|
||||
* @return bool - true means anybody may unenrol others freely, trues means nobody may touch user_enrolments
|
||||
* @return bool - true means user with 'enrol/xxx:unenrol' may unenrol others freely, trues means nobody may touch user_enrolments
|
||||
*/
|
||||
public function allow_unenrol(stdClass $instance) {
|
||||
return false;
|
||||
@@ -764,7 +776,7 @@ abstract class enrol_plugin {
|
||||
/**
|
||||
* Does this plugin allow manual changes in user_enrolments table?
|
||||
*
|
||||
* ALl plugins allowing this must implement 'enrol/xxx:manage' capability
|
||||
* All plugins allowing this must implement 'enrol/xxx:manage' capability
|
||||
*
|
||||
* @param stdClass $instance course enrol instance
|
||||
* @return bool - true means it is possible to change enrol period and status in user_enrolments table
|
||||
|
||||
Reference in New Issue
Block a user