mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-45758 tool_monitor: Update navigation nodes
This commit is contained in:
parent
b9ba26b222
commit
067e9599ac
3 changed files with 29 additions and 37 deletions
|
@ -47,8 +47,8 @@ $string['norules'] = 'There are no rules you can subscribe to.';
|
||||||
$string['manageruleslink'] = 'You can manage rules from {$a} page.';
|
$string['manageruleslink'] = 'You can manage rules from {$a} page.';
|
||||||
$string['moduleinstance'] = 'Module instance';
|
$string['moduleinstance'] = 'Module instance';
|
||||||
$string['manage'] = 'Manage';
|
$string['manage'] = 'Manage';
|
||||||
$string['managesubscriptions'] = 'Manage subscriptions';
|
$string['managesubscriptions'] = 'Event monitoring';
|
||||||
$string['managerules'] = 'Manage rules';
|
$string['managerules'] = 'Event monitoring rules';
|
||||||
$string['messageheader'] = 'Customise your notification message';
|
$string['messageheader'] = 'Customise your notification message';
|
||||||
$string['messageprovider:notification'] = 'Notifications of rule subscriptions';
|
$string['messageprovider:notification'] = 'Notifications of rule subscriptions';
|
||||||
$string['messagetemplate'] = 'Message template';
|
$string['messagetemplate'] = 'Message template';
|
||||||
|
|
|
@ -32,36 +32,37 @@ defined('MOODLE_INTERNAL') || die;
|
||||||
* @param context $context The context of the course
|
* @param context $context The context of the course
|
||||||
*/
|
*/
|
||||||
function tool_monitor_extend_navigation_course($navigation, $course, $context) {
|
function tool_monitor_extend_navigation_course($navigation, $course, $context) {
|
||||||
$node = navigation_node::create(get_string('pluginname', 'tool_monitor'), null, navigation_node::TYPE_CONTAINER, null,
|
|
||||||
'eventmonitor', new pix_icon('i/tool', ''));
|
|
||||||
|
|
||||||
if (has_capability('tool/monitor:managerules', $context)) {
|
if (has_capability('tool/monitor:managerules', $context)) {
|
||||||
$url = new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => $course->id));
|
$url = new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => $course->id));
|
||||||
$settingsnode = navigation_node::create(get_string('managerules', 'tool_monitor'), $url, navigation_node::TYPE_SETTING,
|
$settingsnode = navigation_node::create(get_string('managerules', 'tool_monitor'), $url, navigation_node::TYPE_SETTING,
|
||||||
null, null, new pix_icon('i/settings', ''));
|
null, null, new pix_icon('i/settings', ''));
|
||||||
}
|
$reportnode = $navigation->get('coursereports');
|
||||||
|
|
||||||
if (has_capability('tool/monitor:subscribe', $context)) {
|
if (isset($settingsnode) && !empty($reportnode)) {
|
||||||
$url = new moodle_url('/admin/tool/monitor/index.php', array('courseid' => $course->id));
|
$reportnode->add_node($settingsnode);
|
||||||
$subsnode = navigation_node::create(get_string('managesubscriptions', 'tool_monitor'), $url,
|
|
||||||
navigation_node::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
|
|
||||||
}
|
|
||||||
|
|
||||||
$reportnode = $navigation->get('coursereports');
|
|
||||||
|
|
||||||
if ((isset($subsnode) || isset($settingsnode)) && !empty($reportnode)) {
|
|
||||||
// Add the node only if there are sub pages.
|
|
||||||
$node = $reportnode->add_node($node);
|
|
||||||
|
|
||||||
// Our navigation lib can not handle nodes that have active child, so we need to always add parent first without
|
|
||||||
// children. Refer MDL-45872 .
|
|
||||||
|
|
||||||
if (isset($settingsnode)) {
|
|
||||||
$node->add_node($settingsnode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($subsnode)) {
|
|
||||||
$node->add_node($subsnode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function extends the navigation with the tool items for user settings node.
|
||||||
|
*
|
||||||
|
* @param navigation_node $navigation The navigation node to extend
|
||||||
|
* @param stdClass $user The user object
|
||||||
|
* @param context $usercontext The context of the user
|
||||||
|
* @param stdClass $course The course to object for the tool
|
||||||
|
* @param context $coursecontext The context of the course
|
||||||
|
*/
|
||||||
|
function tool_monitor_extend_navigation_user_settings($navigation, $user, $usercontext, $course, $coursecontext) {
|
||||||
|
global $USER;
|
||||||
|
if (($USER->id == $user->id)) {
|
||||||
|
$url = new moodle_url('/admin/tool/monitor/index.php', array('courseid' => $course->id));
|
||||||
|
$subsnode = navigation_node::create(get_string('managesubscriptions', 'tool_monitor'), $url,
|
||||||
|
navigation_node::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
|
||||||
|
|
||||||
|
if (isset($subsnode) && !empty($navigation)) {
|
||||||
|
$navigation->add_node($subsnode, 'changepassword');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,19 +26,10 @@
|
||||||
defined('MOODLE_INTERNAL') || die;
|
defined('MOODLE_INTERNAL') || die;
|
||||||
|
|
||||||
if ($hassiteconfig) {
|
if ($hassiteconfig) {
|
||||||
$ADMIN->add('reports', new admin_category('toolmonitor', new lang_string('pluginname', 'tool_monitor')));
|
|
||||||
|
|
||||||
// Manage rules page.
|
// Manage rules page.
|
||||||
$url = new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => 0));
|
$url = new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => 0));
|
||||||
$temp = new admin_externalpage('toolmonitorrules', get_string('managerules', 'tool_monitor'), $url,
|
$temp = new admin_externalpage('toolmonitorrules', get_string('managerules', 'tool_monitor'), $url,
|
||||||
'tool/monitor:managerules');
|
'tool/monitor:managerules');
|
||||||
$ADMIN->add('toolmonitor', $temp);
|
$ADMIN->add('reports', $temp);
|
||||||
|
|
||||||
// Manage subscriptions page.
|
|
||||||
$url = new moodle_url('/admin/tool/monitor/index.php', array('courseid' => 0));
|
|
||||||
$temp = new admin_externalpage('toolmonitorsubscriptions', get_string('managesubscriptions', 'tool_monitor'), $url,
|
|
||||||
'tool/monitor:subscribe');
|
|
||||||
$ADMIN->add('toolmonitor', $temp);
|
|
||||||
|
|
||||||
$settings = null;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue