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 356848d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 25 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## v1.4.3 - 14/02/2022

### Added
* ISO 8601 Date format - YYYY-MM-DD.
* Event logging - Thanks [@danielneis](https://github.com/danielneis)!

### Changed
* Minor string changes (backend).
* Tested on Moodle v3.11.
* Bumped version number.

## v1.4.2 - 10/02/2021

### Changed
Expand Down Expand Up @@ -221,4 +232,4 @@
* PHPDocs corrections for class 'advnotifications'.
* Updated 'Message' field to be texarea - allowing for resizing of field.
* Updated SCSS (and therefore CSS) to support resizing of textarea & improved UX for dismiss/close button.
* Bumped version number.
* Bumped version number.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This could be useful in cases such as alerting users of scheduled outages, welco
* Option to automatically remove user (dismissed/seen) records that relates to notifications that don't exist anymore
* AJAX used to improve user-experience and simplify processes
* Live-preview when adding/editing a notification
* Easy to use, but fully documented with all the nitty-gritty information
* Easy to use, but well documented
* Implements Privacy API (GDPR Compliance)

For full documentation, please check [here](docs/AdvancedNotifications.pdf) - or check the plugin's `/docs` directory.
Expand Down
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;
}
}
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die;

$plugin->component = 'block_advnotifications'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494).
$plugin->version = 2021092301; // YYYYMMDDHH (year, month, day, 24-hr format hour).
$plugin->version = 2022021419; // YYYYMMDDHH (year, month, day, 24-hr format hour).
$plugin->requires = 2018051703; // YYYYMMDDHH (Version number for Moodle v3.5.3 as at 21/01/2019).
$plugin->maturity = MATURITY_STABLE; // Code maturity/stability.
$plugin->release = 'v1.4.2'; // Human-readable release version.
$plugin->release = 'v1.4.3'; // Human-readable release version.

0 comments on commit 356848d

Please sign in to comment.