Browse Source

Add new capability to control who gets warning emails.

MOODLE_32_STABLE
Dan Marsden 8 years ago
parent
commit
ad6919e3ec
  1. 2
      classes/add_warning_form.php
  2. 6
      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->setType('emailcontent', PARAM_RAW);
$mform->addHelpButton('emailcontent', 'emailcontent', 'mod_attendance'); $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(); $options = array();
foreach ($users as $user) { foreach ($users as $user) {
$options[$user->id] = fullname($user); $options[$user->id] = fullname($user);

6
classes/task/notify.php

@ -80,13 +80,19 @@ class notify extends \core\task\scheduled_task {
if (!empty($record->thirdpartyemails)) { if (!empty($record->thirdpartyemails)) {
$sendto = explode(',', $record->thirdpartyemails); $sendto = explode(',', $record->thirdpartyemails);
$record->percent = round($record->percent * 100)."%"; $record->percent = round($record->percent * 100)."%";
$context = context_module::instance($record->cmid);
foreach ($sendto as $senduser) { foreach ($sendto as $senduser) {
// Check user is allowed to receive warningemails.
if (has_capability('mod/attendance:warningemails', $context, $senduser)) {
if (empty($thirdpartynotifications[$senduser])) { if (empty($thirdpartynotifications[$senduser])) {
$thirdpartynotifications[$senduser] = array(); $thirdpartynotifications[$senduser] = array();
} }
if (!isset($thirdpartynotifications[$senduser][$record->aid . '_' . $record->userid])) { if (!isset($thirdpartynotifications[$senduser][$record->aid . '_' . $record->userid])) {
$thirdpartynotifications[$senduser][$record->aid . '_' . $record->userid] = get_string('thirdpartyemailtext', 'attendance', $record); $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 '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:view'] = 'Viewing Attendances';
$string['attendance:viewreports'] = 'Viewing Reports'; $string['attendance:viewreports'] = 'Viewing Reports';
$string['attendance:viewsummaryreports'] = 'View course summary 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['attendance_already_submitted'] = 'You may not self register attendance that has already been set.';
$string['attendancedata'] = 'Attendance data'; $string['attendancedata'] = 'Attendance data';
$string['attendanceforthecourse'] = 'Attendance for the course'; $string['attendanceforthecourse'] = 'Attendance for the course';

2
version.php

@ -23,7 +23,7 @@
*/ */
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->version = 2016121315; $plugin->version = 2016121316;
$plugin->requires = 2016111800; $plugin->requires = 2016111800;
$plugin->release = '3.2.14'; $plugin->release = '3.2.14';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;

Loading…
Cancel
Save