/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function engagement_report_extend_navigation($navigation, $course, $context)
{
    if (has_capability('report/engagement:view', $context)) {
        $url = new moodle_url('/course/report/engagement/index.php', array('id' => $course->id));
        $navigation->add(get_string('pluginname', 'coursereport_engagement'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
    }
}
Beispiel #2
0
/**
 * This function extends the navigation with the report items
 *
 * @global stdClass $CFG
 * @global core_renderer $OUTPUT
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass        $course     The course to object for the report
 * @param context         $context    The context of the course
 */
function report_loglive_extend_navigation_course($navigation, $course, $context)
{
    if (has_capability('report/loglive:view', $context)) {
        $url = new moodle_url('/report/loglive/index.php', array('id' => $course->id));
        $navigation->add(get_string('pluginname', 'report_loglive'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
    }
}
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $node The node to add module settings to
 */
function booktool_wordimport_extend_settings_navigation(settings_navigation $settings, navigation_node $node)
{
    global $PAGE;
    if ($PAGE->cm->modname !== 'book') {
        return;
    }
    $params = $PAGE->url->params();
    if (empty($params['id']) and empty($params['cmid'])) {
        return;
    }
    if (empty($PAGE->cm->context)) {
        $PAGE->cm->context = get_context_module::instance($PAGE->cm->instance);
    }
    if (!(has_capability('booktool/wordimport:import', $PAGE->cm->context) and has_capability('mod/book:edit', $PAGE->cm->context))) {
        return;
    }
    // Configure Import link, and pass in the current chapter in case the insert should happen here rather than at the end.
    $url1 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'chapterid' => $params['chapterid']));
    $node->add(get_string('importchapters', 'booktool_wordimport'), $url1, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => '')));
    // Configure Export links for book and current chapter.
    $url2 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'action' => 'export'));
    $node->add(get_string('exportbook', 'booktool_wordimport'), $url2, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => '')));
    $url3 = new moodle_url('/mod/book/tool/wordimport/index.php', array('id' => $PAGE->cm->id, 'chapterid' => $params['chapterid'], 'action' => 'export'));
    $node->add(get_string('exportchapter', 'booktool_wordimport'), $url3, navigation_node::TYPE_SETTING, null, null, new pix_icon('f/document', '', 'moodle', array('class' => 'iconsmall', 'title' => '')));
}
Beispiel #4
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $node The node to add module settings to
 */
function booktool_importhtml_extend_settings_navigation(settings_navigation $settings, navigation_node $node)
{
    global $PAGE;
    if (has_capability('booktool/importhtml:import', $PAGE->cm->context)) {
        $url = new moodle_url('/mod/book/tool/importhtml/index.php', array('id' => $PAGE->cm->id));
        $node->add(get_string('import', 'booktool_importhtml'), $url, navigation_node::TYPE_SETTING, null, null, null);
    }
}
/**
 * This function extends the coursenavigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function report_configreports_extend_navigation_course($navigation, $course, $context)
{
    if ($myreports = report_configreports_get_my_reports($course, $context)) {
        foreach ($myreports as $report) {
            $navigation->add($report['name'], $report['url'], navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
        }
    }
}
Beispiel #6
0
/**
 * This function extends the navigation with the report items
 *
 * @global stdClass $CFG
 * @global core_renderer $OUTPUT
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass        $course     The course to object for the report
 * @param stdClass        $context    The context of the course
 */
