Skip to content

Commit 4a23378

Browse files
committed
Limit 'manageownnotifications' to non-global notifs, misc fixes - #24
1 parent b5b5f3b commit 4a23378

File tree

9 files changed

+43
-21
lines changed

9 files changed

+43
-21
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ env:
2020
- MOODLE_BRANCH=MOODLE_310_STABLE
2121
- MOODLE_BRANCH=MOODLE_39_STABLE
2222
- MOODLE_BRANCH=MOODLE_38_STABLE
23-
- MOODLE_BRANCH=MOODLE_37_STABLE
24-
- MOODLE_BRANCH=MOODLE_36_STABLE
2523
- MOODLE_BRANCH=MOODLE_35_STABLE
2624

2725
matrix:
@@ -72,4 +70,4 @@ script:
7270
- moodle-plugin-ci phpdoc
7371
- moodle-plugin-ci validate
7472
- moodle-plugin-ci savepoints
75-
- moodle-plugin-ci grunt
73+
- moodle-plugin-ci grunt -t stylecheck

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## v1.4.0 - 18/12/2020
4+
5+
### Added
6+
* Users can now create/manage their own (instance-based/non-global) notifications
7+
* Enable via capability/permissions - `manageownnotifications`.
8+
* A package.json file for easier (local) testing, checks & generation of code.
9+
10+
### Changed
11+
* General code, UI & language strings cleanup.
12+
* Updated README.md with new feature listed.
13+
* Bumped version number.
14+
15+
### Fixed
16+
* TravisCI file - updated moodle-plugin-ci to use Moodle HQ's.
17+
318
## v1.3.12 - 13/10/2020
419

520
### Changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
*/
5151

5252
module.exports = function(grunt) {
53-
5453
let decachephp = "../../admin/cli/purge_caches.php";
5554
const sass = require('node-sass');
5655

@@ -130,7 +129,8 @@ module.exports = function(grunt) {
130129

131130
// Register tasks.
132131
grunt.registerTask("default", ["watch"]);
133-
grunt.registerTask("css", ["stylelint:scss", "sass"]);
132+
grunt.registerTask("css", ["stylelint:scss", "sass", "stylelint:css"]);
133+
grunt.registerTask("stylecheck", ["stylelint:scss", "stylelint:css"]);
134134
grunt.registerTask("js", ["uglify"]);
135135
grunt.registerTask("decache", ["exec:decache"]);
136136
};

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@ This could be useful in cases such as alerting users of scheduled outages, welco
1414
* Customisable title & message
1515
* Basic HTML tags allowed for advanced users
1616
* Multi-lingual/filter support
17-
* Multiple types of notifications (Bootstrap-based)
17+
* Multiple types of notifications (Bootstrap-based styles)
1818
* Type-based icons (optional setting)
1919
* Dismissible/Non-Dismissible
2020
* Customisable date range to show notifications
2121
* Display a notification to the user a set amount of times
2222
* Instance-based or global/site-wide notifications
23+
* Users (e.g. teachers) can create and manage their own instance-based notifications - **disabled by default**
2324
* Enable/Disable a/all notifications (Site-wide and instance-based)
2425
* Edit/Delete/Restore notifications
2526
* Option to auto-delete notification after end date
2627
* Option to permanently delete notifications that's had the deleted flag for more than 30 days
2728
* Option to automatically remove user (dismissed/seen) records that relates to notifications that don't exist anymore
2829
* AJAX used to improve user-experience and simplify processes
29-
* Live-preview when making/editing a notification
30+
* Live-preview when adding/editing a notification
3031
* Easy to use, but fully documented with all the nitty-gritty information
3132
* Implements Privacy API (GDPR Compliance)
3233

lang/en/block_advnotifications.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
$string['advnotifications_cell_yes'] = 'Yes';
5555
$string['advnotifications_cell_no'] = 'No';
5656

57-
$string['advnotifications_restore_table_warning'] = '<strong>Warning!</strong> Deleting notifications from this table will permanently delete it from the database. We recommend using the auto-delete features of the plugin...';
57+
$string['advnotifications_restore_table_warning'] = '<strong>Warning!</strong> Deleting notifications from this table will permanently delete it from the database. It is recommended to use the auto-delete features of the plugin...';
5858

5959
// Manage Advanced Notification Lang Strings.
6060
$string['advnotifications_table_title'] = 'Manage notifications';

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
"grunt-contrib-watch": "^1.1.0",
1414
"grunt-exec": "^0.4.7",
1515
"grunt-sass": "^2.1.0",
16-
"grunt-stylelint": "^0.6.0",
17-
"stylelint": "^8.0.0"
16+
"grunt-stylelint": "^0.6.0"
1817
},
1918
"engines": {
2019
"node": ">=10"
2120
},
2221
"license": "GPL-3.0",
2322
"dependencies": {
2423
"grunt-cli": "^1.3.2",
24+
"stylelint": "^8.0.0",
2525
"stylelint-csstree-validator": "^1.9.0"
2626
}
2727
}

