Permalink
Browse files

MDL-33017 navigation: added current course and simplified loading

  • Loading branch information...
Sam Hemelryk
Sam Hemelryk committed Nov 3, 2012
1 parent 6caf3f5 commit 58b602da8e8a554cca4f406fa15091603589d64f
Showing with 194 additions and 221 deletions.
  1. +12 −2 blocks/navigation/yui/navigation/navigation.js
  2. +9 −3 lib/ajax/getnavbranch.php
  3. +173 −216 lib/navigationlib.php
@@ -425,7 +425,7 @@ BRANCH.prototype = {
this.addChild(object.children[i]);
}
}
- if (this.get('type') == 10 && coursecount >= M.block_navigation.courselimit) {
+ if ((this.get('type') == 10 || this.get('type') == 0) && coursecount >= M.block_navigation.courselimit) {
this.addViewAllCoursesChild(this);
}
this.get('tree').toggleExpansion({target:this.node});
@@ -468,10 +468,20 @@ BRANCH.prototype = {
* Add a link to view all courses in a category
*/
addViewAllCoursesChild: function(branch) {
+ var url = null;
+ if (branch.get('type') == 0 ) {
+ if (branch.get('key') == 'mycourses') {
+ url = M.cfg.wwwroot+'/my';
+ } else {
+ url = M.cfg.wwwroot+'/course/index.php';
+ }
+ } else {
+ url = M.cfg.wwwroot+'/course/category.php?id='+branch.get('key');
+ }
branch.addChild({
name : M.str.moodle.viewallcourses,
title : M.str.moodle.viewallcourses,
- link : M.cfg.wwwroot+'/course/category.php?id='+branch.get('key'),
+ link : url,
haschildren : false,
icon : {'pix':"i/navigationitem",'component':'moodle'}
});
View
@@ -36,7 +36,7 @@
// Start buffer capture so that we can `remove` any errors
ob_start();
// Require id This is the key for whatever branch we want to get
- $branchid = required_param('id', PARAM_INT);
+ $branchid = required_param('id', PARAM_ALPHANUM);
// This identifies the type of the branch we want to get
$branchtype = required_param('type', PARAM_INT);
// This identifies the block instance requesting AJAX extension
@@ -87,8 +87,14 @@
}
$converter = new navigation_json();
- // Find the actuall branch we are looking for
- $branch = $navigation->find($branchid, $branchtype);
+ // Find the actual branch we are looking for
+ if ($branchtype != 0) {
+ $branch = $navigation->find($branchid, $branchtype);
+ } else if ($branchid === 'mycourses' || $branchid === 'courses') {
+ $branch = $navigation->find($branchid, navigation_node::TYPE_ROOTNODE);
+ } else {
+ throw new coding_exception('Invalid branch type/id passed to AJAX call to load branches.');
+ }
// Remove links to categories if required.
if (!$linkcategories) {
Oops, something went wrong.

0 comments on commit 58b602d

Please sign in to comment.