Skip to content

Commit

Permalink
MDL-57064 course: Return all properties when getting navigation options
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Nov 22, 2016
1 parent cd4a6b8 commit 84979ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 13 additions & 1 deletion course/lib.php
Expand Up @@ -3707,7 +3707,19 @@ function course_get_user_navigation_options($context, $course = null) {
$sitecontext = context_system::instance();
}

$options = new stdClass;
// Sets defaults for all options.
$options = (object) [
'badges' => false,
'blogs' => false,
'calendar' => false,
'competencies' => false,
'grades' => false,
'notes' => false,
'participants' => false,
'search' => false,
'tags' => false,
];

$options->blogs = !empty($CFG->enableblogs) &&
($CFG->bloglevel == BLOG_GLOBAL_LEVEL ||
($CFG->bloglevel == BLOG_SITE_LEVEL and ($isloggedin and !$isguestuser)))
Expand Down
8 changes: 8 additions & 0 deletions course/tests/courselib_test.php
Expand Up @@ -2935,12 +2935,20 @@ public function test_course_get_user_navigation_options_for_frontpage() {
$this->assertTrue($navoptions->tags);
$this->assertFalse($navoptions->search);
$this->assertTrue($navoptions->calendar);
$this->assertTrue($navoptions->competencies);

// Enable global search now.
$CFG->enableglobalsearch = 1;
$navoptions = course_get_user_navigation_options($context, $course);
$this->assertTrue($navoptions->search);

// Disable competencies.
$oldcompetencies = get_config('core_competency', 'enabled');
set_config('enabled', false, 'core_competency');
$navoptions = course_get_user_navigation_options($context, $course);
$this->assertFalse($navoptions->competencies);
set_config('enabled', $oldcompetencies, 'core_competency');

// Now try with a standard user.
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
Expand Down

0 comments on commit 84979ab

Please sign in to comment.