mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'wip-MDL-32975-m25' of git://github.com/samhemelryk/moodle
This commit is contained in:
commit
2673254919
@ -114,6 +114,13 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$temp->add(new admin_setting_configcheckbox('navshowcategories', new lang_string('navshowcategories', 'admin'), new lang_string('confignavshowcategories', 'admin'), 1));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowmycoursecategories', new lang_string('navshowmycoursecategories', 'admin'), new lang_string('navshowmycoursecategories_help', 'admin'), 0));
|
||||
$temp->add(new admin_setting_configcheckbox('navshowallcourses', new lang_string('navshowallcourses', 'admin'), new lang_string('confignavshowallcourses', 'admin'), 0));
|
||||
$sortoptions = array(
|
||||
'sortorder' => new lang_string('sort_sortorder', 'admin'),
|
||||
'fullname' => new lang_string('sort_fullname', 'admin'),
|
||||
'shortname' => new lang_string('sort_shortname', 'admin'),
|
||||
'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_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'), 0));
|
||||
|
@ -747,6 +747,8 @@ $string['navshowallcourses'] = 'Show all courses';
|
||||
$string['navshowcategories'] = 'Show course categories';
|
||||
$string['navshowmycoursecategories'] = 'Show my course categories';
|
||||
$string['navshowmycoursecategories_help'] = 'If enabled courses in the users my courses branch will be shown in categories.';
|
||||
$string['navsortmycoursessort'] = 'Sort my courses';
|
||||
$string['navsortmycoursessort_help'] = 'Determines how the courses displayed within the My courses branch on the navigation will be sorted. By default sortorder it used.';
|
||||
$string['neverdeleteruns'] = 'Never delete runs';
|
||||
$string['nobookmarksforuser'] = 'You do not have any bookmarks.';
|
||||
$string['nodatabase'] = 'No database';
|
||||
@ -971,6 +973,10 @@ $string['sitesectionhelp'] = 'If selected, a topic section will be displayed on
|
||||
$string['slasharguments'] = 'Use slash arguments';
|
||||
$string['smartpix'] = 'Smart pix search';
|
||||
$string['soaprecommended'] = 'Installing the optional soap extension is useful for web services and some contrib modules.';
|
||||
$string['sort_fullname'] = 'Fullname';
|
||||
$string['sort_idnumber'] = 'ID Number';
|
||||
$string['sort_shortname'] = 'Shortname';
|
||||
$string['sort_sortorder'] = 'Sort order';
|
||||
$string['spellengine'] = 'Spell engine';
|
||||
$string['spelllanguagelist'] = 'Spell language list';
|
||||
$string['splrequired'] = 'The SPL PHP extension is now required by Moodle.';
|
||||
|
@ -1076,7 +1076,7 @@ class global_navigation extends navigation_node {
|
||||
$this->rootnodes['site'] = $this->add_course($SITE);
|
||||
$this->rootnodes['myprofile'] = $this->add(get_string('myprofile'), null, self::TYPE_USER, null, 'myprofile');
|
||||
$this->rootnodes['currentcourse'] = $this->add(get_string('currentcourse'), null, self::TYPE_ROOTNODE, null, 'currentcourse');
|
||||
$this->rootnodes['mycourses'] = $this->add(get_string('mycourses'), new moodle_url('/my'), self::TYPE_ROOTNODE, null, 'mycourses');
|
||||
$this->rootnodes['mycourses'] = $this->add(get_string('mycourses'), new moodle_url('/my/'), self::TYPE_ROOTNODE, null, 'mycourses');
|
||||
$this->rootnodes['courses'] = $this->add(get_string('courses'), new moodle_url('/course/index.php'), self::TYPE_ROOTNODE, null, 'courses');
|
||||
$this->rootnodes['users'] = $this->add(get_string('users'), null, self::TYPE_ROOTNODE, null, 'users');
|
||||
|
||||
@ -1103,6 +1103,10 @@ class global_navigation extends navigation_node {
|
||||
$this->rootnodes['courses']->isexpandable = true;
|
||||
}
|
||||
|
||||
if ($this->rootnodes['mycourses']->isactive) {
|
||||
$this->load_courses_enrolled();
|
||||
}
|
||||
|
||||
$canviewcourseprofile = true;
|
||||
|
||||
// Next load context specific content into the navigation
|
||||
@ -2570,6 +2574,47 @@ class global_navigation extends navigation_node {
|
||||
}
|
||||
return parent::find($key, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* They've expanded the 'my courses' branch.
|
||||
*/
|
||||
protected function load_courses_enrolled() {
|
||||
global $CFG, $DB;
|
||||
$sortorder = 'visible DESC';
|
||||
// Append the chosen sortorder.
|
||||
$sortorder = $sortorder . ',' . $CFG->navsortmycoursessort . ' ASC';
|
||||
$courses = enrol_get_my_courses(null, $sortorder);
|
||||
if ($this->show_my_categories(true)) {
|
||||
// OK Actually we are loading categories. We only want to load categories that have a parent of 0.
|
||||
// In order to make sure we load everything required we must first find the categories that are not
|
||||
// base categories and work out the bottom category in thier path.
|
||||
$categoryids = array();
|
||||
foreach ($courses as $course) {
|
||||
$categoryids[] = $course->category;
|
||||
}
|
||||
$categoryids = array_unique($categoryids);
|
||||
list($sql, $params) = $DB->get_in_or_equal($categoryids);
|
||||
$categories = $DB->get_recordset_select('course_categories', 'id '.$sql.' AND parent <> 0', $params, 'sortorder, id', 'id, path');
|
||||
foreach ($categories as $category) {
|
||||
$bits = explode('/', trim($category->path,'/'));
|
||||
$categoryids[] = array_shift($bits);
|
||||
}
|
||||
$categoryids = array_unique($categoryids);
|
||||
$categories->close();
|
||||
|
||||
// Now we load the base categories.
|
||||
list($sql, $params) = $DB->get_in_or_equal($categoryids);
|
||||
$categories = $DB->get_recordset_select('course_categories', 'id '.$sql.' AND parent = 0', $params, 'sortorder, id');
|
||||
foreach ($categories as $category) {
|
||||
$this->add_category($category, $this->rootnodes['mycourses']);
|
||||
}
|
||||
$categories->close();
|
||||
} else {
|
||||
foreach ($courses as $course) {
|
||||
$this->add_course($course, false, self::COURSE_MY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2696,44 +2741,6 @@ class global_navigation_for_ajax extends global_navigation {
|
||||
return $this->expandable;
|
||||
}
|
||||
|
||||
/**
|
||||
* They've expanded the 'my courses' branch.
|
||||
*/
|
||||
protected function load_courses_enrolled() {
|
||||
global $DB;
|
||||
$courses = enrol_get_my_courses();
|
||||
if ($this->show_my_categories(true)) {
|
||||
// OK Actually we are loading categories. We only want to load categories that have a parent of 0.
|
||||
// In order to make sure we load everything required we must first find the categories that are not
|
||||
// base categories and work out the bottom category in thier path.
|
||||
$categoryids = array();
|
||||
foreach ($courses as $course) {
|
||||
$categoryids[] = $course->category;
|
||||
}
|
||||
$categoryids = array_unique($categoryids);
|
||||
list($sql, $params) = $DB->get_in_or_equal($categoryids);
|
||||
$categories = $DB->get_recordset_select('course_categories', 'id '.$sql.' AND parent <> 0', $params, 'sortorder, id', 'id, path');
|
||||
foreach ($categories as $category) {
|
||||
$bits = explode('/', trim($category->path,'/'));
|
||||
$categoryids[] = array_shift($bits);
|
||||
}
|
||||
$categoryids = array_unique($categoryids);
|
||||
$categories->close();
|
||||
|
||||
// Now we load the base categories.
|
||||
list($sql, $params) = $DB->get_in_or_equal($categoryids);
|
||||
$categories = $DB->get_recordset_select('course_categories', 'id '.$sql.' AND parent = 0', $params, 'sortorder, id');
|
||||
foreach ($categories as $category) {
|
||||
$this->add_category($category, $this->rootnodes['mycourses'], self::TYPE_MY_CATEGORY);
|
||||
}
|
||||
$categories->close();
|
||||
} else {
|
||||
foreach ($courses as $course) {
|
||||
$this->add_course($course, false, self::COURSE_MY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* They've expanded the general 'courses' branch.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user