Skip to content

Commit

Permalink
add deprecated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Mar 11, 2024
1 parent 43ef13a commit 140bef2
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 98 deletions.
14 changes: 7 additions & 7 deletions backup/moodle2/backup_moodleoverflow_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ protected function define_structure() {
$moodleoverflow = new backup_nested_element('moodleoverflow', ['id'], [
'name', 'intro', 'introformat', 'maxbytes', 'maxattachments',
'forcesubscribe', 'trackingtype', 'timecreated', 'timemodified',
'ratingpreference', 'coursewidereputation', 'allownegativereputation']);
'ratingpreference', 'coursewidereputation', 'allownegativereputation', ]);

// Define each element separated.
$discussions = new backup_nested_element('discussions');
$discussion = new backup_nested_element('discussion', ['id'], [
'name', 'firstpost', 'userid', 'timemodified', 'usermodified', 'timestart']);
'name', 'firstpost', 'userid', 'timemodified', 'usermodified', 'timestart', ]);

$posts = new backup_nested_element('posts');

$post = new backup_nested_element('post', ['id'], [
'parent', 'userid', 'created', 'modified',
'mailed', 'message', 'messageformat', 'attachment']);
'mailed', 'message', 'messageformat', 'attachment', ]);

$ratings = new backup_nested_element('ratings');

$rating = new backup_nested_element('rating', ['id'], [
'userid', 'rating', 'firstrated', 'lastchanged']);
'userid', 'rating', 'firstrated', 'lastchanged', ]);

$discussionsubs = new backup_nested_element('discuss_subs');

Expand All @@ -75,18 +75,18 @@ protected function define_structure() {
$subscriptions = new backup_nested_element('subscriptions');

$subscription = new backup_nested_element('subscription', ['id'], [
'userid']);
'userid', ]);

$readposts = new backup_nested_element('readposts');

$read = new backup_nested_element('read', ['id'], [
'userid', 'discussionid', 'postid', 'firstread',
'lastread']);
'lastread', ]);

$tracking = new backup_nested_element('tracking');

$track = new backup_nested_element('track', ['id'], [
'userid']);
'userid', ]);

