Skip to content

Commit

Permalink
chore: make moodle prechecker happy
Browse files Browse the repository at this point in the history
  • Loading branch information
isuru89 committed Jan 13, 2024
1 parent 5cf2ceb commit b2e25e2
Show file tree
Hide file tree
Showing 19 changed files with 295 additions and 287 deletions.
2 changes: 0 additions & 2 deletions classes/privacy/provider.php
Expand Up @@ -25,8 +25,6 @@

namespace local_reminders\privacy;

defined('MOODLE_INTERNAL') || die();

/**
* Privacy provider class for package local_reminders
*/
Expand Down
16 changes: 8 additions & 8 deletions contents/activity_handlers.class.php
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
22 changes: 9 additions & 13 deletions contents/category_reminder.class.php
Expand Up @@ -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;
}

Expand All @@ -67,22 +67,22 @@ 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)) {
$titleprefixlangstr = get_string('calendarevent'.strtolower($changetype).'prefix', 'local_reminders');
$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'),
Expand All @@ -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";
Expand Down
22 changes: 9 additions & 13 deletions contents/course_reminder.class.php
Expand Up @@ -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;
}

Expand All @@ -67,22 +67,22 @@ 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)) {
$titleprefixlangstr = get_string('calendarevent'.strtolower($changetype).'prefix', 'local_reminders');
$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'),
Expand All @@ -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";
Expand Down
28 changes: 12 additions & 16 deletions contents/due_reminder.class.php
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand All @@ -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');
}

Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
26 changes: 11 additions & 15 deletions contents/group_reminder.class.php
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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)) {
Expand All @@ -135,22 +135,22 @@ 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)) {
$titleprefixlangstr = get_string('calendarevent'.strtolower($changetype).'prefix', 'local_reminders');
$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'),
Expand All @@ -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) {
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit b2e25e2

Please sign in to comment.