pages/process.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@
145145
}
146146
}
147147

148+
// Build redirect url params.
149+
$params = [];
150+
if (isset($blockinstance) && $blockinstance > -1) {
151+
$params['blockid'] = $blockinstance;
152+
}
153+
148154
// Handle Delete/Edit early as it requires few resources, and then we can quickly exit(),
149155
// this is the new AJAX/JS deletion/editing method.
150156
if (isset($tableaction) && $tableaction != '') {
@@ -158,7 +164,7 @@
158164
echo json_encode($enotification);
159165
exit();
160166
} else {
161-
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php'),
167+
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php', $params),
162168
get_string('advnotifications_err_nojsedit', 'block_advnotifications'));
163169
}
164170
} else if ($purpose == 'delete') {
@@ -174,7 +180,7 @@
174180
echo json_encode(array("done" => $tableaction));
175181
exit();
176182
} else {
177-
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php'));
183+
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php', $params));
178184
}
179185
} else if ($purpose == 'restore') {
180186
$rnotification = new stdClass();
@@ -189,7 +195,7 @@
189195
echo json_encode(array("done" => $tableaction));
190196
exit();
191197
} else {
192-
redirect(new moodle_url('/blocks/advnotifications/pages/restore.php'));
198+
redirect(new moodle_url('/blocks/advnotifications/pages/restore.php', $params));
193199
}
194200
} else if ($purpose == 'permdelete') {
195201
$DB->delete_records('block_advnotifications', array('id' => $tableaction));
@@ -198,7 +204,7 @@
198204
echo json_encode(array('done' => $tableaction));
199205
exit();
200206
} else {
201-
redirect(new moodle_url('/blocks/advnotifications/pages/restore.php'));
207+
redirect(new moodle_url('/blocks/advnotifications/pages/restore.php', $params));
202208
}
203209
}
204210
}
@@ -254,7 +260,7 @@
254260
echo json_encode(array("updated" => $title));
255261
exit();
256262
} else {
257-
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php'),
263+
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php', $params),
258264
get_string('advnotifications_err_nojsedit', 'block_advnotifications'));
259265
}
260266
}
@@ -288,7 +294,7 @@
288294
exit();
289295
} else {
290296
// Redirect with Error.
291-
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php'),
297+
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php', $params),
292298
get_string('advnotifications_err_req', 'block_advnotifications', $error));
293299
}
294300
}
@@ -325,6 +331,6 @@
325331
echo json_encode("I: Successful");
326332
exit();
327333
} else {
328-
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php'));
334+
redirect(new moodle_url('/blocks/advnotifications/pages/notifications.php', $params));
329335
}
330336
}

styles.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ body #advnotifications_restore_table_wrapper td > form button {
1818
transition: 100ms;
1919
}
2020

21-
body #advnotifications_table_wrapper td > form button[class*="restore"], body #advnotifications_table_wrapper td > form button[class*="edit"],
21+
body #advnotifications_table_wrapper td > form button[class*="restore"],
22+
body #advnotifications_table_wrapper td > form button[class*="edit"],
2223
body #advnotifications_restore_table_wrapper td > form button[class*="restore"],
2324
body #advnotifications_restore_table_wrapper td > form button[class*="edit"] {
2425
color: #060;
@@ -29,7 +30,8 @@ body #advnotifications_restore_table_wrapper td > form button[class*="delete"] {
2930
color: #730000;
3031
}
3132

32-
body #advnotifications_table_wrapper td > form button:hover, body #advnotifications_table_wrapper td > form button:focus,
33+
body #advnotifications_table_wrapper td > form button:hover,
34+
body #advnotifications_table_wrapper td > form button:focus,
3335
body #advnotifications_restore_table_wrapper td > form button:hover,
3436
body #advnotifications_restore_table_wrapper td > form button:focus {
3537
outline: none;

version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
defined('MOODLE_INTERNAL') || die;
2727

2828
$plugin->component = 'block_advnotifications'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494).
29-
$plugin->version = 2020101320; // YYYYMMDDHH (year, month, day, 24-hr format hour).
29+
$plugin->version = 2020121814; // YYYYMMDDHH (year, month, day, 24-hr format hour).
3030
$plugin->requires = 2018051703; // YYYYMMDDHH (Version number for Moodle 3.5.3 as at 21/01/2019).
3131
$plugin->maturity = MATURITY_STABLE; // Code maturity/stability.
32-
$plugin->release = 'v1.3.14'; // Human-readable release version.
32+
$plugin->release = 'v1.4.0'; // Human-readable release version.

0 commit comments

Comments
 (0)