// Build the tree.
$moodleoverflow->add_child($discussions);
Expand Down
3 changes: 2 additions & 1 deletion classes/manager/mail_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ private static function send_post($userto, $post, array &$coursemodules, array &
['userid' => $dataobject->userid,
'courseid' => $dataobject->courseid,
'forumid' => $dataobject->forumid,
'forumdiscussionid' => $dataobject->forumdiscussionid],
'forumdiscussionid' => $dataobject->forumdiscussionid, ],
'numberofposts, id');
if (is_object($record)) {
$dataset = $record;
Expand Down Expand Up @@ -497,6 +497,7 @@ private static function send_post($userto, $post, array &$coursemodules, array &
// Preapare to actually send the post now. Build up the content.
$cleanname = str_replace('"', "'", strip_tags(format_string($moodleoverflow->name)));
$coursecontext = context_course::instance($course->id);
// TODO: deprecated, option array should not contain context objects.
$shortname = format_string($course->shortname, true, ['context' => $coursecontext]);

// Define a header to make mails easier to track.
Expand Down
2 changes: 1 addition & 1 deletion classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static function role_assigned(\core\event\role_assigned $event) {
WHERE m.course = :courseid AND m.forcesubscribe = :initial AND mo.name = 'moodleoverflow' AND ms.id IS NULL";
$params = ['courseid' => $context->instanceid,
'userid' => $userid,
'initial' => MOODLEOVERFLOW_INITIALSUBSCRIBE];
'initial' => MOODLEOVERFLOW_INITIALSUBSCRIBE, ];
$moodleoverflows = $DB->get_records_sql($sql, $params);

// Loop through all moodleoverflows.
Expand Down
10 changes: 5 additions & 5 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,22 +324,22 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {

$DB->delete_records('moodleoverflow_read', [
'moodleoverflowid' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

$DB->delete_records('moodleoverflow_subscriptions', [
'moodleoverflow' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

$DB->delete_records('moodleoverflow_discuss_subs', [
'moodleoverflow' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

$DB->delete_records('moodleoverflow_tracking', [
'moodleoverflowid' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);
$DB->delete_records('moodleoverflow_grades', [
'moodleoverflowid' => $forum->id,
'userid' => $userid]);
'userid' => $userid, ]);

// Do not delete ratings but reset userid.
$ratingsql = "userid = :userid AND discussionid IN
Expand Down
2 changes: 1 addition & 1 deletion classes/ratings.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static function moodleoverflow_add_rating($moodleoverflow, $postid, $rati
// Is the submitted rating valid?
$possibleratings = [RATING_NEUTRAL, RATING_DOWNVOTE, RATING_UPVOTE, RATING_SOLVED,
RATING_HELPFUL, RATING_REMOVE_DOWNVOTE, RATING_REMOVE_UPVOTE,
RATING_REMOVE_SOLVED, RATING_REMOVE_HELPFUL];
RATING_REMOVE_SOLVED, RATING_REMOVE_HELPFUL, ];
if (!in_array($rating, $possibleratings)) {
throw new moodle_exception('invalidratingid', 'moodleoverflow');
}
Expand Down
4 changes: 2 additions & 2 deletions classes/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public static function get_unsubscribable_moodleoverflows() {
WHERE m.forcesubscribe <> :forcesubscribe AND ms.id IS NOT NULL AND cm.course $coursesql";
$params = ['modulename' => 'moodleoverflow',
'userid' => $USER->id,
'forcesubscribe' => MOODLEOVERFLOW_FORCESUBSCRIBE];
'forcesubscribe' => MOODLEOVERFLOW_FORCESUBSCRIBE, ];
$mergedparams = array_merge($courseparams, $params);
$moodleoverflows = $DB->get_recordset_sql($sql, $mergedparams);

Expand Down Expand Up @@ -670,7 +670,7 @@ public static function subscribe_user($userid, $moodleoverflow, $context, $userr
$params = [
'userid' => $userid,
'moodleoverflowid' => $moodleoverflow->id,
'preference' => self::MOODLEOVERFLOW_DISCUSSION_UNSUBSCRIBED];
'preference' => self::MOODLEOVERFLOW_DISCUSSION_UNSUBSCRIBED, ];
$where = 'userid = :userid AND moodleoverflow = :moodleoverflowid AND preference <> :preference';
$DB->delete_records_select('moodleoverflow_discuss_subs', $where, $params);

Expand Down
6 changes: 3 additions & 3 deletions classes/tables/userstats_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ public function __construct($uniqueid, $courseid, $moodleoverflow, $url) {
'forumactivity',
'courseactivity',
'forumreputation',
'coursereputation']);
'coursereputation', ]);
$this->define_baseurl($url);
$this->define_headers([get_string('fullnameuser'),
get_string('userstatsupvotes', 'moodleoverflow'),
get_string('userstatsdownvotes', 'moodleoverflow'),
(get_string('userstatsforumactivity', 'moodleoverflow') . $this->helpactivity->object),
(get_string('userstatscourseactivity', 'moodleoverflow') . $this->helpactivity->object),
get_string('userstatsforumreputation', 'moodleoverflow'),
get_string('userstatscoursereputation', 'moodleoverflow')]);
get_string('userstatscoursereputation', 'moodleoverflow'), ]);
$this->get_table_data();
$this->sortable(true, 'coursereputation', SORT_DESC);
$this->no_sorting('username');
Expand Down Expand Up @@ -277,7 +277,7 @@ public function set_helpactivity() {
'tabindex' => '0',
'data-content' => '<div class=&quot;no-overflow&quot;><p>' .
get_string('helpamountofactivity', 'moodleoverflow') .
'</p> </div>'];
'</p> </div>', ];

$this->helpactivity->object = \html_writer::span($this->helpactivity->icon,
$this->helpactivity->class,
Expand Down
2 changes: 1 addition & 1 deletion classes/task/send_daily_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function execute() {
$string = get_string('digestunreadpost', 'mod_moodleoverflow', ['linktocourse' => $linktocourse,
'linktoforum' => $linktoforum,
'linktodiscussion' => $linktodiscussion,
'unreadposts' => $unreadposts]);
'unreadposts' => $unreadposts, ]);
array_push($mail, $string);
}
// Build the final message and send it to user. Then remove the sent records.
Expand Down
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
$returnto = moodleoverflow_go_back_to($url);

// Prepare the message to be displayed.
// TODO: Deprecated, options should not contain a context object.
$shortname = format_string($course->shortname, true, ['context' => context_course::instance($course->id)]);
$notification = \core\output\notification::NOTIFY_SUCCESS;

Expand Down
3 changes: 2 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ function moodleoverflow_send_mails() {
['userid' => $dataobject->userid,
'courseid' => $dataobject->courseid,
'forumid' => $dataobject->forumid,
'forumdiscussionid' => $dataobject->forumdiscussionid],
'forumdiscussionid' => $dataobject->forumdiscussionid, ],
'numberofposts, id');
if (is_object($record)) {
$dataset = $record;
Expand Down Expand Up @@ -884,6 +884,7 @@ function moodleoverflow_send_mails() {
// Preapare to actually send the post now. Build up the content.
$cleanname = str_replace('"', "'", strip_tags(format_string($moodleoverflow->name)));
$coursecontext = context_course::instance($course->id);
// TODO: Deprecated, options should not contain a context object.
$shortname = format_string($course->shortname, true, ['context' => $coursecontext]);

// Define a header to make mails easier to track.
Expand Down
6 changes: 3 additions & 3 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = -
$userstatsbuttontext = get_string('seeuserstats', 'moodleoverflow');
$userstatsbuttonurl = new moodle_url('/mod/moodleoverflow/userstats.php', ['id' => $cm->id,
'courseid' => $moodleoverflow->course,
'mid' => $moodleoverflow->id]);
'mid' => $moodleoverflow->id, ]);
$userstatsbutton = new single_button($userstatsbuttonurl, $userstatsbuttontext, 'get');
$userstatsbutton->class = 'singlebutton align-middle m-2';
echo $OUTPUT->render($userstatsbutton);
Expand Down Expand Up @@ -325,7 +325,7 @@ function moodleoverflow_print_latest_discussions($moodleoverflow, $cm, $page = -
} else {
// Get his picture, his name and the link to his profile.
$preparedarray[$i]['picture'] = $OUTPUT->user_picture($startuser, ['courseid' => $moodleoverflow->course,
'link' => false]);
'link' => false, ]);
$preparedarray[$i]['username'] = fullname($startuser, has_capability('moodle/site:viewfullnames', $context));
$preparedarray[$i]['userlink'] = $CFG->wwwroot . '/user/view.php?id=' .
$discussion->userid . '&course=' . $moodleoverflow->course;
Expand Down Expand Up @@ -2061,7 +2061,7 @@ function moodleoverflow_update_user_grade_on_db($moodleoverflow, $postuserrating
if ($DB->record_exists('moodleoverflow_grades', ['userid' => $userid, 'moodleoverflowid' => $moodleoverflow->id])) {

$DB->set_field('moodleoverflow_grades', 'grade', $grade, ['userid' => $userid,
'moodleoverflowid' => $moodleoverflow->id]);
'moodleoverflowid' => $moodleoverflow->id, ]);

} else {

Expand Down
4 changes: 2 additions & 2 deletions post.php
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@
'other' => [
'discussionid' => $discussion->id,
'moodleoverflowid' => $moodleoverflow->id,
]];
], ];