function report_loglive_extend_navigation_course($navigation, $course, $context) {
    global $CFG, $OUTPUT;
    if (has_capability('report/loglive:view', $context)) {
        $url = new moodle_url('/report/loglive/index.php', array('id'=>$course->id, 'inpopup'=>1));
        $action = new action_link($url, get_string('pluginname', 'report_loglive'), new popup_action('click', $url));
        $navigation->add('', $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
    }
}
/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function participation_report_extend_navigation($navigation, $course, $context)
{
    global $CFG, $OUTPUT;
    if (has_capability('coursereport/participation:view', $context)) {
        $url = new moodle_url('/course/report/participation/index.php', array('id' => $course->id));
        $navigation->add(get_string('participationreport'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
    }
}
Beispiel #8
0
/**
 * 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_kent_extend_navigation_user_settings($navigation, $user, $usercontext, $course, $coursecontext)
{
    $url = new moodle_url('/local/kent/preferences.php');
    $subsnode = navigation_node::create('Kent Preferences', $url, navigation_node::TYPE_SETTING, null, 'kent');
    if (isset($subsnode) && !empty($navigation)) {
        $navigation->add_node($subsnode);
    }
}
/**
 * This function extends the course navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $user
 * @param stdClass $course The course to object for the report
 */
function report_configurablereports_extend_navigation_user($navigation, $user, $course)
{
    return;
    //TODO: this plugin was not linked from navigation in 2.0, let's keep it that way for now --skodak
    if (report_configurablereports_can_access_user_report($user, $course)) {
        $url = new moodle_url('/report/configurablereports/index.php', array('userid' => $user->id, 'id' => $course->id));
        $navigation->add(get_string('pluginname', 'report_configurablereports'), $url);
    }
}
Beispiel #10
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $node The node to add module settings to
 */
function booktool_exportimscp_extend_settings_navigation(settings_navigation $settings, navigation_node $node)
{
    global $PAGE;
    if (has_capability('booktool/exportimscp:export', $PAGE->cm->context)) {
        $url = new moodle_url('/mod/book/tool/exportimscp/index.php', array('id' => $PAGE->cm->id));
        $icon = new pix_icon('generate', '', 'booktool_exportimscp', array('class' => 'icon'));
        $node->add(get_string('generateimscp', 'booktool_exportimscp'), $url, navigation_node::TYPE_SETTING, null, null, $icon);
    }
}
Beispiel #11
0
/**
 * This function extends the course navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $user
 * @param stdClass $course The course to object for the report
 */
function report_completion_extend_navigation_user($navigation, $user, $course)
{
    return;
    //TODO: this plugin was not linked from navigation in 2.0, let's keep it that way for now --skodak
    if (report_completion_can_access_user_report($user, $course)) {
        $url = new moodle_url('/report/completion/user.php', array('id' => $user->id, 'course' => $course->id));
        $navigation->add(get_string('coursecompletion'), $url);
    }
}
Beispiel #12
0
/**
 * This function extends the course navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $user
 * @param stdClass $course The course to object for the report
 */
function report_outline_extend_navigation_user($navigation, $user, $course)
{
    if (report_outline_can_access_user_report($user, $course)) {
        $url = new moodle_url('/report/outline/user.php', array('id' => $user->id, 'course' => $course->id, 'mode' => 'outline'));
        $navigation->add(get_string('outlinereport'), $url);
        $url = new moodle_url('/report/outline/user.php', array('id' => $user->id, 'course' => $course->id, 'mode' => 'complete'));
        $navigation->add(get_string('completereport'), $url);
    }
}
/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function report_teacherreport_extend_navigation_user($navigation, $user, $course)
{
    global $CFG, $DB, $PAGE, $USER;
    $context = context_user::instance($USER->id);
    if (has_capability('report/teacherreport:view', $context)) {
        $url = new moodle_url('/report/teacherreport/index.php', array('userid' => $USER->id));
        $navigation->add(get_string('pluginname', 'report_teacherreport'), $url, navigation_node::TYPE_SETTING, null, null, null);
    }
}
Beispiel #14
0
 /**
  * Extends the module navigation
  *
  * This function is called when the context for the page is an activity module with the
  * FEATURE_ADVANCED_GRADING and there is an area with the active grading method set to the given plugin.
  *
  * @param global_navigation $navigation {@link global_navigation}
  * @param navigation_node $node {@link navigation_node}
  */
 public function extend_navigation(global_navigation $navigation, navigation_node $node = null)
 {
     if (has_capability('moodle/grade:managegradingforms', $this->get_context())) {
         // no need for preview if user can manage forms, he will have link to manage.php in settings instead
         return;
     }
     if ($this->is_form_defined() && ($options = $this->get_options()) && !empty($options['alwaysshowdefinition'])) {
         $node->add(get_string('gradingof', 'gradingform_rubric', get_grading_manager($this->get_areaid())->get_area_title()), new moodle_url('/grade/grading/form/' . $this->get_method_name() . '/preview.php', array('areaid' => $this->get_areaid())), settings_navigation::TYPE_CUSTOM);
     }
 }
Beispiel #15
0
/**
 * This function extends the course navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $user
 * @param stdClass $course The course to object for the report
 */
function report_stats_extend_navigation_user($navigation, $user, $course) {
    global $CFG;
    if (!empty($CFG->enablestats)) {
        return;
    }
    if (report_stats_can_access_user_report($user, $course)) {
        $url = new moodle_url('/report/stats/user.php', array('id'=>$user->id, 'course'=>$course->id));
        $navigation->add(get_string('stats'), $url);
    }
}
Beispiel #16
0
/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function completion_report_extend_navigation($navigation, $course, $context)
{
    global $CFG, $OUTPUT;
    if (has_capability('coursereport/completion:view', $context)) {
        $completion = new completion_info($course);
        if ($completion->is_enabled() && $completion->has_criteria()) {
            $url = new moodle_url('/course/report/completion/index.php', array('course' => $course->id));
            $navigation->add(get_string('pluginname', 'coursereport_completion'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
        }
    }
}
Beispiel #17
0
/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function report_competency_extend_navigation_course($navigation, $course, $context)
{
    if (!get_config('core_competency', 'enabled')) {
        return;
    }
    if (has_capability('moodle/competency:coursecompetencyview', $context)) {
        $url = new moodle_url('/report/competency/index.php', array('id' => $course->id));
        $name = get_string('pluginname', 'report_competency');
        $navigation->add($name, $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
    }
}
Beispiel #18
0
/**
 * 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 && has_capability('tool/monitor:subscribe', $coursecontext)) {
        $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);
        }
    }
}
Beispiel #19
0
/**
 * This function extends the course navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $user
 * @param stdClass $course The course to object for the report
 */
function report_comments_extend_navigation_user($navigation, $user, $course)
{
    global $CFG;
    $context = context_course::instance($course->id);
    if (has_capability('report/comments:view', $context)) {
        if ($CFG->usecomments) {
            $url = new moodle_url('/report/comments/index.php', array('course' => $course->id, 'id' => $user->id));
            $navigation->add(get_string('comments'), $url);
        }
    }
}
Beispiel #20
0
 /**
  * Returns enrolment instance manage link.
  *
  * By defaults looks for manage.php file and tests for manage capability.
  *
  * @param navigation_node $instancesnode
  * @param stdClass $instance
  * @return moodle_url;
  */
 public function add_course_navigation($instancesnode, stdClass $instance)
 {
     if ($instance->enrol !== 'manual') {
         throw new coding_exception('Invalid enrol instance type!');
     }
     $context = context_course::instance($instance->courseid);
     if (has_capability('enrol/manual:config', $context)) {
         $managelink = new moodle_url('/enrol/manual/edit.php', array('courseid' => $instance->courseid));
         $instancesnode->add($this->get_instance_name($instance), $managelink, navigation_node::TYPE_SETTING);
     }
 }
Beispiel #21
0
function booktool_importhtml_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode)
{
    global $USER, $PAGE, $CFG, $DB, $OUTPUT;
    if ($PAGE->cm->modname !== 'book') {
        return;
    }
    if (empty($PAGE->cm->context)) {
        $PAGE->cm->context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->instance);
    }
    if (has_capability('booktool/importhtml:import', $PAGE->cm->context)) {
        $url = new moodle_url('/mod/book/tool/importhtml/index.php', array('id' => $PAGE->cm->id));
        $booknode->add(get_string('import', 'booktool_importhtml'), $url, navigation_node::TYPE_SETTING, null, null, null);
    }
}
/**
 * Change the navigation block and bar only for external users
 * Force course or activity navigation and modify CSS also
 * Please note that this function is only called in pages where the navigation block is present
 *
 * @global moodle_user $USER
 * @global moodle_database $DB
 * @param navigation_node $nav Current navigation object
 */
function local_ltiprovider_extends_navigation($nav)
{
    global $CFG, $USER, $PAGE, $SESSION, $ME;
    // Check capabilities for tool providers
    // Only for Moodle < 2.3 versions
    if ($CFG->version < 2012062500 and $PAGE->course->id and $PAGE->course->id != SITEID and has_capability('local/ltiprovider:view', $PAGE->context)) {
        $ltiurl = new moodle_url('/local/ltiprovider/index.php', array('courseid' => $PAGE->course->id));
        $coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE);
        $coursenode->add(get_string('pluginname', 'local_ltiprovider'), $ltiurl, $nav::TYPE_CONTAINER, null, 'ltiprovider' . $PAGE->course->id);
    }
    if (isset($USER) and isset($USER->auth) and strpos($USER->username, 'ltiprovider') === 0) {
        // Force course or activity navigation
        if (isset($SESSION->ltiprovider) and $SESSION->ltiprovider->forcenavigation) {
            $context = $SESSION->ltiprovider->context;
            $urltogo = '';
            if ($context->contextlevel == CONTEXT_COURSE and $PAGE->course->id != $SESSION->ltiprovider->courseid) {
                $urltogo = new moodle_url('/course/view.php', array('id' => $SESSION->ltiprovider->courseid));
            } else {
                if ($context->contextlevel == CONTEXT_MODULE and $PAGE->context->id != $context->id) {
                    $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
                    $urltogo = new moodle_url('/mod/' . $cm->modname . '/view.php', array('id' => $cm->id));
                }
            }
            // Special case, user policy, we don't have to do nothing to avoid infinites loops.
            if (strpos($ME, 'user/policy.php')) {
                return;
            }
            if ($urltogo) {
                redirect($urltogo);
            }
        }
        // Delete all the navigation nodes except the course one
        if ($coursenode = $nav->find($PAGE->course->id, $nav::TYPE_COURSE)) {
            foreach (array('myprofile', 'users', 'site', 'home', 'myhome', 'mycourses', 'courses', '1') as $nodekey) {
                if ($node = $nav->get($nodekey)) {
                    $node->remove();
                }
            }
            $nav->children->add($coursenode);
        }
        // Custom CSS
        if (isset($SESSION->ltiprovider) and !$PAGE->requires->is_head_done()) {
            $PAGE->requires->css(new moodle_url('/local/ltiprovider/styles.php', array('id' => $SESSION->ltiprovider->id)));
        } else {
            $url = new moodle_url('/local/ltiprovider/styles.js.php', array('id' => $SESSION->ltiprovider->id, 'rand' => rand(0, 1000)));
            $PAGE->requires->js($url);
        }
    }
}
Beispiel #23
0
/**
 * This function extends the course navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $user
 * @param stdClass $course The course to object for the report
 */
function report_usersessions_extend_navigation_user($navigation, $user, $course)
{
    global $USER;
    if (isguestuser() or !isloggedin()) {
        return;
    }
    if (\core\session\manager::is_loggedinas() or $USER->id != $user->id) {
        // No peeking at somebody else's sessions!
        return;
    }
    $context = context_user::instance($USER->id);
    if (has_capability('report/usersessions:manageownsessions', $context)) {
        $navigation->add(get_string('navigationlink', 'report_usersessions'), new moodle_url('/report/usersessions/user.php'), $navigation::TYPE_SETTING);
    }
}
Beispiel #24
0
function booktool_exportimscp_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode)
{
    global $USER, $PAGE, $CFG, $DB, $OUTPUT;
    if ($PAGE->cm->modname !== 'book') {
        return;
    }
    if (empty($PAGE->cm->context)) {
        $PAGE->cm->context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->instance);
    }
    if (has_capability('booktool/exportimscp:export', $PAGE->cm->context)) {
        $url = new moodle_url('/mod/book/tool/exportimscp/index.php', array('id' => $PAGE->cm->id));
        $icon = new pix_icon('generate', '', 'booktool_exportimscp', array('class' => 'icon'));
        $booknode->add(get_string('generateimscp', 'booktool_exportimscp'), $url, navigation_node::TYPE_SETTING, null, null, $icon);
    }
}
Beispiel #25
0
/**
 * 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, $SITE;
    // Don't show the setting if the event monitor isn't turned on. No access to other peoples subscriptions.
    if (get_config('tool_monitor', 'enablemonitor') && $USER->id == $user->id) {
        // Now let's check to see if the user has any courses / site rules that they can subscribe to.
        if ($courses = tool_monitor_get_user_courses()) {
            $url = new moodle_url('/admin/tool/monitor/index.php');
            $subsnode = navigation_node::create(get_string('managesubscriptions', 'tool_monitor'), $url, navigation_node::TYPE_SETTING, null, 'monitor', new pix_icon('i/settings', ''));
            if (isset($subsnode) && !empty($navigation)) {
                $navigation->add_node($subsnode);
            }
        }
    }
}
Beispiel #26
0
/**
 * Adds a recycle bin link to the course admin menu.
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param context $context The context of the course
 * @return void|null return null if we don't want to display the node.
 */
function tool_recyclebin_extend_navigation_category_settings($navigation, $context)
{
    global $PAGE;
    // Check if it is enabled.
    if (!\tool_recyclebin\category_bin::is_enabled()) {
        return null;
    }
    $categorybin = new \tool_recyclebin\category_bin($context->instanceid);
    // Check we can view the recycle bin.
    if (!$categorybin->can_view()) {
        return null;
    }
    $url = null;
    $settingnode = null;
    // Add a link to the category recyclebin.
    $url = new moodle_url('/admin/tool/recyclebin/index.php', array('contextid' => $context->id));
    // If we are set to auto-hide, check the number of items.
    $autohide = get_config('tool_recyclebin', 'autohide');
    if ($autohide) {
        $items = $categorybin->get_items();
        if (empty($items)) {
            return null;
        }
    }
    // Add the recyclebin link.
    $pluginname = get_string('pluginname', 'tool_recyclebin');
    $node = navigation_node::create($pluginname, $url, navigation_node::NODETYPE_LEAF, 'tool_recyclebin', 'tool_recyclebin', new pix_icon('trash', $pluginname, 'tool_recyclebin'));
    if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
        $node->make_active();
    }
    $navigation->add_node($node);
}
Beispiel #27
0
/**
 * Adds module specific settings to the settings block
 *
 * @param settings_navigation $settings The settings navigation object
 * @param navigation_node $node The node to add module settings to
 */
