diff --git a/auth/shibboleth/index.php b/auth/shibboleth/index.php index 2babbfe20ca79..ddb57ffd2a252 100644 --- a/auth/shibboleth/index.php +++ b/auth/shibboleth/index.php @@ -69,8 +69,8 @@ unset($SESSION->wantsurl); /// Just in case } - /// Go to my-moodle page instead of homepage if mymoodleredirect enabled - if (!has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) and !empty($CFG->mymoodleredirect) and !isguestuser()) { + /// Go to my-moodle page instead of homepage if defaulthomepage enabled + if (!has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) and !empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY and !isguestuser()) { if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') { $urltogo = $CFG->wwwroot.'/my/'; } diff --git a/blocks/navigation/block_navigation.php b/blocks/navigation/block_navigation.php index 31daa95a145d5..4258303ecc625 100644 --- a/blocks/navigation/block_navigation.php +++ b/blocks/navigation/block_navigation.php @@ -163,8 +163,13 @@ function get_content() { // Initialise the JS tree object $module = array('name'=>'block_navigation', 'fullpath'=>'/blocks/navigation/navigation.js', 'requires'=>array('core_dock', 'io', 'node', 'dom', 'event-custom', 'json-parse')); - $arguments = array($this->instance->id, array('expansions'=>$expandable, 'instance'=>$this->instance->id, 'candock'=>$this->instance_can_be_docked())); + $limit = 20; + if (!empty($CFG->navcourselimit)) { + $limit = $CFG->navcourselimit; + } + $arguments = array($this->instance->id, array('expansions'=>$expandable, 'instance'=>$this->instance->id, 'candock'=>$this->instance_can_be_docked(), 'courselimit'=>$limit)); $this->page->requires->js_init_call('M.block_navigation.init_add_tree', $arguments, false, $module); + $this->page->requires->string_for_js('viewallcourses','moodle'); // Grab the items to display $renderer = $this->page->get_renderer('block_navigation'); diff --git a/blocks/navigation/navigation.js b/blocks/navigation/navigation.js index e2286162a1ed9..96e730c25040d 100644 --- a/blocks/navigation/navigation.js +++ b/blocks/navigation/navigation.js @@ -38,6 +38,7 @@ M.block_navigation = M.block_navigation || { * @namespace */ classes:{}, + courselimit : 20, /** * This function gets called when the module is first loaded as required by * the YUI.add statement at the bottom of the page. @@ -55,6 +56,9 @@ M.block_navigation = M.block_navigation || { * Add new instance of navigation tree to tree collection */ init_add_tree:function(Y, id, properties) { + if (properties.courselimit) { + this.courselimit = properties.courselimit; + } M.block_navigation.treecollection[id] = new M.block_navigation.classes.tree(Y, id, properties); } }; @@ -174,6 +178,7 @@ M.block_navigation.classes.tree.prototype.load_ajax = function(tid, outcome, arg } } catch (e) { // If we got here then there was an error parsing the result + alert(e.message); } // The branch is empty so class it accordingly args.target.replaceClass('branch', 'emptybranch'); @@ -191,7 +196,6 @@ M.block_navigation.classes.tree.prototype.add_branch = function(branchobj, targe // Make the new branch into an object var branch = new M.block_navigation.classes.branch(this, branchobj); - var childrenul = false; if (depth === 1) { if (!branch.children) { @@ -203,10 +207,23 @@ M.block_navigation.classes.tree.prototype.add_branch = function(branchobj, targe childrenul = branch.inject_into_dom(target); } if (childrenul) { - for (i in branch.children) { + var count = 0; + for (var i in branch.children) { // Add each branch to the tree + if (branch.children[i].type == 20) { + count++; + } this.add_branch(branch.children[i], childrenul, depth+1); } + if (branch.type == 10 && count >= M.block_navigation.courselimit) { + var properties = Array(); + properties['name'] = M.str.moodle.viewallcourses; + properties['title'] = M.str.moodle.viewallcourses; + properties['link'] = M.cfg.wwwroot+'/course/category.php?id='+branch.key; + properties['haschildren'] = false; + properties['icon'] = {'pix':"i/navigationitem",'component':'moodle'}; + this.add_branch(properties, childrenul, depth+1); + } } return true; } diff --git a/lang/en/admin.php b/lang/en/admin.php index b6612655efd52..0793199a44b13 100755 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -267,8 +267,8 @@ $string['configmymoodleredirect'] = 'This setting forces redirects to /my on login for non-admins and replaces the top level site navigation with /my'; $string['configmypagelocked'] = 'This setting prevents the default page from being edited by any non-admins'; $string['confignavcourselimit'] = 'Limits the number of courses shown to the user when they are either not logged in or are not enrolled in any courses.'; -$string['confignavshowallcourses'] = 'Setting this ensures that all courses a user is registered in are shown on the navigation at all times. By default once a user browses to a course only that course is shown on the navigation.'; -$string['confignavshowcategories'] = 'Show course categories in the navigation bar and navigation blocks'; +$string['confignavshowallcourses'] = 'Setting this ensures that all courses on the site are shown in the navigation at all times.'; +$string['confignavshowcategories'] = 'Show course categories in the navigation bar and navigation blocks. This does not occur with courses the user is currently enrolled in, they will still be listed under mycourses without categories.'; $string['confignodefaultuserrolelists'] = 'This setting prevents all users from being returned from the database from deprecated calls of get_course_user, etc., for the site course if the default role provides that access. Check this, if you suffer a performance hit.'; $string['confignonmetacoursesyncroleids'] = 'By default all role assignments from child courses are synchronised to metacourses. Roles that are selected here will not be included in the synchronisation process.'; $string['confignoreplyaddress'] = 'Emails are sometimes sent out on behalf of a user (eg forum posts). The email address you specify here will be used as the "From" address in those cases when the recipients should not be able to reply directly to the user (eg when a user chooses to keep their address private).'; @@ -695,7 +695,7 @@ $string['mysql416required'] = 'MySQL 4.1.16 is the minimum version required for Moodle 1.6 in order to guarantee that all data can be converted to UTF-8 in the future.'; $string['navigationupgrade'] = 'This upgrade introduces two new navigation blocks that will replace these blocks: Administration, Courses, Activities and Participants. If you had set any special permissions on those blocks you should check to make sure everything is behaving as you want it.'; $string['navcourselimit'] = 'Course limit'; -$string['navshowallcourses'] = 'Show all users courses'; +$string['navshowallcourses'] = 'Show all courses'; $string['navshowcategories'] = 'Show course categories'; $string['nobookmarksforuser'] = 'You do not have any bookmarks.'; $string['nodatabase'] = 'No database'; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 228e9a9ff0360..83d4acfe770cb 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -1809,6 +1809,8 @@ $string['valuealreadyused'] = 'This value has already been used.'; $string['version'] = 'Version'; $string['view'] = 'View'; +$string['viewallcourses'] = 'View all courses'; +$string['viewallcoursescategories'] = 'View all courses and categories'; $string['viewfileinpopup'] = 'View file in a popup window'; $string['viewprofile'] = 'View profile'; $string['views'] = 'Views'; diff --git a/lib/navigationlib.php b/lib/navigationlib.php index fe7b57d8bd16f..5148f008e63a3 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -867,6 +867,9 @@ public function initialise() { } $this->mycourses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', null, false, $limit); + $showallcourses = (count($this->mycourses) == 0 || !empty($CFG->navshowallcourses)); + $showcategories = ($showallcourses && !empty($CFG->navshowcategories)); + // Check if any courses were returned. if (count($this->mycourses) > 0) { // Add all of the users courses to the navigation @@ -875,12 +878,12 @@ public function initialise() { } } - $showallcourses = (count($this->mycourses) == 0 || !empty($CFG->navshowallcourses)); - $showcategories = ($showallcourses && !empty($CFG->navshowcategories)); - if ($showcategories) { // Load all categories (ensures we get the base categories) $this->load_all_categories(); + } else if ($showallcourses) { + // Load all courses + $this->load_all_courses(); } // Next load context specific content into the navigation @@ -889,10 +892,6 @@ public function initialise() { case CONTEXT_COURSECAT : // Load the front page course navigation $this->load_course($SITE); - if ($showallcourses) { - // Load all courses - $this->load_all_courses(); - } break; case CONTEXT_BLOCK : case CONTEXT_COURSE : @@ -948,6 +947,22 @@ public function initialise() { break; } + $limit = 20; + if (!empty($CFG->navcourselimit)) { + $limit = $CFG->navcourselimit; + } + if ($showcategories) { + $categories = $this->find_all_of_type(self::TYPE_CATEGORY); + foreach ($categories as &$category) { + if ($category->children->count() >= $limit) { + $url = new moodle_url('/course/category.php', array('id'=>$category->key)); + $category->add(get_string('viewallcourses'), $url, self::TYPE_SETTING); + } + } + } else if ($this->rootnodes['courses']->children->count() >= $limit) { + $this->rootnodes['courses']->add(get_string('viewallcoursescategories'), new moodle_url('/course/index.php'), self::TYPE_SETTING); + } + // Load for the current user $this->load_for_user(); // Load each extending user into the navigation. diff --git a/login/index.php b/login/index.php index fde2041a71ebd..243a85c7419d4 100644 --- a/login/index.php +++ b/login/index.php @@ -187,8 +187,8 @@ unset($SESSION->wantsurl); } - /// Go to my-moodle page instead of homepage if mymoodleredirect enabled - if (!empty($CFG->mymoodleredirect) and !is_siteadmin() and !isguestuser()) { + /// Go to my-moodle page instead of site homepage if defaulthomepage set to homepage_my + if (!empty($CFG->defaulthomepage) && $CFG->defaulthomepage == HOMEPAGE_MY && !is_siteadmin() && !isguestuser()) { if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') { $urltogo = $CFG->wwwroot.'/my/'; }