Skip to content

Commit cab9551

Browse files
committed
Add ability to manage/create own notification - cap-based - #24
1 parent 6863200 commit cab9551

21 files changed

+179
-101
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Files and directories that git should ignore.
2-
32
.DS_Store
3+
node_modules

.stylelintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
**/src/**
2+
scss/*
23
**/*.scss
34
**/**/*.scss

amd/build/custom.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/notif.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/custom.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ define(['jquery'], function($) {
3535
senddata.call = 'ajax';
3636
senddata.purpose = '';
3737
senddata.tableaction = '';
38+
senddata.blockid = '';
3839

3940
// Check if user wants to edit/delete.
4041
var eattr = $(this).closest('form').attr('data-edit');
4142
var dattr = $(this).closest('form').attr('data-delete');
43+
senddata.blockid = $(this).closest('form').find('[name=blockid]')[0].value;
4244
refreshRequired();
4345

4446
// Check if anchor element has attribute, retrieved from above.
@@ -123,10 +125,12 @@ define(['jquery'], function($) {
123125
senddata.call = 'ajax';
124126
senddata.purpose = '';
125127
senddata.tableaction = '';
128+
senddata.blockid = '';
126129

127130
// Check if user wants to restore/delete.
128131
var rattr = $(this).closest('form').attr('data-restore');
129132
var pdattr = $(this).closest('form').attr('data-permdelete');
133+
senddata.blockid = $(this).closest('form').find('[name=blockid]')[0].value;
130134

131135
// Check if anchor element has attribute, retrieved from above.
132136
if (typeof rattr !== typeof undefined && rattr !== false) {

block_advnotifications.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ public function get_content_for_output($output) {
9393
// Only do this if bc has been set (block has content, editing mode on, etc).
9494
if (isset($bc)) {
9595
$context = context_system::instance();
96-
if ($this->page->user_can_edit_blocks() && has_capability('block/advnotifications:managenotifications', $context)) {
96+
$bcontext = context_block::instance($bc->blockinstanceid);
97+
if ($this->page->user_can_edit_blocks() &&
98+
(has_capability('block/advnotifications:managenotifications', $context) ||
99+
has_capability('block/advnotifications:manageownnotifications', $bcontext))) {
97100
// Edit config icon - always show - needed for positioning UI.
98101
$str = new lang_string('advnotifications_table_title', 'block_advnotifications');
99102
$controls = new action_menu_link_secondary(

classes/notifications_table.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function col_actions($values) {
5858
<input type="hidden" class="edit_notification_sesskey" name="sesskey" value="' . sesskey() . '">
5959
<input type="hidden" class="edit_notification_purpose" name="purpose" value="edit">
6060
<input type="hidden" class="edit_notification_tableaction" name="tableaction" value="' . $values->id . '">
61+
<input type="hidden" class="edit_notification_blockid" name="blockid" value="' . $values->blockid . '">
6162
<button type="submit" class="edit_notification_edit icon fa fa-pencil-square-o fa-fw" name="edit"
6263
title="' . get_string('advnotifications_edit_label', 'block_advnotifications') . '"></button>
6364
</form>
@@ -66,6 +67,7 @@ public function col_actions($values) {
6667
<input type="hidden" class="delete_notification_sesskey" name="sesskey" value="' . sesskey() . '">
6768
<input type="hidden" class="delete_notification_purpose" name="purpose" value="delete">
6869
<input type="hidden" class="delete_notification_tableaction" name="tableaction" value="' . $values->id . '">
70+
<input type="hidden" class="delete_notification_blockid" name="blockid" value="' . $values->blockid . '">
6971
<button type="submit" class="delete_notification_delete icon fa fa-trash-o fa-fw" name="delete"
7072
title="' . get_string('advnotifications_delete_label', 'block_advnotifications') . '"></button>
7173
</form>';

classes/restore_table.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function col_actions($values) {
5555
<input type="hidden" class="restore_notification_sesskey" name="sesskey" value="' . sesskey() . '">
5656
<input type="hidden" class="restore_notification_purpose" name="purpose" value="restore">
5757
<input type="hidden" class="restore_notification_tableaction" name="tableaction" value="' . $values->id . '">
58+
<input type="hidden" class="restore_notification_blockid" name="blockid" value="' . $values->blockid . '">
5859
<button type="submit" class="restore_notification_restore icon fa fa-history fa-fw" name="restore"
5960
title="' . get_string('advnotifications_restore_label', 'block_advnotifications') . '"></button>
6061
</form>
@@ -63,6 +64,7 @@ public function col_actions($values) {
6364
<input type="hidden" class="delete_notification_sesskey" name="sesskey" value="' . sesskey() . '">
6465
<input type="hidden" class="delete_notification_purpose" name="purpose" value="permdelete">
6566
<input type="hidden" class="delete_notification_tableaction" name="tableaction" value="' . $values->id . '">
67+
<input type="hidden" class="delete_notification_blockid" name="blockid" value="' . $values->blockid . '">
6668
<button type="submit" class="delete_notification_delete icon fa fa-times fa-fw" name="delete"
6769
title="' . get_string('advnotifications_delete_label', 'block_advnotifications') . '"></button>
6870
</form>';

0 commit comments

Comments
 (0)