function booktool_print_extend_settings_navigation(settings_navigation $settings, navigation_node $node)
{
    global $USER, $PAGE, $CFG, $DB, $OUTPUT;
    $params = $PAGE->url->params();
    if (empty($params['id']) or empty($params['chapterid'])) {
        return;
    }
    if (has_capability('booktool/print:print', $PAGE->cm->context)) {
        $url1 = new moodle_url('/mod/book/tool/print/index.php', array('id' => $params['id']));
        $url2 = new moodle_url('/mod/book/tool/print/index.php', array('id' => $params['id'], 'chapterid' => $params['chapterid']));
        $action = new action_link($url1, get_string('printbook', 'booktool_print'), new popup_action('click', $url1));
        $node->add(get_string('printbook', 'booktool_print'), $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('book', '', 'booktool_print', array('class' => 'icon')));
        $action = new action_link($url2, get_string('printchapter', 'booktool_print'), new popup_action('click', $url2));
        $node->add(get_string('printchapter', 'booktool_print'), $action, navigation_node::TYPE_SETTING, null, null, new pix_icon('chapter', '', 'booktool_print', array('class' => 'icon')));
    }
}
Beispiel #28
0
/**
* Sets up the main navigation
* @param settingsnav $settingsnav navigation settings object
* @param context $context Context of the form
*/
function local_metadata_extends_settings_navigation($settingsnav, $context)
{
    global $CFG, $PAGE, $USER;
    // Setup navigation for Admin metadata
    if (is_null($PAGE->course)) {
        //return;
    } else {
        if ($categorynode = $settingsnav->find('categorysettings', null)) {
            $url = new moodle_url('/local/metadata/admview_knowledge.php', array('categoryid' => $PAGE->category->id));
            $foonode = navigation_node::create(get_string('manage_pluginname', 'local_metadata'), $url, navigation_node::NODETYPE_LEAF, 'metadata', 'metadata', new pix_icon('i/report', ''));
            if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
                $foonode->make_active();
            }
            $categorynode->add_node($foonode);
            //$categorynode->add(get_string('manage_pluginname', 'local_metadata'), $url, self::TYPE_SETTING, null, 'permissions', new pix_icon('i/permissions', ''));
        }
    }
    // Only add this settings item on non-site course pages.
    if (!$PAGE->course or $PAGE->course->id == 1) {
        return;
    }
    // TODO: Only let users with the appropriate capability see this settings item.
    //if (!has_capability('local/metadata:ins_view', context_course::instance($PAGE->course->id))) {
    //    return;
    //}
    if ($settingnode = $settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) {
        $url = new moodle_url('/local/metadata/insview_general.php', array('id' => $PAGE->course->id));
        // TODO: Should change the name to something more descriptive
        $foonode = navigation_node::create(get_string('ins_pluginname', 'local_metadata'), $url, navigation_node::NODETYPE_LEAF, 'metadata', 'metadata', new pix_icon('i/report', ''));
        if ($PAGE->url->compare($url, URL_MATCH_BASE)) {
            $foonode->make_active();
        }
        $settingnode->add_node($foonode);
    }
}
Beispiel #29
0
/**
 * This function extends the category navigation to add learning plan links.
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param context $coursecategorycontext The context of the course category
 */
