MDL-72834 Calendar: Move the calendar into the user menu

This commit is contained in:
Huong Nguyen 2021-11-17 10:44:24 +07:00
parent 18b2af60f5
commit 7de559fa2f
11 changed files with 31 additions and 47 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -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);
}
/**

View File

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

View File

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

View File

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

View File

@ -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)) {

View File

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

View File

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