Skip to content

Commit

Permalink
Add new date format & change strings to single quotes - learningworks#30
Browse files Browse the repository at this point in the history
  • Loading branch information
Zander Potgieter committed Feb 14, 2022
1 parent b253b07 commit 45a1aa3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
4 changes: 2 additions & 2 deletions classes/event/notification_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function get_url() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the notification with id '$this->objectid'
for the block with id '$this->contextinstanceid'.";
return 'The user with id \'' . $this->userid . '\' created the notification with id \'' . $this->objectid . '\'
for the block with id \'' . $this->contextinstanceid . '\'.';
}
}
12 changes: 6 additions & 6 deletions classes/event/notification_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public function get_url() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the notification with id '$this->objectid'
for the block with id '$this->contextinstanceid'.
The title was '" . $this->other['old_title'] . "'.
The message was '" . $this->other['old_message'] . "'.
The date from was '" . userdate($this->other['old_date_from']) . "'.
The date to was '" . userdate($this->other['old_date_to']) . "'.";
return 'The user with id \'' . $this->userid . '\' deleted the notification with id \'' . $this->objectid . '\'
for the block with id \'' . $this->contextinstanceid . '\'.
The title was \'' . $this->other['old_title'] . '\'.
The message was \'' . $this->other['old_message'] . '\'.
The date from was \'' . userdate($this->other['old_date_from']) . '\'.
The date to was \'' . userdate($this->other['old_date_to']) . '\'.';
}
}
12 changes: 6 additions & 6 deletions classes/event/notification_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public function get_url() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the notification with id '$this->objectid'
for the block with id '$this->contextinstanceid'.
The title was changed from '" . $this->other['old_title'] . "' to '" . $this->other['new_title'] . "'.
The message was changed from '" . $this->other['old_message'] . "' to '" . $this->other['new_message'] . "'.
The date from was changed from '" . userdate($this->other['old_date_from']) . "' to '" . userdate($this->other['new_date_from']) . "'.
The date to was changed from '" . userdate($this->other['old_date_to']) . "' to '" . userdate($this->other['new_date_to']) . "'.";
return 'The user with id \'' . $this->userid . '\' updated the notification with id \'' . $this->objectid . '\'
for the block with id \'' . $this->contextinstanceid . '\'.
The title was changed from \'' . $this->other['old_title'] . '\' to \'' . $this->other['new_title'] . '\'.
The message was changed from \'' . $this->other['old_message'] . '\' to \'' . $this->other['new_message'] . '\'.
The date from was changed from \'' . userdate($this->other['old_date_from']) . '\' to \'' . userdate($this->other['new_date_from']) . '\'.
The date to was changed from \'' . userdate($this->other['old_date_to']) . '\' to \'' . userdate($this->other['new_date_to']) . '\'.';
}
}
18 changes: 11 additions & 7 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ function prep_notifications($instanceid) {
function get_date_formats() {
$formats = [];

// Show formats for 30 January 2023.
$timestamp = '1675036800';

// Add supported formats to array.
$formats['d/m/Y'] = date('d/m/Y');
$formats['j/n/y'] = date('j/n/y');
$formats['m-d-Y'] = date('m-d-Y');
$formats['n-j-y'] = date('n-j-y');
$formats['j M y'] = date('j M y');
$formats['j F Y'] = date('j F Y');
$formats['d/m/Y'] = date('d/m/Y', $timestamp);
$formats['j/n/y'] = date('j/n/y', $timestamp);
$formats['m-d-Y'] = date('m-d-Y', $timestamp);
$formats['n-j-y'] = date('n-j-y', $timestamp);
$formats['Y-m-d'] = date('Y-m-d', $timestamp);
$formats['j M y'] = date('j M y', $timestamp);
$formats['j F Y'] = date('j F Y', $timestamp);

return $formats;
}
}

0 comments on commit 45a1aa3

Please sign in to comment.