Merge branch 'MDL-76414-main' of https://github.com/yusufwib01/moodle
This commit is contained in:
@@ -72,6 +72,12 @@ class primary extends view {
|
||||
}
|
||||
}
|
||||
|
||||
// Add the calendar link only for guest users.
|
||||
if (isguestuser()) {
|
||||
$this->add(get_string('calendar', 'calendar'), new \moodle_url('/calendar/view.php?view=month'), self::TYPE_ROOTNODE,
|
||||
null, 'calendar');
|
||||
}
|
||||
|
||||
$showsiteadminnode = empty($this->page->theme->removedprimarynavitems) ||
|
||||
!in_array('siteadminnode', $this->page->theme->removedprimarynavitems);
|
||||
|
||||
@@ -133,6 +139,10 @@ class primary extends view {
|
||||
if ($this->context->contextlevel == CONTEXT_COURSECAT || $node->search_for_active_node(URL_MATCH_EXACT)) {
|
||||
$activekey = 'siteadminnode';
|
||||
}
|
||||
} else if (in_array('calendar', $children) && $node = $this->find('calendar', self::TYPE_ROOTNODE)) {
|
||||
if ($node->search_for_active_node(URL_MATCH_BASE)) {
|
||||
$activekey = 'calendar';
|
||||
}
|
||||
}
|
||||
|
||||
if ($activekey && $activenode = $this->find($activekey, null)) {
|
||||
|
||||
@@ -61,7 +61,7 @@ final class primary_test extends \advanced_testcase {
|
||||
*/
|
||||
public static function setting_initialise_provider(): array {
|
||||
return [
|
||||
'Testing as a guest user' => ['guest', ['home']],
|
||||
'Testing as a guest user' => ['guest', ['home', 'calendar']],
|
||||
'Testing as an admin' => ['admin', ['home', 'myhome', 'mycourses', 'siteadminnode']],
|
||||
'Testing as a regular user' => ['user', ['home', 'myhome', 'mycourses']]
|
||||
];
|
||||
|
||||
@@ -58,10 +58,11 @@ Feature: Primary navigation
|
||||
And I should see "Dashboard" in the "page-header" "region"
|
||||
|
||||
@theme_boost
|
||||
Scenario: Guest users can only see the Home item in the primary navigation menu
|
||||
Scenario: Guest users can only see the Home and Calendar items in the primary navigation menu
|
||||
Given I log in as "guest"
|
||||
When I am on site homepage
|
||||
Then I should see "Home" in the ".primary-navigation" "css_element"
|
||||
And I should see "Calendar" in the ".primary-navigation" "css_element"
|
||||
And I should not see "Dashboard" in the ".primary-navigation" "css_element"
|
||||
And I should not see "My courses" in the ".primary-navigation" "css_element"
|
||||
And I should not see "Site administration" in the ".primary-navigation" "css_element"
|
||||
|
||||
Reference in New Issue
Block a user