Skip to content

Commit

Permalink
Merge branch 'MDL-59140_master' of git://github.com/markn86/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Jun 14, 2017
2 parents 736973d + c8f2e0e commit 5699070
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion admin/settings/appearance.php
Expand Up @@ -179,7 +179,8 @@
'idnumber' => new lang_string('sort_idnumber', 'admin'),
);
$temp->add(new admin_setting_configselect('navsortmycoursessort', new lang_string('navsortmycoursessort', 'admin'), new lang_string('navsortmycoursessort_help', 'admin'), 'sortorder', $sortoptions));
$temp->add(new admin_setting_configtext('navcourselimit',new lang_string('navcourselimit','admin'),new lang_string('confignavcourselimit', 'admin'),20,PARAM_INT));
$temp->add(new admin_setting_configtext('navcourselimit', new lang_string('navcourselimit', 'admin'),
new lang_string('confignavcourselimit', 'admin'), 10, PARAM_INT));
$temp->add(new admin_setting_configcheckbox('usesitenameforsitepages', new lang_string('usesitenameforsitepages', 'admin'), new lang_string('configusesitenameforsitepages', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('linkadmincategories', new lang_string('linkadmincategories', 'admin'), new lang_string('linkadmincategories_help', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('linkcoursesections', new lang_string('linkcoursesections', 'admin'), new lang_string('linkcoursesections_help', 'admin'), 0));
Expand Down
2 changes: 1 addition & 1 deletion lang/en/admin.php
Expand Up @@ -274,7 +274,7 @@
$string['configmycoursesperpage'] = 'Maximum number of courses to display in any list of a user\'s own courses';
$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['confignavcourselimit'] = 'Limits the number of courses shown to the user in the navigation.';
$string['confignavshowallcourses'] = 'This setting determines whether users who are enrolled in courses can see Courses (listing all courses) in the navigation, in addition to My Courses (listing courses in which they are enrolled).';
$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['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). This setting will also be used as the envelope sender when sending email.';
Expand Down
10 changes: 10 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -2877,5 +2877,15 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2017061201.00);
}

if ($oldversion < 2017061301.00) {
// Check if the value of 'navcourselimit' is set to the old default value, if so, change it to the new default.
if ($CFG->navcourselimit == 20) {
set_config('navcourselimit', 10);
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2017061301.00);
}

return true;
}
19 changes: 17 additions & 2 deletions lib/navigationlib.php
Expand Up @@ -84,6 +84,8 @@ class navigation_node implements renderable {
const COURSE_MY = 1;
/** var int Course the current user is currently viewing */
const COURSE_CURRENT = 2;
/** var string The course index page navigation node */
const COURSE_INDEX_PAGE = 'courseindexpage';

/** @var int Parameter to aid the coder in tracking [optional] */
public $id = null;
Expand Down Expand Up @@ -430,7 +432,7 @@ public function find($key, $type) {
public function build_flat_navigation_list(flat_navigation $nodes, $showdivider = false) {
if ($this->showinflatnavigation) {
$indent = 0;
if ($this->type == self::TYPE_COURSE) {
if ($this->type == self::TYPE_COURSE || $this->key == self::COURSE_INDEX_PAGE) {
$indent = 1;
}
$flat = new flat_navigation_node($this, $indent);
Expand Down Expand Up @@ -2892,6 +2894,9 @@ public function find($key, $type) {
*/
protected function load_courses_enrolled() {
global $CFG;

$limit = (int) $CFG->navcourselimit;

$sortorder = 'visible DESC';
// Prevent undefined $CFG->navsortmycoursessort errors.
if (empty($CFG->navsortmycoursessort)) {
Expand All @@ -2900,7 +2905,9 @@ protected function load_courses_enrolled() {
// Append the chosen sortorder.
$sortorder = $sortorder . ',' . $CFG->navsortmycoursessort . ' ASC';
$courses = enrol_get_my_courses('*', $sortorder);
if (count($courses) && $this->show_my_categories()) {
$numcourses = count($courses);
$courses = array_slice($courses, 0, $limit);
if ($numcourses && $this->show_my_categories()) {
// Generate an array containing unique values of all the courses' categories.
$categoryids = array();
foreach ($courses as $course) {
Expand Down Expand Up @@ -2956,6 +2963,14 @@ protected function load_courses_enrolled() {
foreach ($courses as $course) {
$this->add_course($course, false, self::COURSE_MY);
}
// Show a link to the course page if there are more courses the user is enrolled in.
if ($numcourses > $limit) {
// Adding hash to URL so the link is not highlighted in the navigation when clicked.
$url = new moodle_url('/course/index.php#');
$parent = $this->rootnodes['mycourses'];
$coursenode = $parent->add(get_string('morenavigationlinks'), $url, self::TYPE_CUSTOM, null, self::COURSE_INDEX_PAGE);
$coursenode->showinflatnavigation = true;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion version.php
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2017061300.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017061301.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.

Expand Down

0 comments on commit 5699070

Please sign in to comment.