Merge branch 'MDL-59140_master' of git://github.com/markn86/moodle

This commit is contained in:
Dan Poltawski 2017-06-13 13:23:28 +01:00
commit 569907002f
5 changed files with 31 additions and 5 deletions

View File

@ -179,7 +179,8 @@ preferences,moodle|/user/preferences.php|preferences',
'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));

View File

@ -274,7 +274,7 @@ $string['configmodchooserdefault'] = 'Should the activity chooser be presented t
$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.';

View File

@ -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;
}

View File

@ -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;
@ -430,7 +432,7 @@ class navigation_node implements renderable {
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);
@ -2892,6 +2894,9 @@ class global_navigation extends navigation_node {
*/
protected function load_courses_enrolled() {
global $CFG;
$limit = (int) $CFG->navcourselimit;
$sortorder = 'visible DESC';
// Prevent undefined $CFG->navsortmycoursessort errors.
if (empty($CFG->navsortmycoursessort)) {
@ -2900,7 +2905,9 @@ class global_navigation extends navigation_node {
// 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) {
@ -2956,6 +2963,14 @@ class global_navigation extends navigation_node {
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;
}
}
}

View File

@ -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.