function tool_lp_extend_navigation_category_settings($navigation, $coursecategorycontext)
{
    if (!get_config('core_competency', 'enabled')) {
        return false;
    }
    // We check permissions before renderring the links.
    $templatereadcapability = \core_competency\template::can_read_context($coursecategorycontext);
    $competencyreadcapability = \core_competency\competency_framework::can_read_context($coursecategorycontext);
    if (!$templatereadcapability && !$competencyreadcapability) {
        return false;
    }
    // The link to the learning plan page.
    if ($templatereadcapability) {
        $title = get_string('templates', 'tool_lp');
        $path = new moodle_url("/admin/tool/lp/learningplans.php", array('pagecontextid' => $coursecategorycontext->id));
        $settingsnode = navigation_node::create($title, $path, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/competencies', ''));
        if (isset($settingsnode)) {
            $navigation->add_node($settingsnode);
        }
    }
    // The link to the competency frameworks page.
    if ($competencyreadcapability) {
        $title = get_string('competencyframeworks', 'tool_lp');
        $path = new moodle_url("/admin/tool/lp/competencyframeworks.php", array('pagecontextid' => $coursecategorycontext->id));
        $settingsnode = navigation_node::create($title, $path, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/competencies', ''));
        if (isset($settingsnode)) {
            $navigation->add_node($settingsnode);
        }
    }
}
 public function test_node_remove_class()
 {
     $this->setup_node();
     $this->node->add_class('testclass');
     $this->assertTrue($this->node->remove_class('testclass'));
     $this->assertNotContains('testclass', $this->node->classes);
 }