diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 1ef4bd8..8ff3d86 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -25,8 +25,6 @@ namespace local_reminders\privacy; -defined('MOODLE_INTERNAL') || die(); - /** * Privacy provider class for package local_reminders */ diff --git a/contents/activity_handlers.class.php b/contents/activity_handlers.class.php index b3733a7..adbdc57 100644 --- a/contents/activity_handlers.class.php +++ b/contents/activity_handlers.class.php @@ -137,7 +137,7 @@ class local_reminder_generic_handler extends local_reminder_activity_handler { * @return array array of filtered users. */ public function filter_authorized_users($users, $type, $activity, $course, $coursemodule, $coursemodulecontext) { - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $status = $this->check_completion_status($course, $coursemodule, $auser->id); if (!$status) { @@ -204,7 +204,7 @@ public function filter_authorized_users($users, $type, $activity, $course, $cour global $CFG; require_once($CFG->dirroot . '/mod/quiz/lib.php'); - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $canattempt = has_capability('mod/quiz:attempt', $coursemodulecontext, $auser); if (!$canattempt) { @@ -263,7 +263,7 @@ public function filter_authorized_users($users, $type, $activity, $course, $cour require_once($CFG->dirroot . '/mod/assign/lib.php'); require_once($CFG->dirroot . '/lib/completionlib.php'); - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $cansubmit = has_capability('mod/assign:submit', $coursemodulecontext, $auser); if (!$cansubmit) { @@ -339,7 +339,7 @@ public function filter_authorized_users($users, $type, $activity, $course, $cour require_once($CFG->dirroot . '/mod/choice/lib.php'); require_once($CFG->dirroot . '/lib/completionlib.php'); - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $cansubmit = has_capability('mod/choice:choose', $coursemodulecontext, $auser); if (!$cansubmit) { @@ -393,7 +393,7 @@ public function filter_authorized_users($users, $type, $activity, $course, $cour require_once($CFG->dirroot . '/mod/feedback/lib.php'); require_once($CFG->dirroot . '/lib/completionlib.php'); - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $cansubmit = has_capability('mod/feedback:complete', $coursemodulecontext, $auser); if (!$cansubmit) { @@ -447,7 +447,7 @@ public function filter_authorized_users($users, $type, $activity, $course, $cour global $CFG; require_once($CFG->dirroot . '/mod/lesson/lib.php'); - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $cansubmit = has_capability('mod/lesson:view', $coursemodulecontext, $auser); if (!$cansubmit) { @@ -519,7 +519,7 @@ public function filter_authorized_users($users, $type, $activity, $course, $cour global $CFG; require_once($CFG->dirroot . '/mod/survey/lib.php'); - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $cansubmit = has_capability('mod/survey:participate', $coursemodulecontext, $auser); if (!$cansubmit) { @@ -572,7 +572,7 @@ public function filter_authorized_users($users, $type, $activity, $course, $cour global $CFG; require_once($CFG->dirroot . '/mod/resource/lib.php'); - $filteredusers = array(); + $filteredusers = []; foreach ($users as $auser) { $cansubmit = has_capability('mod/resource:view', $coursemodulecontext, $auser); if (!$cansubmit) { diff --git a/contents/category_reminder.class.php b/contents/category_reminder.class.php index 60fa831..8979b95 100644 --- a/contents/category_reminder.class.php +++ b/contents/category_reminder.class.php @@ -50,10 +50,10 @@ class category_reminder extends local_reminder { * @param object $event calendar event. * @param object $coursecategory course instance. * @param integer $aheaddays number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). */ - public function __construct($event, $coursecategory, $aheaddays = 1, $custom_time = null) { - parent::__construct($event, $aheaddays, $custom_time); + public function __construct($event, $coursecategory, $aheaddays = 1, $customtime = null) { + parent::__construct($event, $aheaddays, $customtime); $this->coursecategory = $coursecategory; } @@ -67,11 +67,11 @@ public function __construct($event, $coursecategory, $aheaddays = 1, $custom_tim */ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $htmlmail = $this->get_html_header(); - $htmlmail .= html_writer::start_tag('body', array('id' => 'email')); + $htmlmail .= html_writer::start_tag('body', ['id' => 'email']); $htmlmail .= $this->get_reminder_header(); $htmlmail .= html_writer::start_tag('div'); $htmlmail .= html_writer::start_tag('table', - array('cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle)); + ['cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle]); $contenttitle = $this->get_message_title(); if (!isemptystring($changetype)) { @@ -79,10 +79,10 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $contenttitle = "[$titleprefixlangstr]: $contenttitle"; } $htmlmail .= html_writer::start_tag('tr'); - $htmlmail .= html_writer::start_tag('td', array('colspan' => 2)); + $htmlmail .= html_writer::start_tag('td', ['colspan' => 2]); $htmlmail .= html_writer::link($this->generate_event_link(), - html_writer::tag('h3', $contenttitle, array('style' => $this->titlestyle)), - array('style' => 'text-decoration: none')); + html_writer::tag('h3', $contenttitle, ['style' => $this->titlestyle]), + ['style' => 'text-decoration: none']); $htmlmail .= html_writer::end_tag('td').html_writer::end_tag('tr'); $htmlmail .= $this->write_table_row(get_string('contentwhen', 'local_reminders'), @@ -109,11 +109,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { * @return string Message content as plain-text. */ public function get_message_plaintext($user=null, $changetype=null) { - if ($this->aheaddays != 0) { - $text = $this->get_message_title().' ['.$this->pluralize($this->aheaddays, ' day').' to go]'."\n"; - } else { - $text = $this->get_message_title().' ['.$this->pluralize($this->custom_time->value, ' ' . $this->custom_time->unit).' to go]'."\n"; - } + $text = $this->get_message_title().' '.$this->get_aheaddays_plain()."\n"; $text .= get_string('contentwhen', 'local_reminders').': '.$this->get_tzinfo_plain($user, $this->event)."\n"; $text .= get_string('contenttypecourse', 'local_reminders').': '.$this->coursecategory->name."\n"; $text .= get_string('contentdescription', 'local_reminders').': '.$this->event->description."\n"; diff --git a/contents/course_reminder.class.php b/contents/course_reminder.class.php index afaff74..71c5027 100644 --- a/contents/course_reminder.class.php +++ b/contents/course_reminder.class.php @@ -50,10 +50,10 @@ class course_reminder extends local_reminder { * @param object $event calendar event. * @param object $course course instance. * @param integer $aheaddays number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). */ - public function __construct($event, $course, $aheaddays = 1, $custom_time = null) { - parent::__construct($event, $aheaddays, $custom_time); + public function __construct($event, $course, $aheaddays = 1, $customtime = null) { + parent::__construct($event, $aheaddays, $customtime); $this->course = $course; } @@ -67,11 +67,11 @@ public function __construct($event, $course, $aheaddays = 1, $custom_time = null */ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $htmlmail = $this->get_html_header(); - $htmlmail .= html_writer::start_tag('body', array('id' => 'email')); + $htmlmail .= html_writer::start_tag('body', ['id' => 'email']); $htmlmail .= $this->get_reminder_header(); $htmlmail .= html_writer::start_tag('div'); $htmlmail .= html_writer::start_tag('table', - array('cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle)); + ['cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle]); $contenttitle = $this->get_message_title(); if (!isemptystring($changetype)) { @@ -79,10 +79,10 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $contenttitle = "[$titleprefixlangstr]: $contenttitle"; } $htmlmail .= html_writer::start_tag('tr'); - $htmlmail .= html_writer::start_tag('td', array('colspan' => 2)); + $htmlmail .= html_writer::start_tag('td', ['colspan' => 2]); $htmlmail .= html_writer::link($this->generate_event_link(), - html_writer::tag('h3', $contenttitle, array('style' => $this->titlestyle)), - array('style' => 'text-decoration: none')); + html_writer::tag('h3', $contenttitle, ['style' => $this->titlestyle]), + ['style' => 'text-decoration: none']); $htmlmail .= html_writer::end_tag('td').html_writer::end_tag('tr'); $htmlmail .= $this->write_table_row(get_string('contentwhen', 'local_reminders'), @@ -109,11 +109,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { * @return string Message content as plain-text. */ public function get_message_plaintext($user=null, $changetype=null) { - if ($this->aheaddays != 0) { - $text = $this->get_message_title().' ['.$this->pluralize($this->aheaddays, ' day').' to go]'."\n"; - } else { - $text = $this->get_message_title().' ['.$this->pluralize($this->custom_time->value, ' ' . $this->custom_time->unit).' to go]'."\n"; - } + $text = $this->get_message_title().' '.$this->get_aheaddays_plain()."\n"; $text .= get_string('contentwhen', 'local_reminders').': '.$this->get_tzinfo_plain($user, $this->event)."\n"; $text .= get_string('contenttypecourse', 'local_reminders').': '.$this->course->fullname."\n"; $text .= get_string('contentdescription', 'local_reminders').': '.$this->event->description."\n"; diff --git a/contents/due_reminder.class.php b/contents/due_reminder.class.php index 7f2d62a..4e8ca11 100644 --- a/contents/due_reminder.class.php +++ b/contents/due_reminder.class.php @@ -66,10 +66,10 @@ class due_reminder extends course_reminder { * @param object $cm coursemodulecontext instance. * @param object $coursemodule course module. * @param integer $aheaddays ahead days in number. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). */ - public function __construct($event, $course, $cm, $coursemodule, $aheaddays = 1, $custom_time = null) { - parent::__construct($event, $course, $aheaddays, $custom_time); + public function __construct($event, $course, $cm, $coursemodule, $aheaddays = 1, $customtime = null) { + parent::__construct($event, $course, $aheaddays, $customtime); $this->cm = $cm; $this->coursemodule = $coursemodule; } @@ -140,11 +140,11 @@ public function filter_authorized_users($users, $type=null) { */ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $htmlmail = $this->get_html_header(); - $htmlmail .= html_writer::start_tag('body', array('id' => 'email')); + $htmlmail .= html_writer::start_tag('body', ['id' => 'email']); $htmlmail .= $this->get_reminder_header(); $htmlmail .= html_writer::start_tag('div'); $htmlmail .= html_writer::start_tag('table', - array('cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle)); + ['cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle]); $contenttitle = $this->get_message_title(); if (!isemptystring($changetype)) { @@ -154,17 +154,17 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { } } $htmlmail .= html_writer::start_tag('tr'); - $htmlmail .= html_writer::start_tag('td', array('colspan' => 2)); + $htmlmail .= html_writer::start_tag('td', ['colspan' => 2]); $htmlmail .= html_writer::link($this->generate_event_link(), - html_writer::tag('h3', $contenttitle, array('style' => $this->titlestyle)), - array('style' => 'text-decoration: none')); + html_writer::tag('h3', $contenttitle, ['style' => $this->titlestyle]), + ['style' => 'text-decoration: none']); $htmlmail .= html_writer::end_tag('td').html_writer::end_tag('tr'); if (!isemptystring($changetype) && $changetype == REMINDERS_CALL_TYPE_OVERDUE && !is_null($ctxinfo) && !isemptystring($ctxinfo->overduemessage)) { $htmlmail .= html_writer::start_tag('tr'); - $htmlmail .= html_writer::start_tag('td', array('colspan' => 2)); - $htmlmail .= html_writer::tag('h4', $ctxinfo->overduemessage, array('style' => $this->overduestyle)); + $htmlmail .= html_writer::start_tag('td', ['colspan' => 2]); + $htmlmail .= html_writer::tag('h4', $ctxinfo->overduemessage, ['style' => $this->overduestyle]); $htmlmail .= html_writer::end_tag('td').html_writer::end_tag('tr'); } @@ -174,7 +174,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $htmlmail .= $this->write_table_row(get_string('contenttypecourse', 'local_reminders'), $this->course->fullname); - $activitylink = html_writer::link($this->cm->get_url(), $this->cm->get_context_name(), array('target' => '_blank')); + $activitylink = html_writer::link($this->cm->get_url(), $this->cm->get_context_name(), ['target' => '_blank']); $htmlmail .= $this->write_table_row(get_string('contenttypeactivity', 'local_reminders'), $activitylink); $formattercls = null; @@ -205,11 +205,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { * @return string Message content as plain-text. */ public function get_message_plaintext($user=null, $changetype=null) { - if ($this->aheaddays != 0) { - $text = $this->get_message_title().' ['.$this->pluralize($this->aheaddays, ' day').' to go]'."\n"; - } else { - $text = $this->get_message_title().' ['.$this->pluralize($this->custom_time->value, ' ' . $this->custom_time->unit).' to go]'."\n"; - } + $text = $this->get_message_title().' '.$this->get_aheaddays_plain()."\n"; $text .= get_string('contentwhen', 'local_reminders').': '.$this->get_tzinfo_plain($user, $this->event)."\n"; $text .= get_string('contenttypecourse', 'local_reminders').': '.$this->course->fullname."\n"; $text .= get_string('contenttypeactivity', 'local_reminders').': '.$this->cm->get_context_name()."\n"; diff --git a/contents/group_reminder.class.php b/contents/group_reminder.class.php index d9b2319..fc521d7 100644 --- a/contents/group_reminder.class.php +++ b/contents/group_reminder.class.php @@ -76,10 +76,10 @@ class group_reminder extends local_reminder { * @param object $event calendar event. * @param object $group group instance. * @param integer $aheaddays number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). */ - public function __construct($event, $group, $aheaddays = 1, $custom_time = null) { - parent::__construct($event, $aheaddays, $custom_time); + public function __construct($event, $group, $aheaddays = 1, $customtime = null) { + parent::__construct($event, $aheaddays, $customtime); $this->group = $group; $this->load_course_object(); } @@ -114,7 +114,7 @@ public function set_activity($modulename, $activity) { private function load_course_object() { global $DB; - $this->course = $DB->get_record('course', array('id' => $this->group->courseid)); + $this->course = $DB->get_record('course', ['id' => $this->group->courseid]); if (!empty($this->course) && !empty($this->event->instance)) { $cmx = get_coursemodule_from_instance($this->event->modulename, $this->event->instance, $this->group->courseid); if (!empty($cmx)) { @@ -135,11 +135,11 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { global $CFG; $htmlmail = $this->get_html_header(); - $htmlmail .= html_writer::start_tag('body', array('id' => 'email')); + $htmlmail .= html_writer::start_tag('body', ['id' => 'email']); $htmlmail .= $this->get_reminder_header(); $htmlmail .= html_writer::start_tag('div'); $htmlmail .= html_writer::start_tag('table', - array('cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle)); + ['cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle]); $contenttitle = $this->get_message_title(); if (!isemptystring($changetype)) { @@ -147,10 +147,10 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $contenttitle = "[$titleprefixlangstr]: $contenttitle"; } $htmlmail .= html_writer::start_tag('tr'); - $htmlmail .= html_writer::start_tag('td', array('colspan' => 2)); + $htmlmail .= html_writer::start_tag('td', ['colspan' => 2]); $htmlmail .= html_writer::link($this->generate_event_link(), - html_writer::tag('h3', $contenttitle, array('style' => $this->titlestyle)), - array('style' => 'text-decoration: none')); + html_writer::tag('h3', $contenttitle, ['style' => $this->titlestyle]), + ['style' => 'text-decoration: none']); $htmlmail .= html_writer::end_tag('td').html_writer::end_tag('tr'); $htmlmail .= $this->write_table_row(get_string('contentwhen', 'local_reminders'), @@ -164,7 +164,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { if (!empty($this->cm)) { $cmlink = html_writer::link($this->cm->get_url(), $this->cm->get_context_name()); $htmlmail .= $this->write_table_row(get_string('contenttypeactivity', 'local_reminders'), - $cmlink, array('target' => '_blank'), false); + $cmlink, ['target' => '_blank'], false); } if (isset($CFG->local_reminders_groupshowname) && $CFG->local_reminders_groupshowname) { @@ -199,11 +199,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { * @return string Message content as plain-text. */ public function get_message_plaintext($user=null, $changetype=null) { - if ($this->aheaddays != 0) { - $text = $this->get_message_title().' ['.$this->pluralize($this->aheaddays, ' day').' to go]'."\n"; - } else { - $text = $this->get_message_title().' ['.$this->pluralize($this->custom_time->value, ' ' . $this->custom_time->unit).' to go]'."\n"; - } + $text = $this->get_message_title().' '.$this->get_aheaddays_plain()."\n"; $text .= get_string('contentwhen', 'local_reminders').': '.$this->get_tzinfo_plain($user, $this->event)."\n"; if (!empty($this->course)) { $text .= get_string('contenttypecourse', 'local_reminders').': '.$this->course->fullname."\n"; diff --git a/contents/site_reminder.class.php b/contents/site_reminder.class.php index 27bc1a7..9be2115 100644 --- a/contents/site_reminder.class.php +++ b/contents/site_reminder.class.php @@ -47,11 +47,11 @@ class site_reminder extends local_reminder { */ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $htmlmail = $this->get_html_header(); - $htmlmail .= html_writer::start_tag('body', array('id' => 'email')); + $htmlmail .= html_writer::start_tag('body', ['id' => 'email']); $htmlmail .= $this->get_reminder_header(); $htmlmail .= html_writer::start_tag('div'); $htmlmail .= html_writer::start_tag('table', - array('cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle)); + ['cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle]); $contenttitle = $this->get_message_title(); if (!isemptystring($changetype)) { @@ -59,10 +59,10 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $contenttitle = "[$titleprefixlangstr]: $contenttitle"; } $htmlmail .= html_writer::start_tag('tr'); - $htmlmail .= html_writer::start_tag('td', array('colspan' => 2)); + $htmlmail .= html_writer::start_tag('td', ['colspan' => 2]); $htmlmail .= html_writer::link($this->generate_event_link(), - html_writer::tag('h3', $contenttitle, array('style' => $this->titlestyle)), - array('style' => 'text-decoration: none')); + html_writer::tag('h3', $contenttitle, ['style' => $this->titlestyle]), + ['style' => 'text-decoration: none']); $htmlmail .= html_writer::end_tag('td').html_writer::end_tag('tr'); $htmlmail .= $this->write_table_row(get_string('contentwhen', 'local_reminders'), @@ -87,11 +87,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { * @return string Message content as plain-text. */ public function get_message_plaintext($user=null, $changetype=null) { - if ($this->aheaddays != 0) { - $text = $this->get_message_title().' ['.$this->pluralize($this->aheaddays, ' day').' to go]'."\n"; - } else { - $text = $this->get_message_title().' ['.$this->pluralize($this->custom_time->value, ' ' .$this->custom_time->unit).' to go]'."\n"; - } + $text = $this->get_message_title().' '.$this->get_aheaddays_plain()."\n"; $text .= get_string('contentwhen', 'local_reminders').': '.$this->get_tzinfo_plain($user, $this->event)."\n"; $text .= get_string('contentdescription', 'local_reminders').': '.$this->event->description."\n"; diff --git a/contents/user_reminder.class.php b/contents/user_reminder.class.php index 1877913..8f4a817 100644 --- a/contents/user_reminder.class.php +++ b/contents/user_reminder.class.php @@ -50,10 +50,10 @@ class user_reminder extends local_reminder { * @param object $event calendar event. * @param object $user user instance. * @param integer $aheaddays number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). */ - public function __construct($event, $user, $aheaddays = 1, $custom_time = null) { - parent::__construct($event, $aheaddays, $custom_time); + public function __construct($event, $user, $aheaddays = 1, $customtime = null) { + parent::__construct($event, $aheaddays, $customtime); $this->user = $user; } @@ -78,11 +78,11 @@ public function cleanup() { */ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $htmlmail = $this->get_html_header(); - $htmlmail .= html_writer::start_tag('body', array('id' => 'email')); + $htmlmail .= html_writer::start_tag('body', ['id' => 'email']); $htmlmail .= $this->get_reminder_header(); $htmlmail .= html_writer::start_tag('div'); $htmlmail .= html_writer::start_tag('table', - array('cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle)); + ['cellspacing' => 0, 'cellpadding' => 8, 'style' => $this->tbodycssstyle]); $contenttitle = $this->get_message_title(); if (!isemptystring($changetype)) { @@ -90,10 +90,10 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { $contenttitle = "[$titleprefixlangstr]: $contenttitle"; } $htmlmail .= html_writer::start_tag('tr'); - $htmlmail .= html_writer::start_tag('td', array('colspan' => 2)); + $htmlmail .= html_writer::start_tag('td', ['colspan' => 2]); $htmlmail .= html_writer::link($this->generate_event_link(), - html_writer::tag('h3', $contenttitle, array('style' => $this->titlestyle)), - array('style' => 'text-decoration: none')); + html_writer::tag('h3', $contenttitle, ['style' => $this->titlestyle]), + ['style' => 'text-decoration: none']); $htmlmail .= html_writer::end_tag('td').html_writer::end_tag('tr'); $htmlmail .= $this->write_table_row(get_string('contentwhen', 'local_reminders'), @@ -120,11 +120,7 @@ public function get_message_html($user=null, $changetype=null, $ctxinfo=null) { * @return string Message content as plain-text. */ public function get_message_plaintext($user=null, $changetype=null) { - if ($this->aheaddays != 0) { - $text = $this->get_message_title().' ['.$this->pluralize($this->aheaddays, ' day').' to go]'."\n"; - } else { - $text = $this->get_message_title().' ['.$this->pluralize($this->custom_time->value, ' ' . $this->custom_time->unit).' to go]'."\n"; - } + $text = $this->get_message_title().' '.$this->get_aheaddays_plain()."\n"; $text .= get_string('contentwhen', 'local_reminders').': '.$this->get_tzinfo_plain($user, $this->event)."\n"; $text .= get_string('contenttypeuser', 'local_reminders').': '.fullname($this->user)."\n"; $text .= get_string('contentdescription', 'local_reminders').': '.$this->event->description."\n"; diff --git a/coursesettings.php b/coursesettings.php index 5d25d26..07de1d4 100644 --- a/coursesettings.php +++ b/coursesettings.php @@ -34,10 +34,10 @@ $courseid = required_param('courseid', PARAM_INT); -$return = new moodle_url('/course/view.php', array('id' => $courseid)); +$return = new moodle_url('/course/view.php', ['id' => $courseid]); -$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); -$coursesettings = $DB->get_record('local_reminders_course', array('courseid' => $courseid)); +$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST); +$coursesettings = $DB->get_record('local_reminders_course', ['courseid' => $courseid]); if (!$coursesettings) { $coursesettings = new stdClass(); } @@ -45,9 +45,9 @@ $coursesettings->explicitenable = isset($CFG->local_reminders_explicitenable) && $CFG->local_reminders_explicitenable; $coursecontext = context_course::instance($course->id); -$activitysettings = $DB->get_records('local_reminders_activityconf', array('courseid' => $courseid)); +$activitysettings = $DB->get_records('local_reminders_activityconf', ['courseid' => $courseid]); if (!$activitysettings) { - $activitysettings = array(); + $activitysettings = []; } else { foreach ($activitysettings as $asetting) { $actkey = 'activity_'.$asetting->eventid.'_'.$asetting->settingkey; @@ -57,25 +57,31 @@ $globalactivityaheaddays = $CFG->local_reminders_duerdays; if (!isset($globalactivityaheaddays)) { - $globalactivityaheaddays = array(0, 0, 0); + $globalactivityaheaddays = [0, 0, 0]; } -$aheaddaysindex = array(7 => 0, 3 => 1, 1 => 2); +$aheaddaysindex = [7 => 0, 3 => 1, 1 => 2]; foreach ($aheaddaysindex as $dkey => $dvalue) { $daykey = 'activityglobal_days'.$dkey; $coursesettings->$daykey = $globalactivityaheaddays[$dvalue]; } -$globalactivity_custom = $CFG->local_reminders_duecustom; +$globalactivitycustom = $CFG->local_reminders_duecustom; $customkey = 'activityglobal_custom'; -if ($globalactivity_custom && intval($globalactivity_custom) > 0) { - $custom_value = intval($globalactivity_custom); +if ($globalactivitycustom && intval($globalactivitycustom) > 0) { + $customvalue = intval($globalactivitycustom); $coursesettings->$customkey = 1; - $custom_time_units = ['weeks' => CUSTOM_WEEK_SECS, 'days' => CUSTOM_DAY_SECS, 'hours' => CUSTOM_HOUR_SECS, 'minutes' => CUSTOM_MINUTE_SECS, 'seconds' => 1]; - foreach($custom_time_units as $unit_key => $unit_value) { - $remainder = $custom_value % $unit_value; + $customtimeunits = [ + 'weeks' => CUSTOM_WEEK_SECS, + 'days' => CUSTOM_DAY_SECS, + 'hours' => CUSTOM_HOUR_SECS, + 'minutes' => CUSTOM_MINUTE_SECS, + 'seconds' => 1, + ]; + foreach ($customtimeunits as $unitkey => $unitvalue) { + $remainder = $customvalue % $unitvalue; if ($remainder == 0) { - $value = intdiv($globalactivity_custom, $unit_value); - $coursesettings->customunit = $value . ' ' . $unit_key; + $value = intdiv($globalactivitycustom, $unitvalue); + $coursesettings->customunit = $value . ' ' . $unitkey; break; } } @@ -88,11 +94,11 @@ require_capability('moodle/course:update', $coursecontext); $PAGE->set_pagelayout('admin'); -$PAGE->set_url('/local/reminders/coursesettings.php', array('courseid' => $courseid)); +$PAGE->set_url('/local/reminders/coursesettings.php', ['courseid' => $courseid]); $PAGE->set_title(get_string('admintreelabel', 'local_reminders')); $PAGE->set_heading($course->fullname); -$mform = new local_reminders_coursesettings_edit_form(null, array($coursesettings)); +$mform = new local_reminders_coursesettings_edit_form(null, [$coursesettings]); if ($mform->is_cancelled()) { redirect($return); @@ -115,7 +121,7 @@ $status = $DB->get_record_sql("SELECT id FROM {local_reminders_activityconf} WHERE courseid = :courseid AND eventid = :eventid AND settingkey = :settingkey", - array('courseid' => $data->courseid, 'eventid' => $eventid, 'settingkey' => $keyparts[2])); + ['courseid' => $data->courseid, 'eventid' => $eventid, 'settingkey' => $keyparts[2]]); $actdata = new stdClass(); $actdata->courseid = $data->courseid; diff --git a/coursesettings_form.php b/coursesettings_form.php index 42674e4..2183af7 100644 --- a/coursesettings_form.php +++ b/coursesettings_form.php @@ -44,11 +44,12 @@ class local_reminders_coursesettings_edit_form extends moodleform { public function definition() { global $USER; - $daysarray = array('days7' => ' '.get_string('days7', 'local_reminders'), + $daysarray = [ + 'days7' => ' '.get_string('days7', 'local_reminders'), 'days3' => ' '.get_string('days3', 'local_reminders'), 'days1' => ' '.get_string('days1', 'local_reminders'), - 'custom' => ' '.get_string('custom', 'local_reminders') - ); + 'custom' => ' '.get_string('custom', 'local_reminders'), + ]; $mform = $this->_form; list($coursesettings) = $this->_customdata; @@ -90,17 +91,17 @@ public function definition() { $noactivities = true; $mform->addElement('header', 'description', get_string('activityconfupcomingactivities', 'local_reminders')); - $custom_unit_label = empty($coursesettings->customunit) ? '' : '(' . $coursesettings->customunit . ')'; + $customunitlabel = empty($coursesettings->customunit) ? '' : '(' . $coursesettings->customunit . ')'; if (!empty($upcomingactivities)) { // Group activities by start time. - $allactivities = array(); + $allactivities = []; foreach ($upcomingactivities as $activity) { $starttime = $activity->timestart - ($activity->timestart % (24 * 3600)); if (array_key_exists($starttime, $allactivities)) { $allactivities[$starttime][] = $activity; } else { - $allactivities[$starttime] = array($activity); + $allactivities[$starttime] = [$activity]; } } ksort($allactivities); @@ -144,11 +145,12 @@ public function definition() { $mform->addElement('advcheckbox', $key, get_string('enabled', 'local_reminders'), ' '); $mform->setDefault($key, $explicitlyenable ? 0 : 1); - $activitydayarray = array(); + $activitydayarray = []; foreach ($daysarray as $dkey => $dvalue) { $trefkey = "activityglobal_$dkey"; $daykey = "activity_".$activity->id."_$dkey"; - $activitydayarray[] = $mform->createElement('advcheckbox', $daykey, '', $dkey != 'custom' ? $dvalue : $dvalue . ' ' .$custom_unit_label); + $activitydayarray[] = $mform->createElement('advcheckbox', $daykey, '', + $dkey != 'custom' ? $dvalue : $dvalue . ' ' .$customunitlabel); if (!$explicitlyenable) { $mform->disabledIf($daykey, $trefkey, 'eq', 0); } @@ -208,7 +210,7 @@ private function load_string_safe($key, $defaultvalue='') { * @return string complete url for the event */ private function generate_event_link($event) { - $params = array('view' => 'day', 'time' => $event->timestart); + $params = ['view' => 'day', 'time' => $event->timestart]; $calurl = new moodle_url('/calendar/view.php', $params); $calurl->set_anchor('event_'.$event->id); diff --git a/db/access.php b/db/access.php index 6ac04ad..b57e0f0 100644 --- a/db/access.php +++ b/db/access.php @@ -24,4 +24,4 @@ defined('MOODLE_INTERNAL') || die(); -$capabilities = array (); +$capabilities = []; diff --git a/db/events.php b/db/events.php index 101e52c..2a80298 100644 --- a/db/events.php +++ b/db/events.php @@ -23,18 +23,17 @@ */ defined('MOODLE_INTERNAL') || die(); -$observers = array( - - array( +$observers = [ + [ 'eventname' => '\core\event\calendar_event_updated', 'callback' => '\local_reminders\calendar_observer::calendar_event_updated', - ), - array( + ], + [ 'eventname' => '\core\event\calendar_event_created', 'callback' => '\local_reminders\calendar_observer::calendar_event_added', - ), - array( + ], + [ 'eventname' => '\core\event\calendar_event_deleted', 'callback' => '\local_reminders\calendar_observer::calendar_event_removed', - ), -); + ], +]; diff --git a/db/install.php b/db/install.php index d487ab7..f05b0e6 100644 --- a/db/install.php +++ b/db/install.php @@ -22,7 +22,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); /** * Post-install code for the reminders plugin. diff --git a/db/messages.php b/db/messages.php index f6dbe1b..a61c594 100644 --- a/db/messages.php +++ b/db/messages.php @@ -24,30 +24,24 @@ defined('MOODLE_INTERNAL') || die(); -$messageproviders = array ( +$messageproviders = [ // Reminders for site events. - 'reminders_site' => array ( - ), + 'reminders_site' => [], // Reminders for user events. - 'reminders_user' => array ( - ), + 'reminders_user' => [] // Reminders for course events. - 'reminders_course' => array ( - ), + 'reminders_course' => [], // Reminders for course events. - 'reminders_coursecategory' => array ( - ), + 'reminders_coursecategory' => [], // Reminders for group events. - 'reminders_group' => array ( - ), + 'reminders_group' => [], // Reminders for due events. - 'reminders_due' => array ( - ), + 'reminders_due' => [], -); +]; diff --git a/db/upgrade.php b/db/upgrade.php index 91dc803..e2ca421 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -21,7 +21,7 @@ * @copyright 2012 Isuru Madushanka Weerarathna * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); + /** * Run the upgrade for the plugin. @@ -67,8 +67,8 @@ function xmldb_local_reminders_upgrade($oldversion) { $table->add_field('status_group', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, '1'); // Adding keys to table local_reminders_course. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); - $table->add_key('relatedcourse', XMLDB_KEY_FOREIGN_UNIQUE, array('courseid'), 'course', array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); + $table->add_key('relatedcourse', XMLDB_KEY_FOREIGN_UNIQUE, ['courseid'], 'course', ['id']); // Conditionally launch create table for local_reminders_course. if (!$dbman->table_exists($table)) { @@ -120,10 +120,10 @@ function create_local_reminders_activity_config_table($dbman) { $table->add_field('settingvalue', XMLDB_TYPE_TEXT, null, null, null, null, null); // Adding keys to table local_reminders_post_activity. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Adding indexes for faster access. - $table->add_index('localremindercourses', XMLDB_INDEX_NOTUNIQUE, array('courseid')); + $table->add_index('localremindercourses', XMLDB_INDEX_NOTUNIQUE, ['courseid']); // Conditionally launch create table for local_reminders_post_activity. if (!$dbman->table_exists($table)) { @@ -146,7 +146,7 @@ function create_local_reminders_post_activity_table($dbman) { $table->add_field('eventid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); // Adding keys to table local_reminders_post_activity. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Conditionally launch create table for local_reminders_post_activity. if (!$dbman->table_exists($table)) { diff --git a/lib.php b/lib.php index 26f5760..be7a643 100644 --- a/lib.php +++ b/lib.php @@ -76,8 +76,8 @@ define('REMINDERS_CLEAN_TABLE', 'local_reminders'); define('REMINDERS_ENABLED_KEY', 'enabled'); -define('REMINDERS_SUPPORTED_OVERRIDES', array('assign', 'quiz')); -define('REMINDERS_SUPPORTED_OVERRIDES_REF_IDS', array('assign' => 'assignid', 'quiz' => 'quiz')); +define('REMINDERS_SUPPORTED_OVERRIDES', ['assign', 'quiz']); +define('REMINDERS_SUPPORTED_OVERRIDES_REF_IDS', ['assign' => 'assignid', 'quiz' => 'quiz']); define('CUSTOM_MINUTE_SECS', 60); define('CUSTOM_HOUR_SECS', CUSTOM_MINUTE_SECS * 60); @@ -120,8 +120,8 @@ function local_reminders_cron_task() { function local_reminders_cron_pre($currtime, $timewindowstart) { global $CFG, $DB; - $aheaddaysindex = array(7 => 0, 3 => 1, 1 => 2); - $eventtypearray = array('site', 'user', 'course', 'due', 'group', 'zoom'); + $aheaddaysindex = [7 => 0, 3 => 1, 1 => 2]; + $eventtypearray = ['site', 'user', 'course', 'due', 'group', 'zoom']; // Loading roles allowed to receive reminder messages from configuration. $tmprolesreminders = get_roles_for_reminders(); @@ -133,10 +133,11 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { $timewindowend = $currtime; // Now lets filter appropiate events to send reminders. - $secondsaheads = array(REMINDERS_7DAYSBEFORE_INSECONDS, + $secondsaheads = [ + REMINDERS_7DAYSBEFORE_INSECONDS, REMINDERS_3DAYSBEFORE_INSECONDS, REMINDERS_1DAYBEFORE_INSECONDS, - ); + ]; // Append custom schedule if any of event categories has defined it. foreach ($eventtypearray as $etype) { @@ -178,7 +179,7 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { mtrace(" [Local Reminder] Found ".count($upcomingevents)." upcoming events. Continuing..."); $fromuser = get_from_user(); - $excludedmodules = array(); + $excludedmodules = []; if (isset($CFG->local_reminders_excludedmodulenames)) { $excludedmodules = explode(',', $CFG->local_reminders_excludedmodulenames); } @@ -189,7 +190,13 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { $allemailfailed = true; $triedcount = 0; - $custom_time_units = ['weeks' => CUSTOM_WEEK_SECS, 'days' => CUSTOM_DAY_SECS, 'hours' => CUSTOM_HOUR_SECS, 'minutes' => CUSTOM_MINUTE_SECS, 'seconds' => 1]; + $customtimeunits = [ + 'weeks' => CUSTOM_WEEK_SECS, + 'days' => CUSTOM_DAY_SECS, + 'hours' => CUSTOM_HOUR_SECS, + 'minutes' => CUSTOM_MINUTE_SECS, + 'seconds' => 1, + ]; foreach ($upcomingevents as $event) { if (in_array($event->modulename, $excludedmodules)) { @@ -205,7 +212,7 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { $diffinseconds = $event->timestart - $timewindowend; $fromcustom = false; - $custom_time = null; + $customtime = null; if ($event->timestart - REMINDERS_1DAYBEFORE_INSECONDS >= $timewindowstart && $event->timestart - REMINDERS_1DAYBEFORE_INSECONDS <= $timewindowend) { @@ -226,17 +233,18 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { $customsecs = $CFG->$tempconfigstr; if ($event->timestart - $customsecs >= $timewindowstart && $event->timestart - $customsecs <= $timewindowend) { - foreach($custom_time_units as $unit_key => $unit_value) { - $remainder = $customsecs % $unit_value; - if ($remainder == 0) { - $value = intdiv($customsecs, $unit_value); - $custom_time = new stdClass(); - $custom_time->unit = $unit_key; - $custom_time->value = $value; - break; - } + + foreach ($customtimeunits as $unitkey => $unitvalue) { + $remainder = $customsecs % $unitvalue; + if ($remainder == 0) { + $value = intdiv($customsecs, $unitvalue); + $customtime = new stdClass(); + $customtime->unit = $unitkey; + $customtime->value = $value; + break; } - $fromcustom = true; + } + $fromcustom = true; } } } @@ -244,15 +252,16 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { if (!$fromcustom) { mtrace(" [Local Reminder] Processing event in ahead of $aheadday days."); } else { - mtrace(" [Local Reminder] Processing event in ahead of $custom_time->value $custom_time->unit."); + mtrace(" [Local Reminder] Processing event in ahead of $customtime->value $customtime->unit."); } if ($diffinseconds < 0) { mtrace(' [Local Reminder] Skipping event because it might have expired.'); continue; } mtrace(" [Local Reminder] Processing event#$event->id [Type: $event->eventtype, inaheadof=$aheadday days]..."); - if ($custom_time) { - mtrace(" [Local Reminder] Processing event#$event->id [Custom Schedule Configured: $custom_time->value $custom_time->unit]..."); + if ($customtime) { + mtrace(" [Local Reminder] Processing event#$event->id ". + "[Custom Schedule Configured: $customtime->value $customtime->unit]..."); } if (!$fromcustom) { $optionstr = 'local_reminders_' . $event->eventtype . 'rdays'; @@ -292,19 +301,19 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { try { switch ($event->eventtype) { case 'site': - $reminderref = process_site_event($event, $aheadday, $custom_time); + $reminderref = process_site_event($event, $aheadday, $customtime); break; case 'user': - $reminderref = process_user_event($event, $aheadday, $custom_time); + $reminderref = process_user_event($event, $aheadday, $customtime); break; case 'category': - $reminderref = process_category_event($event, $aheadday, $custom_time, $categoryroleids); + $reminderref = process_category_event($event, $aheadday, $customtime, $categoryroleids); break; case 'course': - $reminderref = process_course_event($event, $aheadday, $custom_time, $courseroleids); + $reminderref = process_course_event($event, $aheadday, $customtime, $courseroleids); break; case 'open': @@ -328,18 +337,20 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { mtrace(" [Local Reminder] Activity event $event->id reminders disabled for $aheadday days ahead."); break; } else if ($fromcustom && has_disabled_reminders_for_activity($event->courseid, $event->id, "custom")) { - mtrace(" [Local Reminder] Activity event $event->id reminders disabled for custom time ($custom_time->value $custom_time->unit) ahead."); - break; + mtrace(" [Local Reminder] Activity event $event->id reminders disabled ". + "for custom time ($customtime->value $customtime->unit) ahead."); + break; } - $reminderref = process_activity_event($event, $aheadday, $custom_time, $activityroleids, REMINDERS_CALL_TYPE_PRE); + $reminderref = process_activity_event($event, $aheadday, $customtime, $activityroleids, + REMINDERS_CALL_TYPE_PRE); break; case 'group': - $reminderref = process_group_event($event, $aheadday, $custom_time); + $reminderref = process_group_event($event, $aheadday, $customtime); break; default: - $reminderref = process_unknown_event($event, $aheadday, $custom_time, $activityroleids, REMINDERS_CALL_TYPE_PRE); + $reminderref = process_unknown_event($event, $aheadday, $customtime, $activityroleids, REMINDERS_CALL_TYPE_PRE); } } catch (Exception $ex) { @@ -366,7 +377,7 @@ function local_reminders_cron_pre($currtime, $timewindowstart) { $triedcount++; $sendusers = $reminderref->get_sending_users(); - $alreadysentuserids = array(); + $alreadysentuserids = []; foreach ($sendusers as $touser) { @@ -456,7 +467,7 @@ function add_flag_record_db($timewindowend, $crontype = '') { function get_timewindow_starttime($currtime) { global $DB; - $logrows = $DB->get_records("local_reminders", array(), 'time DESC', '*', 0, 1); + $logrows = $DB->get_records("local_reminders", [], 'time DESC', '*', 0, 1); $timewindowstart = $currtime; if (!$logrows) { // This is the first cron cycle, after plugin is just installed. @@ -524,7 +535,7 @@ function when_calendar_event_updated($updateevent, $changetype) { } $aheadday = floor($diffsecondsuntil / (REMINDERS_DAYIN_SECONDS * 1.0)); - $excludedmodules = array(); + $excludedmodules = []; if (isset($CFG->local_reminders_excludedmodulenames)) { $excludedmodules = explode(',', $CFG->local_reminders_excludedmodulenames); } @@ -641,7 +652,7 @@ function local_reminders_extend_settings_navigation($settingsnav, $context) { if ($settingnode = $settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) { $name = get_string('admintreelabel', 'local_reminders'); - $url = new moodle_url('/local/reminders/coursesettings.php', array('courseid' => $PAGE->course->id)); + $url = new moodle_url('/local/reminders/coursesettings.php', ['courseid' => $PAGE->course->id]); $navnode = navigation_node::create( $name, $url, diff --git a/locallib.php b/locallib.php index 7a4c0a9..a355ade 100644 --- a/locallib.php +++ b/locallib.php @@ -44,7 +44,7 @@ function get_upcoming_events_for_course($courseid, $currtime) { global $DB, $CFG; - // we default exclude these kind of event types + // We default exclude these kind of event types. $excludedstatuses = ['site', 'user', 'open']; // When activity openings separation is enabled in global settings, we will retrieve those events too. @@ -79,8 +79,8 @@ function fetch_course_activity_settings($courseid, $eventid) { $records = $DB->get_records_sql("SELECT settingkey, settingvalue FROM {local_reminders_activityconf} WHERE courseid = :courseid AND eventid = :eventid", - array('courseid' => $courseid, 'eventid' => $eventid)); - $pairs = array(); + ['courseid' => $courseid, 'eventid' => $eventid]); + $pairs = []; if (!empty($records)) { foreach ($records as $record) { $pairs[$record->settingkey] = $record->settingvalue; @@ -112,10 +112,10 @@ function has_disabled_reminders_for_activity($courseid, $eventid, $keytocheck=RE * @param object $event event instance reference. * @param object $options context options. * @param number $aheadday number of days ahead this activity belongs to. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @return bool true if reminders can sent, otherwise false. */ -function should_run_for_activity($event, $options, $aheadday=null, $custom_time=null) { +function should_run_for_activity($event, $options, $aheadday=null, $customtime=null) { global $DB, $CFG; $showtrace = $options->showtrace; @@ -134,10 +134,10 @@ function should_run_for_activity($event, $options, $aheadday=null, $custom_time= $showtrace && mtrace(" [Local Reminder] Reminders for activity event#$eventid (title=$event->name) ". "have been disabled for $aheadday days ahead."); return false; - } else if ($custom_time && array_key_exists("custom", $activitysettings) && !$activitysettings["custom"]) { + } else if ($customtime && array_key_exists("custom", $activitysettings) && !$activitysettings["custom"]) { $showtrace && mtrace(" [Local Reminder] Reminders for activity event#$eventid (title=$event->name) ". - "have been disabled for custom time ($custom_time->value $custom_time->unit) ahead."); - return false; + "have been disabled for custom time ($customtime->value $customtime->unit) ahead."); + return false; } if ($explicitenable) { @@ -149,7 +149,7 @@ function should_run_for_activity($event, $options, $aheadday=null, $custom_time= return true; } - // Handle custom setting + // Handle custom setting. if (array_key_exists(REMINDERS_ENABLED_KEY, $activitysettings) && $activitysettings[REMINDERS_ENABLED_KEY] && array_key_exists("custom", $activitysettings) @@ -204,7 +204,7 @@ function send_overdue_activity_reminders($curtime, $timewindowstart, $activityro return; } - $excludedmodules = array(); + $excludedmodules = []; if (isset($CFG->local_reminders_excludedmodulenames)) { $excludedmodules = explode(',', $CFG->local_reminders_excludedmodulenames); } @@ -236,7 +236,7 @@ function send_overdue_activity_reminders($curtime, $timewindowstart, $activityro $ctxinfo = new \stdClass; $ctxinfo->overduemessage = $CFG->local_reminders_overduewarnmessage ?? ''; $ctxinfo->overduetitle = $CFG->local_reminders_overduewarnprefix ?? ''; - $alreadysentuserids = array(); + $alreadysentuserids = []; foreach ($sendusers as $touser) { try { @@ -292,10 +292,10 @@ function handle_course_activity_event($event, $course, $cm, $options) { $showtrace = $options->showtrace; $aheadday = $options->aheadday; - $custom_time = $options->custom_time; + $customtime = $options->customtime; if ($event->courseid > 0) { - $coursesettings = $DB->get_record('local_reminders_course', array('courseid' => $event->courseid)); + $coursesettings = $DB->get_record('local_reminders_course', ['courseid' => $event->courseid]); if (isset($coursesettings->status_activities) && $coursesettings->status_activities == 0) { $showtrace && mtrace(" [Local Reminder] Reminders for activities has been restricted in the configs."); return null; @@ -305,25 +305,25 @@ function handle_course_activity_event($event, $course, $cm, $options) { if (is_course_hidden_and_denied($course)) { $showtrace && mtrace(" [Local Reminder] Course is hidden. No reminders will be sent."); return null; - } else if (!should_run_for_activity($event, $options, $aheadday, $custom_time)) { + } else if (!should_run_for_activity($event, $options, $aheadday, $customtime)) { return null; } $activityobj = fetch_module_instance($event->modulename, $event->instance, $event->courseid, $showtrace); $context = context_module::instance($cm->id); - $sendusers = array(); - $reminder = new due_reminder($event, $course, $context, $cm, $aheadday, $custom_time); + $sendusers = []; + $reminder = new due_reminder($event, $course, $context, $cm, $aheadday, $customtime); mtrace(" [Local Reminder] Finding out users for event#".$event->id."..."); if ($event->courseid <= 0 && $event->userid > 0) { // A user overridden activity. $showtrace && mtrace(" [Local Reminder] Event #".$event->id." is a user overridden ".$event->modulename." event."); - $user = $DB->get_record('user', array('id' => $event->userid)); + $user = $DB->get_record('user', ['id' => $event->userid]); $sendusers[] = $user; } else if ($event->groupid > 0) { // A group overridden activity. $showtrace && mtrace(" [Local Reminder] Event #".$event->id." is a group overridden ".$event->modulename." event."); - $group = $DB->get_record('groups', array('id' => $event->groupid)); + $group = $DB->get_record('groups', ['id' => $event->groupid]); $sendusers = get_users_in_group($group); } else { // Here 'ra.id field added to avoid printing debug message, @@ -331,14 +331,14 @@ function handle_course_activity_event($event, $course, $cm, $options) { $sendusers = get_active_role_users($options->activityroleids, $context); $sendusers = filter_user_group_overrides($event, $sendusers, $showtrace); - // In the filter_user_list below the user id required and NOT the role_assignments id which is returned from get_active_role_users - // Need to switch to the user id below before filtering + // The user id is required but NOT the role_assignment id for filter_user_list which is returned from get_active_role_users. + // Need to switch to the user id below before filtering. if ($sendusers) { - $user_array = []; - foreach($sendusers as $role_assignment_user) { - $user_array += [$role_assignment_user->id => \core_user::get_user($role_assignment_user->id)]; + $userarray = []; + foreach ($sendusers as $roleassignmentuser) { + $userarray += [$roleassignmentuser->id => \core_user::get_user($roleassignmentuser->id)]; } - $sendusers = $user_array; + $sendusers = $userarray; } // Filter user list, @@ -349,7 +349,7 @@ function handle_course_activity_event($event, $course, $cm, $options) { // This is not pretty. But we can do better. if (strcmp($event->eventtype, 'gradingdue') == 0 && isset($context)) { - $filteredusers = array(); + $filteredusers = []; foreach ($sendusers as $guser) { if (has_capability('mod/assign:grade', $context, $guser)) { $filteredusers[] = $guser; @@ -368,13 +368,15 @@ function handle_course_activity_event($event, $course, $cm, $options) { * * @param object $event calendar event. * @param int $aheadday number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @param array $activityroleids role ids for activities. * @param boolean $showtrace whether to print logs or not. * @param string $calltype calling type PRE|OVERDUE. * @return reminder_ref reminder reference instance. */ -function process_activity_event($event, $aheadday, $custom_time=null, $activityroleids=null, $showtrace=true, $calltype=REMINDERS_CALL_TYPE_PRE) { +function process_activity_event($event, $aheadday, $customtime=null, $activityroleids=null, $showtrace=true, + $calltype=REMINDERS_CALL_TYPE_PRE) { + if (isemptystring($event->modulename)) { return null; } @@ -392,7 +394,7 @@ function process_activity_event($event, $aheadday, $custom_time=null, $activityr if (!empty($course) && !empty($cm)) { $options = new \stdClass; $options->aheadday = $aheadday; - $options->custom_time = $custom_time; + $options->customtime = $customtime; $options->showtrace = $showtrace; $options->activityroleids = $activityroleids; $options->calltype = $calltype; @@ -408,19 +410,21 @@ function process_activity_event($event, $aheadday, $custom_time=null, $activityr * * @param object $event calendar event. * @param int $aheadday number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @param array $activityroleids role ids for activities. * @param boolean $showtrace whether to print logs or not. * @param string $calltype calling type PRE|OVERDUE. * @return reminder_ref reminder reference instance. */ -function process_unknown_event($event, $aheadday, $custom_time=null, $activityroleids=null, $showtrace=true, $calltype=REMINDERS_CALL_TYPE_PRE) { +function process_unknown_event($event, $aheadday, $customtime=null, $activityroleids=null, $showtrace=true, + $calltype=REMINDERS_CALL_TYPE_PRE) { + if (isemptystring($event->modulename)) { $showtrace && mtrace(" [Local Reminder] Unknown event type [$event->eventtype]!"); return null; } - return process_activity_event($event, $aheadday, $custom_time, $activityroleids, $showtrace, $calltype); + return process_activity_event($event, $aheadday, $customtime, $activityroleids, $showtrace, $calltype); } /** @@ -428,15 +432,15 @@ function process_unknown_event($event, $aheadday, $custom_time=null, $activityro * * @param object $event calendar event. * @param int $aheadday number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @param array $courseroleids role ids for course. * @param boolean $showtrace whether to print logs or not. * @return reminder_ref reminder reference instance. */ -function process_course_event($event, $aheadday, $custom_time=null, $courseroleids=null, $showtrace=true) { +function process_course_event($event, $aheadday, $customtime=null, $courseroleids=null, $showtrace=true) { global $DB, $PAGE; - $course = $DB->get_record('course', array('id' => $event->courseid)); + $course = $DB->get_record('course', ['id' => $event->courseid]); if (is_course_hidden_and_denied($course)) { $showtrace && mtrace(" [Local Reminder] Course is hidden. No reminders will be sent."); return null; @@ -445,17 +449,17 @@ function process_course_event($event, $aheadday, $custom_time=null, $courserolei return null; } - $coursesettings = $DB->get_record('local_reminders_course', array('courseid' => $event->courseid)); + $coursesettings = $DB->get_record('local_reminders_course', ['courseid' => $event->courseid]); if (isset($coursesettings->status_course) && $coursesettings->status_course == 0) { $showtrace && mtrace(" [Local Reminder] Reminders for course events has been restricted."); return null; } if (!empty($course)) { - $sendusers = array(); + $sendusers = []; get_users_of_course($course->id, $courseroleids, $sendusers); - $reminder = new course_reminder($event, $course, $aheadday, $custom_time); + $reminder = new course_reminder($event, $course, $aheadday, $customtime); return new reminder_ref($reminder, $sendusers); } return null; @@ -466,12 +470,12 @@ function process_course_event($event, $aheadday, $custom_time=null, $courserolei * * @param object $event calendar event. * @param int $aheadday number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @param array $courseroleids role ids for course. * @param boolean $showtrace whether to print logs or not. * @return reminder_ref reminder reference instance. */ -function process_category_event($event, $aheadday, $custom_time=null, $courseroleids=null, $showtrace=true) { +function process_category_event($event, $aheadday, $customtime=null, $courseroleids=null, $showtrace=true) { global $CFG; $catid = $event->categoryid; @@ -490,7 +494,7 @@ function process_category_event($event, $aheadday, $custom_time=null, $courserol } $showtrace && mtrace(" [LOCAL REMINDERS] Course category: $catid => $cat->name"); $childrencourses = $cat->get_courses(['recursive' => true]); - $allusers = array(); + $allusers = []; $currenttime = time(); $allcourses = isset($CFG->local_reminders_category_noforcompleted) && !$CFG->local_reminders_category_noforcompleted; foreach ($childrencourses as $course) { @@ -502,7 +506,7 @@ function process_category_event($event, $aheadday, $custom_time=null, $courserol } $showtrace && mtrace(" [LOCAL REMINDERS] Total users to send = ".count($allusers)); - $reminder = new category_reminder($event, $cat, $aheadday, $custom_time); + $reminder = new category_reminder($event, $cat, $aheadday, $customtime); return new reminder_ref($reminder, $allusers); } @@ -511,25 +515,25 @@ function process_category_event($event, $aheadday, $custom_time=null, $courserol * * @param object $event calendar event. * @param int $aheadday number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @param boolean $showtrace whether to print logs or not. * @return reminder_ref reminder reference instance. */ -function process_group_event($event, $aheadday, $custom_time=null, $showtrace=true) { +function process_group_event($event, $aheadday, $customtime=null, $showtrace=true) { global $DB, $PAGE; - $group = $DB->get_record('groups', array('id' => $event->groupid)); + $group = $DB->get_record('groups', ['id' => $event->groupid]); if (!empty($group)) { if (isset($group->courseid) && !empty($group->courseid)) { $PAGE->set_context(context_course::instance($group->courseid)); } - $coursesettings = $DB->get_record('local_reminders_course', array('courseid' => $group->courseid)); + $coursesettings = $DB->get_record('local_reminders_course', ['courseid' => $group->courseid]); if (isset($coursesettings->status_group) && $coursesettings->status_group == 0) { $showtrace && mtrace(" [Local Reminder] Reminders for group events has been restricted in the configs."); return null; } - $reminder = new group_reminder($event, $group, $aheadday, $custom_time); + $reminder = new group_reminder($event, $group, $aheadday, $customtime); // Add module details, if this event is a mod type event. if (!isemptystring($event->modulename) && $event->courseid > 0) { @@ -546,16 +550,16 @@ function process_group_event($event, $aheadday, $custom_time=null, $showtrace=tr * * @param object $event calendar event. * @param int $aheadday number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @return reminder_ref reminder reference instance. */ -function process_user_event($event, $aheadday, $custom_time=null) { +function process_user_event($event, $aheadday, $customtime=null) { global $DB; - $user = $DB->get_record('user', array('id' => $event->userid, 'deleted' => 0)); + $user = $DB->get_record('user', ['id' => $event->userid, 'deleted' => 0]); if (!empty($user)) { - $reminder = new user_reminder($event, $user, $aheadday, $custom_time); + $reminder = new user_reminder($event, $user, $aheadday, $customtime); $sendusers[] = $user; return new reminder_ref($reminder, $sendusers); } @@ -567,13 +571,13 @@ function process_user_event($event, $aheadday, $custom_time=null) { * * @param object $event calendar event. * @param int $aheadday number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). * @return reminder_ref reminder reference instance. */ -function process_site_event($event, $aheadday, $custom_time=null) { +function process_site_event($event, $aheadday, $customtime=null) { global $DB, $PAGE; - $reminder = new site_reminder($event, $aheadday, $custom_time); + $reminder = new site_reminder($event, $aheadday, $customtime); $sendusers = $DB->get_records_sql("SELECT * FROM {user} WHERE id > 1 AND deleted=0 AND suspended=0 AND confirmed=1;"); @@ -590,9 +594,9 @@ function get_roles_for_reminders() { global $CFG; $allroles = get_all_roles(); - $courseroleids = array(); - $activityroleids = array(); - $categoryroleids = array(); + $courseroleids = []; + $activityroleids = []; + $categoryroleids = []; if (!empty($allroles)) { $flag = 0; foreach ($allroles as $arole) { @@ -611,11 +615,11 @@ function get_roles_for_reminders() { $flag++; } } - return array( + return [ $courseroleids, $activityroleids, $categoryroleids, - ); + ]; } /** @@ -759,7 +763,7 @@ function get_active_role_users($activityroleids, $context) { return get_role_users($activityroleids, $context, true, 'ra.id as ra_id, u.*', null, false, '', '', '', 'ue.status = :userenrolstatus', - array('userenrolstatus' => ENROL_USER_ACTIVE)); + ['userenrolstatus' => ENROL_USER_ACTIVE]); } /** @@ -780,7 +784,7 @@ function filter_user_group_overrides($event, $sendusers, $showtrace) { $showtrace && mtrace(" [Local Reminder] Event supports overrides for key "); $idcolumn = REMINDERS_SUPPORTED_OVERRIDES_REF_IDS[$event->modulename]; - $overridesrecords = $DB->get_records($event->modulename.'_overrides', array($idcolumn => $event->instance)); + $overridesrecords = $DB->get_records($event->modulename.'_overrides', [$idcolumn => $event->instance]); if (empty($overridesrecords)) { $showtrace && mtrace(" [Local Reminder] No overrides for activity ".$event->instance."!"); return $sendusers; @@ -820,12 +824,12 @@ function filter_user_group_overrides($event, $sendusers, $showtrace) { function get_users_in_group($group) { global $DB; - $sendusers = array(); + $sendusers = []; $groupmemberroles = groups_get_members_by_role($group->id, $group->courseid, 'u.id'); if ($groupmemberroles) { foreach ($groupmemberroles as $roleid => $roledata) { foreach ($roledata->users as $member) { - $sendusers[] = $DB->get_record('user', array('id' => $member->id)); + $sendusers[] = $DB->get_record('user', ['id' => $member->id]); } } } @@ -880,7 +884,7 @@ function isemptystring($str) { function fetch_module_instance($modulename, $instance, $courseid=0, $showtrace=true) { global $DB; - $params = array('instance' => $instance, 'modulename' => $modulename); + $params = ['instance' => $instance, 'modulename' => $modulename]; $courseselect = ""; @@ -965,7 +969,7 @@ public static function get_human_readable_tz($tz) { * @return void. */ private static function load_tz_info() { - self::$mapping = array(); + self::$mapping = []; foreach (static::$badzones as $detailname => $abbr) { if (!is_numeric($detailname)) { self::$mapping[$abbr] = $detailname; diff --git a/reminder.class.php b/reminder.class.php index 3da07c1..3aa4ca7 100644 --- a/reminder.class.php +++ b/reminder.class.php @@ -23,7 +23,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die; /** * Abstract class for reminder object. @@ -45,7 +44,7 @@ abstract class local_reminder { /** * @var object custom time ahead of the actual event. */ - protected $custom_time; + protected $customtime; /** * @var int indicates immediate sending of message as a notification. @@ -144,12 +143,12 @@ abstract class local_reminder { * * @param object $event calendar event. * @param integer $aheaddays number of days ahead. - * @param object $custom_time contains the custom time value and unit (if configured). + * @param object $customtime contains the custom time value and unit (if configured). */ - public function __construct($event, $aheaddays = 1, $custom_time=null) { + public function __construct($event, $aheaddays = 1, $customtime=null) { $this->event = $event; $this->aheaddays = $aheaddays; - $this->custom_time = $custom_time; + $this->customtime = $customtime; } /** @@ -183,7 +182,7 @@ public function filter_authorized_users($users, $type=null) { */ public function write_table_row($headervalue, $value, $customizedstyle=null, $overridestyle=true) { $htmltext = html_writer::start_tag('tr'); - $defheadercss = array('style' => $this->defheaderstyle); + $defheadercss = ['style' => $this->defheaderstyle]; if (isset($customizedstyle)) { $finalstyles = $customizedstyle; if (!$overridestyle) { @@ -217,7 +216,7 @@ protected function write_location_info($event) { */ protected function write_description($description, $event) { $htmltext = html_writer::start_tag('tr'); - $columndescstyle = array('style' => $this->descstyle, 'colspan' => 2); + $columndescstyle = ['style' => $this->descstyle, 'colspan' => 2]; if (isemptystring($description)) { $htmltext .= html_writer::tag('td', "

$event->name

", $columndescstyle); } else { @@ -266,6 +265,21 @@ protected function get_tzinfo_plain($user, $event) { return format_event_time_duration($user, $event, null, true, 'plain'); } + /** + * Returns number of ahead days as a plain text. + * The format looks like: "[# days to go]" when aheaddays > 0. + * For custom scehdules: "[# {timeunit}s to go]". + * + * @return string number of days/time units in advance as a text. + */ + protected function get_aheaddays_plain() { + if ($this->aheaddays != 0) { + return '['.$this->pluralize($this->aheaddays, ' day').' to go]'; + } else { + return '['.$this->pluralize($this->customtime->value, ' ' . $this->customtime->unit).' to go]'; + } + } + /** * Pluralize given text by appending 's' if number if greater than 1. * @@ -287,15 +301,15 @@ protected function get_html_footer() { $footer = html_writer::start_tag('tr'); $moodlecalendarname = get_string('moodlecalendarname', 'local_reminders'); - $calendarlink = html_writer::link($CFG->wwwroot.'/calendar/index.php', $moodlecalendarname, array('target' => '_blank')); + $calendarlink = html_writer::link($CFG->wwwroot.'/calendar/index.php', $moodlecalendarname, ['target' => '_blank']); if (isset($CFG->local_reminders_emailfooterdefaultenabled) && $CFG->local_reminders_emailfooterdefaultenabled) { - $footer .= html_writer::start_tag('td', array('style' => $this->footerdefstyle, 'colspan' => 2)); + $footer .= html_writer::start_tag('td', ['style' => $this->footerdefstyle, 'colspan' => 2]); $footer .= get_string('reminderfrom', 'local_reminders').' '; $footer .= $calendarlink; } else if (isset($CFG->local_reminders_emailfootercustom) && trim($CFG->local_reminders_emailfootercustom) !== '') { - $footer .= html_writer::start_tag('td', array('style' => $this->footerstyle, 'colspan' => 2)); + $footer .= html_writer::start_tag('td', ['style' => $this->footerstyle, 'colspan' => 2]); $footer .= text_to_html($CFG->local_reminders_emailfootercustom, false, false, true); } else { @@ -312,9 +326,10 @@ protected function get_html_footer() { * @return string complete url for the event */ protected function generate_event_link() { - $params = array('view' => 'day', 'cal_d' => date('j', $this->event->timestart), + $params = [ + 'view' => 'day', 'cal_d' => date('j', $this->event->timestart), 'cal_m' => date('n', $this->event->timestart), 'cal_y' => date('Y', $this->event->timestart), - ); + ]; $calurl = new moodle_url('/calendar/view.php', $params); $calurl->set_anchor('event_'.$this->event->id); @@ -370,7 +385,7 @@ public function get_custom_headers() { $urlinfo = parse_url($CFG->wwwroot); $hostname = $urlinfo['host']; - return array('Message-ID: event->id.'@'.$hostname.'>'); + return ['Message-ID: event->id.'@'.$hostname.'>']; } /** diff --git a/settings.php b/settings.php index fed4551..de8d8be 100644 --- a/settings.php +++ b/settings.php @@ -35,7 +35,7 @@ // Load all roles in the moodle. $systemcontext = context_system::instance(); $allroles = role_fix_names(get_all_roles(), $systemcontext, ROLENAME_ORIGINAL); - $rolesarray = array(); + $rolesarray = []; if (!empty($allroles)) { foreach ($allroles as $arole) { $rolesarray[$arole->shortname] = ' '.$arole->localname; @@ -43,9 +43,9 @@ } // Default settings for recieving reminders according to role. - $defaultrolesforcourse = array('student' => 1); - $defaultrolesforcategory = array('editingteacher' => 1, 'teacher' => 1); - $defaultrolesforactivity = array('student' => 1, 'editingteacher' => 1); + $defaultrolesforcourse = ['student' => 1]; + $defaultrolesforcategory = ['editingteacher' => 1, 'teacher' => 1]; + $defaultrolesforactivity = ['student' => 1, 'editingteacher' => 1]; // Adds a checkbox to enable/disable sending reminders. $settings->add(new admin_setting_configcheckbox('local_reminders_enable', @@ -60,9 +60,10 @@ get_string('messagetitleprefix', 'local_reminders'), get_string('messagetitleprefixdescription', 'local_reminders'), 'Moodle-Reminder')); - $replychoices = array(REMINDERS_SEND_AS_ADMIN => get_string('sendasadmin', 'local_reminders'), - REMINDERS_SEND_AS_NO_REPLY => get_string('sendasnoreply', 'local_reminders'), - ); + $replychoices = [ + REMINDERS_SEND_AS_ADMIN => get_string('sendasadmin', 'local_reminders'), + REMINDERS_SEND_AS_NO_REPLY => get_string('sendasnoreply', 'local_reminders'), + ]; $settings->add(new admin_setting_configselect('local_reminders_sendas', get_string('sendas', 'local_reminders'), @@ -73,9 +74,10 @@ get_string('sendasnametitle', 'local_reminders'), get_string('sendasnamedescription', 'local_reminders'), 'No Reply')); - $choices = array(REMINDERS_SEND_ALL_EVENTS => get_string('filtereventssendall', 'local_reminders'), - REMINDERS_SEND_ONLY_VISIBLE => get_string('filtereventsonlyvisible', 'local_reminders'), - ); + $choices = [ + REMINDERS_SEND_ALL_EVENTS => get_string('filtereventssendall', 'local_reminders'), + REMINDERS_SEND_ONLY_VISIBLE => get_string('filtereventsonlyvisible', 'local_reminders'), + ]; $settings->add(new admin_setting_configselect('local_reminders_filterevents', get_string('filterevents', 'local_reminders'), @@ -85,7 +87,7 @@ $corepluginmanager = core_plugin_manager::instance(); $formatplugins = $corepluginmanager->get_plugins_of_type('mod'); $enabledplugins = $corepluginmanager->get_enabled_plugins('mod'); - $excludedoptions = array(); + $excludedoptions = []; foreach ($formatplugins as $key => $value) { if (in_array($key, $enabledplugins)) { $excludedoptions[$key] = $value->displayname; @@ -95,7 +97,7 @@ $settings->add(new admin_setting_configmultiselect('local_reminders_excludedmodulenames', get_string('excludedmodules', 'local_reminders'), get_string('excludedmodulesdesc', 'local_reminders'), - array(), + [], $excludedoptions)); // REMINDER EMAIL CONFIGURATIONS. @@ -117,19 +119,20 @@ // END OF EMAIL CONFIGURATIONS. - $daysarray = array('days7' => ' '.get_string('days7', 'local_reminders'), - 'days3' => ' '.get_string('days3', 'local_reminders'), - 'days1' => ' '.get_string('days1', 'local_reminders'), - ); + $daysarray = [ + 'days7' => ' '.get_string('days7', 'local_reminders'), + 'days3' => ' '.get_string('days3', 'local_reminders'), + 'days1' => ' '.get_string('days1', 'local_reminders'), + ]; // Default settings for each event type. - $defaultsite = array('days7' => 0, 'days3' => 1, 'days1' => 0); - $defaultuser = array('days7' => 0, 'days3' => 0, 'days1' => 1); - $defaultcourse = array('days7' => 0, 'days3' => 1, 'days1' => 0); - $defaultcategory = array('days7' => 0, 'days3' => 1, 'days1' => 0); - $defaultgroup = array('days7' => 0, 'days3' => 1, 'days1' => 0); - $defaultdue = array('days7' => 0, 'days3' => 1, 'days1' => 0); - $defaultdueopen = array('days7' => 0, 'days3' => 1, 'days1' => 0); + $defaultsite = ['days7' => 0, 'days3' => 1, 'days1' => 0]; + $defaultuser = ['days7' => 0, 'days3' => 0, 'days1' => 1]; + $defaultcourse = ['days7' => 0, 'days3' => 1, 'days1' => 0]; + $defaultcategory = ['days7' => 0, 'days3' => 1, 'days1' => 0]; + $defaultgroup = ['days7' => 0, 'days3' => 1, 'days1' => 0]; + $defaultdue = ['days7' => 0, 'days3' => 1, 'days1' => 0]; + $defaultdueopen = ['days7' => 0, 'days3' => 1, 'days1' => 0]; // CALENDAR EVENT CHANGED EVENTS. @@ -240,10 +243,11 @@ get_string('overduewarnmessage', 'local_reminders'), get_string('overduewarnmessagedescription', 'local_reminders'), 'This activity is overdue!')); - $activitychoices = array(REMINDERS_ACTIVITY_BOTH => get_string('activityremindersboth', 'local_reminders'), - REMINDERS_ACTIVITY_ONLY_OPENINGS => get_string('activityremindersonlyopenings', 'local_reminders'), - REMINDERS_ACTIVITY_ONLY_CLOSINGS => get_string('activityremindersonlyclosings', 'local_reminders'), - ); + $activitychoices = [ + REMINDERS_ACTIVITY_BOTH => get_string('activityremindersboth', 'local_reminders'), + REMINDERS_ACTIVITY_ONLY_OPENINGS => get_string('activityremindersonlyopenings', 'local_reminders'), + REMINDERS_ACTIVITY_ONLY_CLOSINGS => get_string('activityremindersonlyclosings', 'local_reminders'), + ]; $settings->add(new admin_setting_configselect('local_reminders_duesend', get_string('sendactivityreminders', 'local_reminders'),