-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlib.php
52 lines (47 loc) · 1.98 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @package local_resourcenotif
* @copyright 2012-2021 Silecs {@link http://www.silecs.info/societe}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function local_resourcenotif_extend_navigation_course() {
global $OUTPUT, $PAGE;
$linkItem = '<a class="dropdown-item editing_notifications menu-action cm-edit-action" data-action="notifications" role="menuitem" href="'
. htmlspecialchars(new moodle_url('/local/resourcenotif/resourcenotif.php', array('id' => '123XYZ321')))
. '" title="' . htmlspecialchars(get_string("notifications")) . '">'
. $OUTPUT->pix_icon('t/email', get_string("notifications"))
. '<span class="menu-action-text">' . htmlspecialchars(get_string("notifications")) . '</span>'
. '</a>';
//style Boost
$enc = json_encode($linkItem);
$PAGE->requires->js_init_code(<<<EOJS
var activities = document.querySelectorAll('.section-cm-edit-actions div[role="menu"]');
if (activities) {
for (var i = 0; i < activities.length; i++) {
var ul = activities[i];
var owner = ul.parentNode.parentNode.parentNode.getAttribute('data-owner');
if (owner) {
var id = owner.replace(/^#module-/, '');
ul.insertAdjacentHTML('beforeend', $enc.replace('123XYZ321', id));
}
}
}
EOJS
, true);
//code style Clean
$enc = json_encode('<li role="presentation">' . $linkItem . '</li>');
$PAGE->requires->js_init_code(<<<EOJS
var activities = document.querySelectorAll('.section-cm-edit-actions ul[role="menu"]');
if (activities) {
for (var i = 0; i < activities.length; i++) {
var ul = activities[i];
var owner = ul.parentNode.getAttribute('data-owner');
if (owner) {
var id = owner.replace(/^#module-/, '');
ul.insertAdjacentHTML('beforeend', $enc.replace('123XYZ321', id));
}
}
}
EOJS
, true);
}