MDL-45758 tool_monitor: Build the navigation tree for the tool
Original issue - MDL-46131
This commit is contained in:
@@ -29,6 +29,8 @@ $string['allmodules'] = 'All modules';
|
||||
$string['core'] = 'Core';
|
||||
$string['eventnotfound'] = 'Event not found';
|
||||
$string['freqdesc'] = '{$a->freq} times in {$a->mins} minutes';
|
||||
$string['managesubscriptions'] = 'Manage subscriptions';
|
||||
$string['managerules'] = 'Manage rules';
|
||||
$string['pluginname'] = 'Event monitor';
|
||||
$string['selectcourse'] = 'Visit this report at course level to get a list of possible modules';
|
||||
$string['tool/monitor:managerules'] = 'Manage event monitor rules';
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This page lists public api for tool_monitor plugin.
|
||||
*
|
||||
* @package tool_monitor
|
||||
* @copyright 2014 onwards Ankit Agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
/**
|
||||
* This function extends the navigation with the tool items
|
||||
*
|
||||
* @param navigation_node $navigation The navigation node to extend
|
||||
* @param stdClass $course The course to object for the tool
|
||||
* @param context $context The context of the course
|
||||
*/
|
||||
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)) {
|
||||
$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,
|
||||
null, null, new pix_icon('i/settings', ''));
|
||||
}
|
||||
|
||||
if (has_capability('tool/monitor:subscribe', $context)) {
|
||||
$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', ''));
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Links and settings
|
||||
*
|
||||
* This file contains links and settings used by tool_monitor
|
||||
*
|
||||
* @package tool_monitor
|
||||
* @copyright 2014 onwards Ankit Agarwal <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('reports', new admin_category('toolmonitor', new lang_string('pluginname', 'tool_monitor')));
|
||||
|
||||
// Manage rules page.
|
||||
$url = new moodle_url('/admin/tool/monitor/managerules.php', array('courseid' => 0));
|
||||
$temp = new admin_externalpage('toolmonitorrules', get_string('managerules', 'tool_monitor'), $url,
|
||||
'tool/monitor:managerules');
|
||||
$ADMIN->add('toolmonitor', $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;
|
||||
}
|
||||
Reference in New Issue
Block a user