mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-26017 enrol: Add keyholder role
This commit is contained in:
parent
d87bcfb325
commit
0ac6a57ec5
@ -48,6 +48,15 @@ $capabilities = array(
|
||||
)
|
||||
),
|
||||
|
||||
'enrol/self:holdkey' => array(
|
||||
|
||||
'captype' => 'write',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
'manager' => CAP_PROHIBIT,
|
||||
)
|
||||
),
|
||||
|
||||
/* Voluntarily unenrol self from course - watch out for data loss. */
|
||||
'enrol/self:unenrolself' => array(
|
||||
'captype' => 'write',
|
||||
|
@ -63,6 +63,7 @@ $string['groupkey_desc'] = 'Use group enrolment keys by default.';
|
||||
$string['groupkey_help'] = 'In addition to restricting access to the course to only those who know the key, use of group enrolment keys means users are automatically added to groups when they enrol in the course.
|
||||
|
||||
Note: An enrolment key for the course must be specified in the self enrolment settings as well as group enrolment keys in the group settings.';
|
||||
$string['keyholder'] = 'You should have received this enrolment key from:';
|
||||
$string['longtimenosee'] = 'Unenrol inactive after';
|
||||
$string['longtimenosee_help'] = 'If users haven\'t accessed a course for a long time, then they are automatically unenrolled. This parameter specifies that time limit.';
|
||||
$string['maxenrolled'] = 'Max enrolled users';
|
||||
@ -88,6 +89,7 @@ $string['requirepassword'] = 'Require enrolment key';
|
||||
$string['requirepassword_desc'] = 'Require enrolment key in new courses and prevent removing of enrolment key from existing courses.';
|
||||
$string['role'] = 'Default assigned role';
|
||||
$string['self:config'] = 'Configure self enrol instances';
|
||||
$string['self:holdkey'] = 'Appear as the self enrolment key holder';
|
||||
$string['self:manage'] = 'Manage enrolled users';
|
||||
$string['self:unenrol'] = 'Unenrol users from course';
|
||||
$string['self:unenrolself'] = 'Unenrol self from the course';
|
||||
|
@ -41,6 +41,7 @@ class enrol_self_enrol_form extends moodleform {
|
||||
}
|
||||
|
||||
public function definition() {
|
||||
global $USER, $OUTPUT, $CFG;
|
||||
$mform = $this->_form;
|
||||
$instance = $this->_customdata;
|
||||
$this->instance = $instance;
|
||||
@ -53,6 +54,26 @@ class enrol_self_enrol_form extends moodleform {
|
||||
// Change the id of self enrolment key input as there can be multiple self enrolment methods.
|
||||
$mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_self'),
|
||||
array('id' => 'enrolpassword_'.$instance->id));
|
||||
$context = context_course::instance($this->instance->courseid);
|
||||
$keyholders = get_users_by_capability($context, 'enrol/self:holdkey', user_picture::fields('u'));
|
||||
$keyholdercount = 0;
|
||||
foreach ($keyholders as $keyholder) {
|
||||
$keyholdercount++;
|
||||
if ($keyholdercount === 1) {
|
||||
$mform->addElement('static', 'keyholder', '', get_string('keyholder', 'enrol_self'));
|
||||
}
|
||||
$keyholdercontext = context_user::instance($keyholder->id);
|
||||
if ($USER->id == $keyholder->id || has_capability('moodle/user:viewdetails', context_system::instance()) ||
|
||||
has_coursecontact_role($keyholder->id)) {
|
||||
$profilelink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $keyholder->id . '&course=' .
|
||||
$this->instance->courseid . '">' . fullname($keyholder) . '</a>';
|
||||
} else {
|
||||
$profilelink = fullname($keyholder);
|
||||
}
|
||||
$profilepic = $OUTPUT->user_picture($keyholder, array('size' => 35, 'courseid' => $this->instance->courseid));
|
||||
$mform->addElement('static', 'keyholder'.$keyholdercount, '', $profilepic . $profilelink);
|
||||
}
|
||||
|
||||
} else {
|
||||
$mform->addElement('static', 'nokey', '', get_string('nopassword', 'enrol_self'));
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2014111000; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->version = 2014111001; // The current plugin version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2014110400; // Requires this Moodle version
|
||||
$plugin->component = 'enrol_self'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->cron = 600;
|
||||
|
Loading…
x
Reference in New Issue
Block a user