diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index cd69ecc3b79..e39a99a4908 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -38,6 +38,7 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) { // sp new lang_string('customusermenuitems', 'admin'), new lang_string('configcustomusermenuitems', 'admin'), 'grades,grades|/grade/report/mygrades.php|t/grades +calendar,core_calendar|/calendar/view.php?view=month|i/calendar messages,message|/message/index.php|t/message preferences,moodle|/user/preferences.php|t/preferences', PARAM_RAW, diff --git a/admin/tool/uploaduser/tests/behat/upload_users.feature b/admin/tool/uploaduser/tests/behat/upload_users.feature index 0d1cef6e580..c12e3713298 100644 --- a/admin/tool/uploaduser/tests/behat/upload_users.feature +++ b/admin/tool/uploaduser/tests/behat/upload_users.feature @@ -133,12 +133,12 @@ Feature: Upload users # Boost check. And I log in as "jonest" And I am on "Maths" course homepage - And "Calendar" "link" should be visible + And "Private files" "link" should be visible And I log out # Classic check. And I log in as "reznor" And I am on "Maths" course homepage - And "Calendar" "link" should not be visible + And "Private files" "link" should not be visible @javascript Scenario: Upload users setting their user theme when allowuserthemes is false diff --git a/calendar/tests/behat/category_events.feature b/calendar/tests/behat/category_events.feature index 734c7acddc6..93df2e3a300 100644 --- a/calendar/tests/behat/category_events.feature +++ b/calendar/tests/behat/category_events.feature @@ -67,11 +67,7 @@ Feature: Course Category Events @javascript Scenario: Manager of a Category can see all child and parent events in their category Given I log in as "managera" - And I turn editing mode on - # TODO MDL-57120 site "Tags" link not accessible without navigation block. - When I add the "Navigation" block if not present - And I click on "Site pages" "list_item" in the "Navigation" "block" - And I click on "Calendar" "link" in the "Navigation" "block" + When I follow "Calendar" in the user menu Then I should see "FA event" And I should see "DA1 event" And I should see "DA2 event" @@ -80,11 +76,7 @@ Feature: Course Category Events And I should not see "DB2 event" And I log out Given I log in as "managerb" - And I turn editing mode on - # TODO MDL-57120 site "Tags" link not accessible without navigation block. - When I add the "Navigation" block if not present - And I click on "Site pages" "list_item" in the "Navigation" "block" - And I click on "Calendar" "link" in the "Navigation" "block" + And I follow "Calendar" in the user menu Then I should see "FB event" And I should see "DB1 event" And I should see "DB2 event" @@ -95,11 +87,7 @@ Feature: Course Category Events @javascript Scenario: Users enrolled in a course can see all child and parent events in their category Given I log in as "student1" - And I turn editing mode on - # TODO MDL-57120 site "Tags" link not accessible without navigation block. - When I add the "Navigation" block if not present - And I click on "Site pages" "list_item" in the "Navigation" "block" - And I click on "Calendar" "link" in the "Navigation" "block" + When I follow "Calendar" in the user menu Then I should see "FA event" And I should see "DA1 event" And I should see "DA2 event" diff --git a/course/lib.php b/course/lib.php index 13091f1f194..6485dde2216 100644 --- a/course/lib.php +++ b/course/lib.php @@ -4049,7 +4049,6 @@ function course_get_user_navigation_options($context, $course = null) { $options = (object) [ 'badges' => false, 'blogs' => false, - 'calendar' => false, 'competencies' => false, 'grades' => false, 'notes' => false, @@ -4072,7 +4071,6 @@ function course_get_user_navigation_options($context, $course = null) { $options->badges = !empty($CFG->enablebadges) && has_capability('moodle/badges:viewbadges', $sitecontext); $options->tags = !empty($CFG->usetags) && $isloggedin; $options->search = !empty($CFG->enableglobalsearch) && has_capability('moodle/search:query', $sitecontext); - $options->calendar = $isloggedin; } else { // We are in a course, so make sure we use the proper capability (course:viewparticipants). $options->participants = course_can_view_participants($context); diff --git a/course/tests/courselib_test.php b/course/tests/courselib_test.php index 06229494c3f..334acaf54f9 100644 --- a/course/tests/courselib_test.php +++ b/course/tests/courselib_test.php @@ -3191,7 +3191,6 @@ class core_course_courselib_testcase extends advanced_testcase { $this->assertTrue($navoptions->badges); $this->assertTrue($navoptions->tags); $this->assertFalse($navoptions->search); - $this->assertTrue($navoptions->calendar); $this->assertTrue($navoptions->competencies); // Enable global search now. @@ -3216,7 +3215,6 @@ class core_course_courselib_testcase extends advanced_testcase { $this->assertTrue($navoptions->badges); $this->assertTrue($navoptions->tags); $this->assertTrue($navoptions->search); - $this->assertTrue($navoptions->calendar); } /** diff --git a/course/tests/externallib_test.php b/course/tests/externallib_test.php index a2d03e22c4d..16a89ac0584 100644 --- a/course/tests/externallib_test.php +++ b/course/tests/externallib_test.php @@ -2538,7 +2538,7 @@ class externallib_test extends externallib_advanced_testcase { foreach ($course['options'] as $option) { $navoptions->{$option['name']} = $option['available']; } - $this->assertCount(9, $course['options']); + $this->assertCount(8, $course['options']); if ($course['id'] == SITEID) { $this->assertTrue($navoptions->blogs); $this->assertFalse($navoptions->notes); @@ -2547,7 +2547,6 @@ class externallib_test extends externallib_advanced_testcase { $this->assertTrue($navoptions->tags); $this->assertFalse($navoptions->grades); $this->assertFalse($navoptions->search); - $this->assertTrue($navoptions->calendar); $this->assertTrue($navoptions->competencies); } else { $this->assertTrue($navoptions->blogs); @@ -2557,7 +2556,6 @@ class externallib_test extends externallib_advanced_testcase { $this->assertFalse($navoptions->tags); $this->assertTrue($navoptions->grades); $this->assertFalse($navoptions->search); - $this->assertFalse($navoptions->calendar); $this->assertTrue($navoptions->competencies); } } diff --git a/course/upgrade.txt b/course/upgrade.txt index 05c6692a4e9..3cfe32b8caf 100644 --- a/course/upgrade.txt +++ b/course/upgrade.txt @@ -64,6 +64,9 @@ course formats don't have their own renderer. * New course_get_enrolled_courses_for_logged_in_user_from_search which hooks in with external\get_enrolled_courses_by_timeline_classification given COURSE_TIMELINE_SEARCH is set then get_enrolled_courses_by_timeline_classification will deviate to use a string search of enrolled courses. * Class core_course\output\course_module_name is deprecated. Now core_courseformat\output\local\cm\cmname controls inline edit. +* Calendar menu entry is now moved to User menu items, so the following methods will not return the calendar item anymore: + - course_get_user_navigation_options + - core_course_externalcore_course_external::get_user_navigation_options === 3.11 === * A new callback xxx_coursemodule_definition_after_data that allows plugins to extend activity forms after the data is set. diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index d35e55a7035..71f99e39f08 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -3171,5 +3171,23 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2021111700.01); } + if ($oldversion < 2021112600.01) { + + // Get current configuration data. + $currentcustomusermenuitems = str_replace(["\r\n", "\r"], "\n", $CFG->customusermenuitems); + $lines = explode("\n", $currentcustomusermenuitems); + $lines = array_map('trim', $lines); + $calendarcustomusermenu = 'calendar,core_calendar|/calendar/view.php?view=month|i/calendar'; + + if (!in_array($calendarcustomusermenu, $lines)) { + // Add Calendar item to the menu. + array_splice($lines, 1, 0, [$calendarcustomusermenu]); + set_config('customusermenuitems', implode("\n", $lines)); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2021112600.01); + } + return true; } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 87a7a1409e8..8f301959ebe 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -2927,20 +2927,6 @@ class global_navigation extends navigation_node { self::TYPE_SETTING, null, 'search'); } - if ($navoptions->calendar) { - $courseid = $COURSE->id; - $params = array('view' => 'month'); - if ($courseid != $SITE->id) { - $params['course'] = $courseid; - } - - // Calendar - $calendarurl = new moodle_url('/calendar/view.php', $params); - $node = $coursenode->add(get_string('calendar', 'calendar'), $calendarurl, - self::TYPE_CUSTOM, null, 'calendar', new pix_icon('i/calendar', '')); - $node->showinflatnavigation = true; - } - if (isloggedin()) { $usercontext = context_user::instance($USER->id); if (has_capability('moodle/user:manageownfiles', $usercontext)) { diff --git a/mod/chat/tests/behat/chat_calendar_events.feature b/mod/chat/tests/behat/chat_calendar_events.feature index 68aac69e542..164a576709f 100644 --- a/mod/chat/tests/behat/chat_calendar_events.feature +++ b/mod/chat/tests/behat/chat_calendar_events.feature @@ -22,10 +22,7 @@ Feature: Chat calendar entries | activity | name | intro | course | idnumber | schedule | | chat | Test chat name | Test chat description | C1 | chat1 | 0 | And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - # TODO MDL-57120 site "Calendar" link not accessible without navigation block. - And I add the "Navigation" block if not present - Given I click on "Calendar" "link" in the "Navigation" "block" + When I follow "Calendar" in the user menu Then I should not see "Test chat name" Scenario: Create a chat activity and publish the start date to the calendar @@ -33,8 +30,5 @@ Feature: Chat calendar entries | activity | name | intro | course | idnumber | schedule | | chat | Test chat name | Test chat description | C1 | chat1 | 1 | And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - # TODO MDL-57120 site "Calendar" link not accessible without navigation block. - And I add the "Navigation" block if not present - Given I click on "Calendar" "link" in the "Navigation" "block" + When I follow "Calendar" in the user menu Then I should see "Test chat name" diff --git a/version.php b/version.php index 2c8ec8e10b5..6cd4433b078 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2021112600.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2021112600.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. $release = '4.0dev+ (Build: 20211126)'; // Human-friendly version name