Browse Source

Add new capability to control who gets warning emails.

MOODLE_33_STABLE
Dan Marsden 8 years ago
parent
commit
d277d10bb7
  1. 2
      classes/add_warning_form.php
  2. 10
      classes/task/notify.php
  3. 12
      db/access.php
  4. 1
      lang/en/attendance.php
  5. 2
      version.php

2
classes/add_warning_form.php

@ -75,7 +75,7 @@ class mod_attendance_add_warning_form extends moodleform {
$mform->setType('emailcontent', PARAM_RAW);
$mform->addHelpButton('emailcontent', 'emailcontent', 'mod_attendance');
$users = get_users_by_capability(context_course::instance($COURSE->id), 'mod/attendance:viewreports');
$users = get_users_by_capability(context_course::instance($COURSE->id), 'mod/attendance:warningemails');
$options = array();
foreach ($users as $user) {
$options[$user->id] = fullname($user);

10
classes/task/notify.php

@ -80,12 +80,18 @@ class notify extends \core\task\scheduled_task {
if (!empty($record->thirdpartyemails)) {
$sendto = explode(',', $record->thirdpartyemails);
$record->percent = round($record->percent * 100)."%";
$context = context_module::instance($record->cmid);
foreach ($sendto as $senduser) {
// Check user is allowed to receive warningemails.
if (has_capability('mod/attendance:warningemails', $context, $senduser)) {
if (empty($thirdpartynotifications[$senduser])) {
$thirdpartynotifications[$senduser] = array();
}
if (!isset($thirdpartynotifications[$senduser][$record->aid.'_'.$record->userid])) {
$thirdpartynotifications[$senduser][$record->aid.'_'.$record->userid] = get_string('thirdpartyemailtext', 'attendance', $record);
if (!isset($thirdpartynotifications[$senduser][$record->aid . '_' . $record->userid])) {
$thirdpartynotifications[$senduser][$record->aid . '_' . $record->userid] = get_string('thirdpartyemailtext', 'attendance', $record);
}
} else {
mtrace("user".$senduser. "does not have capablity in cm".$record->cmid);
}
}
}

12
db/access.php

@ -141,4 +141,16 @@ $capabilities = array(
'manager' => CAP_ALLOW
)
),
// Users that can receive extra warning e-mails.
'mod/attendance:warningemails' => array(
'riskbitmask' => RISK_DATALOSS,
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
);

1
lang/en/attendance.php

@ -52,6 +52,7 @@ $string['attendance:takeattendances'] = 'Taking Attendances';
$string['attendance:view'] = 'Viewing Attendances';
$string['attendance:viewreports'] = 'Viewing Reports';
$string['attendance:viewsummaryreports'] = 'View course summary reports';
$string['attendance:warningemails'] = 'Can be subscribed to emails with at-risk users';
$string['attendance_already_submitted'] = 'You may not self register attendance that has already been set.';
$string['attendancedata'] = 'Attendance data';
$string['attendanceforthecourse'] = 'Attendance for the course';

2
version.php

@ -23,7 +23,7 @@
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2017050210;
$plugin->version = 2017050211;
$plugin->requires = 2017042100;
$plugin->release = '3.3.9';
$plugin->maturity = MATURITY_STABLE;

Loading…
Cancel
Save