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) {
}
$plugin = enrol_get_plugin('manual');
- $sql = "SELECT com.userid
+ $sql = "SELECT com.userid
FROM {cohort_members} com
LEFT JOIN (
SELECT *
)
),
- 'enrol/manual:manage' => array(
+ 'enrol/manual:enrol' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
)
),
+ 'enrol/manual:manage' => array(
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_COURSE,
+ 'legacy' => array(
+ 'manager' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ )
+ ),
'enrol/manual:unenrol' => array(
'captype' => 'write',
$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';
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;
$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;
}
$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) {
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$plugin->version = 2010061500;
+$plugin->version = 2010071200;
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;
/**
* 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