From 904291f21fac6783fee90a2d0c9b23882522b6e7 Mon Sep 17 00:00:00 2001 From: Issam Taboubi Date: Mon, 28 Sep 2015 15:48:20 -0400 Subject: [PATCH] MDL-51557 tool_lp: Add learning plans to the administration categories --- admin/tool/lp/lib.php | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/admin/tool/lp/lib.php b/admin/tool/lp/lib.php index e91a186074c..1dc32cca2a2 100644 --- a/admin/tool/lp/lib.php +++ b/admin/tool/lp/lib.php @@ -73,3 +73,48 @@ function tool_lp_myprofile_navigation(core_user\output\myprofile\tree $tree, $us get_string('learningplans', 'tool_lp'), null, $url); $tree->add_node($node); } + +/** + * 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) { + // We check permissions before renderring the links. + $templatemanagecapability = has_capability('tool/lp:templatemanage', $coursecategorycontext); + $competencymanagecapability = has_capability('tool/lp:competencymanage', $coursecategorycontext); + if (!$templatemanagecapability && !$competencymanagecapability) { + return false; + } + + // The link to the learning plan page. + if ($templatemanagecapability) { + $title = get_string('learningplans', '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('competency', '', 'tool_lp')); + if (isset($settingsnode)) { + $navigation->add_node($settingsnode); + } + } + + // The link to the competency frameworks page. + if ($competencymanagecapability) { + $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('competency', '', 'tool_lp')); + if (isset($settingsnode)) { + $navigation->add_node($settingsnode); + } + } +} \ No newline at end of file