// If the editing user is not the original author, add the original author to the params.
if ($realpost->userid != $USER->id) {
Expand Down Expand Up @@ -705,7 +705,7 @@
'other' => [
'discussionid' => $discussion->id,
'moodleoverflowid' => $moodleoverflow->id,
]];
], ];
$event = \mod_moodleoverflow\event\post_created::create($params);
$event->trigger();
redirect(
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/behat_mod_moodleoverflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function add_new_discussion($moodleoverflowname, TableNode $table, $bu

// Navigate to moodleoverflow.
$this->execute('behat_navigation::i_am_on_page_instance', [$this->escape($moodleoverflowname),
'moodleoverflow activity']);
'moodleoverflow activity', ]);
$this->execute('behat_forms::press_button', $buttonstr);

// Fill form and post.
Expand Down
8 changes: 4 additions & 4 deletions tests/dailymail_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private function helper_run_send_mails() {
* Test if the task send_daily_mail sends a mail to the user.
* @covers \send_daily_mail::execute
*/
public function test_mail_delivery() {
public function test_mail_delivery(): void {

// Create user with maildigest = on.
$this->helper_create_user_and_discussion('1');
Expand All @@ -154,7 +154,7 @@ public function test_mail_delivery() {
* Test if the content of the mail matches the supposed content.
* @covers \send_daily_mail::execute
*/
public function test_content_of_mail_delivery() {
public function test_content_of_mail_delivery(): void {

// Create user with maildigest = on.
$this->helper_create_user_and_discussion('1');
Expand Down Expand Up @@ -189,7 +189,7 @@ public function test_content_of_mail_delivery() {
* Test if the task does not send a mail when maildigest = 0
* @covers \send_daily_mail::execute
*/
public function test_mail_not_send() {
public function test_mail_not_send(): void {
// Creat user with daily_mail = off.
$this->helper_create_user_and_discussion('0');

Expand All @@ -205,7 +205,7 @@ public function test_mail_not_send() {
* Test if database is updated after sending a mail
* @covers \send_daily_mail::execute
*/
public function test_records_removed() {
public function test_records_removed(): void {
global $DB;
// Create user with maildigest = on.
$this->helper_create_user_and_discussion('1');
Expand Down
8 changes: 4 additions & 4 deletions tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function tearDown(): void {
* Test subscription using automatic subscription on create.
* @covers \mod_moodleoverflow\subscriptions Subscription of users as default.
*/
public function test_moodleoverflow_auto_subscribe_on_create() {
public function test_moodleoverflow_auto_subscribe_on_create(): void {
global $DB;

$this->resetAfterTest();
Expand Down Expand Up @@ -83,7 +83,7 @@ public function test_moodleoverflow_auto_subscribe_on_create() {
* Test subscription using forced subscription on create.
* @covers \mod_moodleoverflow\subscriptions sorced Subscription of users.
*/
public function test_moodleoverflow_forced_subscribe_on_create() {
public function test_moodleoverflow_forced_subscribe_on_create(): void {
global $DB;

$this->resetAfterTest();
Expand Down Expand Up @@ -115,7 +115,7 @@ public function test_moodleoverflow_forced_subscribe_on_create() {
* Test subscription using optional subscription on create.
* @covers \mod_moodleoverflow\subscriptions optional subscription.
*/
public function test_moodleoverflow_optional_subscribe_on_create() {
public function test_moodleoverflow_optional_subscribe_on_create(): void {
global $DB;

$this->resetAfterTest();
Expand Down Expand Up @@ -146,7 +146,7 @@ public function test_moodleoverflow_optional_subscribe_on_create() {
* Test subscription using disallow subscription on create.
* @covers \mod_moodleoverflow\subscriptions prohibit Subscription of users.
*/
public function test_moodleoverflow_disallow_subscribe_on_create() {
public function test_moodleoverflow_disallow_subscribe_on_create(): void {
global $DB;

$this->resetAfterTest();
Expand Down
4 changes: 2 additions & 2 deletions tests/post_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function tearDown(): void {
* Test if a post and its attachment are deleted successfully.
* @covers ::moodleoverflow_delete_post
*/
public function test_moodleoverflow_delete_post() {
public function test_moodleoverflow_delete_post(): void {
global $DB;

// The attachment should exist.
Expand All @@ -95,7 +95,7 @@ public function test_moodleoverflow_delete_post() {
* Test if a post and its attachment are deleted successfully.
* @covers ::moodleoverflow_delete_discussion
*/
public function test_moodleoverflow_delete_discussion() {
public function test_moodleoverflow_delete_discussion(): void {
global $DB;

$numberofattachments = count($DB->get_records('files', ['itemid' => $this->post->id, 'filearea' => 'attachment']));
Expand Down
Loading

0 comments on commit 140bef2

Please sign in to comment.