Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select users with capability not only enrolled #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,30 @@ protected function definition() {
$mform->setDefault('roleid', $plugin->get_config('roleid'));

$mform->addElement('textarea', 'customtext1', get_string('editdescription', 'enrol_apply'));
$mform->setType('customtext1', PARAM_TEXT);

//new added requirement_20190110
//$title_customtext2 = str_replace("{replace_title}",$instance->customtext2,get_string('custom_label', 'enrol_apply'));
$title_customtext2 = get_string('custom_label', 'enrol_apply');
$mform->addElement('text', 'customtext2', $title_customtext2);
$mform->setDefault('customtext2', "Comment");
$mform->setType('customtext2', PARAM_TEXT);

$options = array(1 => get_string('yes'),
0 => get_string('no'));

$mform->addElement('select', 'customint1', get_string('show_standard_user_profile', 'enrol_apply'), $options);
$mform->setDefault('customint1', $plugin->get_config('customint1'));
$mform->setType('customint1', PARAM_INT);

$mform->addElement('select', 'customint2', get_string('show_extra_user_profile', 'enrol_apply'), $options);
$mform->setDefault('customint2', $plugin->get_config('customint2'));
$mform->setType('customint2', PARAM_INT);

$choices = array(
'$@NONE@$' => get_string('nobody'),
'$@ALL@$' => get_string('everyonewhocan', 'admin', get_capability_string('enrol/apply:manageapplications')));
$users = get_enrolled_users($context, 'enrol/apply:manageapplications');
$users = get_users_by_capability($context, 'enrol/apply:manageapplications');
foreach ($users as $userid => $user) {
$choices[$userid] = fullname($user);
}
Expand Down
4 changes: 2 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private function send_application_notification($instance, $userid, $data) {
}

/**
* Returns enrolled users of a course who should be notified about new course enrolment applications.
* Returns users of a course who should be notified about new course enrolment applications.
*
* Note: mostly copied from get_users_from_config() function in moodlelib.php.
* @param array $instance Enrol apply instance record.
Expand All @@ -484,7 +484,7 @@ public function get_notifycoursebased_users($instance) {
// We have to make sure that users still have the necessary capability,
// it should be faster to fetch them all first and then test if they are present
// instead of validating them one-by-one.
$users = get_enrolled_users($context, 'enrol/apply:manageapplications');
$users = get_users_by_capability($context, 'enrol/apply:manageapplications');

if ($value === '$@ALL@$') {
return $users;
Expand Down