MDL-66612 calendar: Change global events to site events

AMOS BEGIN
 CPY [category,moodle],[category,calendar]
 CPY [site,notes],[eventtypesite,calendar]
 CPY [site,moodle],[site,calendar]
 MOV [typesite,moodle],[siteevent,calendar]
AMOS END
This commit is contained in:
Pau Ferrer Ocaña 2019-09-06 08:46:28 +02:00
parent e75b4e41b1
commit 375d82cafc
22 changed files with 56 additions and 42 deletions

View File

@ -26,7 +26,7 @@ Feature: Enable the calendar block in a course and test it's functionality
Then "Calendar" "block" should exist
@javascript
Scenario: View a global event in the calendar block
Scenario: View a site event in the calendar block
Given I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |
@ -52,7 +52,7 @@ Feature: Enable the calendar block in a course and test it's functionality
| id_eventtype | Course |
| id_name | Course Event |
And I am on "Course 1" course homepage
And I follow "Hide global events"
And I follow "Hide site events"
And I hover over today in the calendar
Then I should not see "Site Event"
And I should see "Course Event"

View File

@ -5,7 +5,7 @@ Feature: Enable the calendar block in a course
I can add the calendar block to a course
@javascript
Scenario: View a global event in the calendar block in a course
Scenario: View a site event in the calendar block in a course
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |

View File

@ -5,7 +5,7 @@ Feature: View a site event on the dashboard
I can view the event in the calendar
@javascript
Scenario: View a global event in the calendar block on the dashboard
Scenario: View a site event in the calendar block on the dashboard
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |

View File

@ -5,7 +5,7 @@ Feature: Enable the calendar block on the site front page
I can add the calendar block on the site front page
@javascript
Scenario: View a global event in the calendar block on the front page
Scenario: View a site event in the calendar block on the front page
Given the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@example.com | S1 |

View File

@ -16,7 +16,7 @@ Feature: Enable the upcoming events block in a course
| teacher1 | C1 | editingteacher |
@javascript
Scenario: View a global event in the calendar block
Scenario: View a site event in the calendar block
Given I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |

View File

@ -9,7 +9,7 @@ Feature: View a upcoming site event on the dashboard
| student1 | Student | 1 | student1@example.com | S1 |
@javascript
Scenario: View a global event in the upcoming events block on the dashboard
Scenario: View a site event in the upcoming events block on the dashboard
Given I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |

View File

@ -10,7 +10,7 @@ Feature: View a site event on the frontpage
| teacher1 | Teacher | 1 | teacher1@example.com | T1 |
@javascript
Scenario: View a global event in the upcoming events block on the frontpage
Scenario: View a site event in the upcoming events block on the frontpage
Given I log in as "admin"
And I create a calendar event with form data:
| id_eventtype | Site |

View File

@ -55,7 +55,7 @@ class event_icon_exporter extends exporter {
$user = $event->get_user();
$userid = $user ? $user->get('id') : null;
$isactivityevent = !empty($coursemodule);
$isglobalevent = ($course && $courseid == SITEID);
$issiteevent = ($course && $courseid == SITEID);
$iscategoryevent = ($category && !empty($categoryid));
$iscourseevent = ($course && !empty($courseid) && $courseid != SITEID && empty($groupid));
$isgroupevent = ($group && !empty($groupid));
@ -70,7 +70,7 @@ class event_icon_exporter extends exporter {
} else {
$alttext = get_string('activityevent', 'calendar');
}
} else if ($isglobalevent) {
} else if ($issiteevent) {
$key = 'i/siteevent';
$component = 'core';
$alttext = get_string('typesite', 'calendar');

View File

@ -57,19 +57,19 @@ trait eventtype {
$options = [];
if (!empty($eventtypes['user'])) {
$options['user'] = get_string('user');
$options['user'] = get_string('user', 'calendar');
}
if (!empty($eventtypes['group'])) {
$options['group'] = get_string('group');
$options['group'] = get_string('group', 'calendar');
}
if (!empty($eventtypes['course'])) {
$options['course'] = get_string('course');
$options['course'] = get_string('course', 'calendar');
}
if (!empty($eventtypes['category'])) {
$options['category'] = get_string('category');
$options['category'] = get_string('category', 'calendar');
}
if (!empty($eventtypes['site'])) {
$options['site'] = get_string('site');
$options['site'] = get_string('site', 'calendar');
}
// If we only have one event type and it's 'user' event then don't bother

View File

@ -85,7 +85,7 @@ class managesubscriptions extends \moodleform {
// Add the select elements for the available event types.
$this->add_event_type_elements($mform, $eventtypes);
// Eventtype: 0 = user, 1 = global, anything else = course ID.
// Eventtype: 0 = user, 1 = site, anything else = course ID.
$mform->addElement('submit', 'add', get_string('add'));
// Add the javascript required to enhance this mform.

View File

@ -76,7 +76,7 @@ if(!empty($what) && !empty($time)) {
if ($what == 'all') {
$users = $user->id;
$courses[SITEID] = new stdClass;
$courses[SITEID]->shortname = get_string('globalevents', 'calendar');
$courses[SITEID]->shortname = get_string('siteevents', 'calendar');
$paramcourses[SITEID] = $courses[SITEID];
$paramcategory = true;
} else if ($what == 'groups') {

View File

@ -147,7 +147,7 @@ class core_calendar_external extends external_api {
"Set to true to return current user's user events",
VALUE_DEFAULT, true, NULL_ALLOWED),
'siteevents' => new external_value(PARAM_BOOL,
"Set to true to return global events",
"Set to true to return site events",
VALUE_DEFAULT, true, NULL_ALLOWED),
'timestart' => new external_value(PARAM_INT,
"Time from which events should be returned",

View File

@ -70,10 +70,16 @@ define('CALENDAR_TF_24', '%H:%M');
define('CALENDAR_TF_12', '%I:%M %p');
/**
* CALENDAR_EVENT_GLOBAL - Global calendar event types
* CALENDAR_EVENT_GLOBAL - Site calendar event types
* @deprecated since 3.8
*/
define('CALENDAR_EVENT_GLOBAL', 1);
/**
* CALENDAR_EVENT_SITE - Site calendar event types
*/
define('CALENDAR_EVENT_SITE', 1);
/**
* CALENDAR_EVENT_COURSE - Course calendar event types
*/
@ -1551,8 +1557,8 @@ function calendar_add_event_metadata($event) {
$event->cmid = $module->id;
} else if ($event->courseid == SITEID) { // Site event.
$event->icon = '<img src="' . $OUTPUT->image_url('i/siteevent') . '" alt="' .
get_string('globalevent', 'calendar') . '" class="icon" />';
$event->cssclass = 'calendar_event_global';
get_string('siteevent', 'calendar') . '" class="icon" />';
$event->cssclass = 'calendar_event_site';
} else if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) { // Course event.
$event->icon = '<img src="' . $OUTPUT->image_url('i/courseevent') . '" alt="' .
get_string('courseevent', 'calendar') . '" class="icon" />';
@ -1958,7 +1964,7 @@ function calendar_sub_month($month, $year) {
* @param int $year the number of the year
* @param array $eventsbyday event on specific day
* @param array $durationbyday duration of the event in days
* @param array $typesbyday event type (eg: global, course, user, or group)
* @param array $typesbyday event type (eg: site, course, user, or group)
* @param array $courses list of courses
* @return void
*/
@ -1995,9 +2001,9 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
// Mark the day as having such an event.
if ($event->courseid == SITEID && $event->groupid == 0) {
$typesbyday[$eventdaystart]['startglobal'] = true;
// Set event class for global event.
$events[$event->id]->class = 'calendar_event_global';
$typesbyday[$eventdaystart]['startsite'] = true;
// Set event class for site event.
$events[$event->id]->class = 'calendar_event_site';
} else if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
$typesbyday[$eventdaystart]['startcourse'] = true;
// Set event class for course event.
@ -2036,7 +2042,7 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
for ($i = $lowerbound + 1; $i <= $upperbound; ++$i) {
$durationbyday[$i][] = $event->id;
if ($event->courseid == SITEID && $event->groupid == 0) {
$typesbyday[$i]['durationglobal'] = true;
$typesbyday[$i]['durationsite'] = true;
} else if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
$typesbyday[$i]['durationcourse'] = true;
} else if ($event->groupid) {
@ -2077,7 +2083,7 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false, s
if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_COURSE, $user)) {
$courses = array_keys($courseeventsfrom);
}
if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_GLOBAL, $user)) {
if ($ignorefilters || calendar_show_event_type(CALENDAR_EVENT_SITE, $user)) {
$courses[] = SITEID;
}
$courses = array_unique($courses);
@ -2472,7 +2478,7 @@ function calendar_format_event_time($event, $now, $linkparams = null, $usecommon
* @return bool True if the tyep should be displayed false otherwise
*/
function calendar_show_event_type($type, $user = null) {
$default = CALENDAR_EVENT_GLOBAL + CALENDAR_EVENT_COURSE + CALENDAR_EVENT_GROUP + CALENDAR_EVENT_USER;
$default = CALENDAR_EVENT_SITE + CALENDAR_EVENT_COURSE + CALENDAR_EVENT_GROUP + CALENDAR_EVENT_USER;
if (get_user_preferences('calendar_persistflt', 0, $user) === 0) {
global $SESSION;
@ -2498,7 +2504,7 @@ function calendar_show_event_type($type, $user = null) {
*/
function calendar_set_event_type_display($type, $display = null, $user = null) {
$persist = get_user_preferences('calendar_persistflt', 0, $user);
$default = CALENDAR_EVENT_GLOBAL + CALENDAR_EVENT_COURSE + CALENDAR_EVENT_GROUP
$default = CALENDAR_EVENT_SITE + CALENDAR_EVENT_COURSE + CALENDAR_EVENT_GROUP
+ CALENDAR_EVENT_USER + CALENDAR_EVENT_COURSECAT;
if ($persist === 0) {
global $SESSION;

View File

@ -48,7 +48,7 @@ Feature: Course Category Events
| student2 | B2i | student |
And the following "events" exist:
| name | eventtype |
| Site event | global |
| Site event | site |
And the following "events" exist:
| name | eventtype | course |
| CA1i event | course | A1i |

View File

@ -532,7 +532,7 @@ class core_calendar_container_testcase extends advanced_testcase {
protected function create_event($properties = []) {
$record = new \stdClass();
$record->name = 'event name';
$record->eventtype = 'global';
$record->eventtype = 'site';
$record->timestart = time();
$record->timeduration = 0;
$record->timesort = 0;

View File

@ -467,7 +467,7 @@ class core_calendar_event_factory_testcase extends advanced_testcase {
protected function create_event($properties = []) {
$record = new \stdClass();
$record->name = 'event name';
$record->eventtype = 'global';
$record->eventtype = 'site';
$record->timestart = time();
$record->timeduration = 0;
$record->timesort = 0;

View File

@ -141,7 +141,7 @@ class core_calendar_event_mapper_testcase extends advanced_testcase {
protected function create_event($properties = []) {
$record = new \stdClass();
$record->name = 'event name';
$record->eventtype = 'global';
$record->eventtype = 'site';
$record->timestart = time();
$record->timeduration = 0;
$record->timesort = 0;

View File

@ -48,7 +48,7 @@ use core_calendar\local\event\factories\event_factory_interface;
function create_event($properties) {
$record = new \stdClass();
$record->name = 'event name';
$record->eventtype = 'global';
$record->eventtype = 'site';
$record->repeat = 0;
$record->repeats = 0;
$record->timestart = time();

View File

@ -155,7 +155,7 @@ class core_calendar_repeat_event_collection_testcase extends advanced_testcase {
protected function create_event($properties = []) {
$record = new \stdClass();
$record->name = 'event name';
$record->eventtype = 'global';
$record->eventtype = 'site';
$record->repeat = 0;
$record->repeats = 0;
$record->timestart = time();

View File

@ -32,6 +32,7 @@ $string['calendarheading'] = '{$a} Calendar';
$string['calendarpreferences'] = 'Calendar preferences';
$string['calendartypes'] = 'Calendar types';
$string['calendarurl'] = 'Calendar URL: {$a}';
$string['category'] = 'Category';
$string['categoryevent'] = 'Category event';
$string['clickhide'] = 'click to hide';
$string['clickshow'] = 'click to show';
@ -142,16 +143,12 @@ $string['forcecalendartype'] = 'Force calendar';
$string['fri'] = 'Fri';
$string['friday'] = 'Friday';
$string['generateurlbutton'] = 'Get calendar URL';
$string['global'] = 'Global';
$string['globalevent'] = 'Global event';
$string['globalevents'] = 'Global events';
$string['gotoactivity'] = 'Go to activity';
$string['gotocalendar'] = 'Go to calendar';
$string['group'] = 'Group';
$string['groupevent'] = 'Group event';
$string['groupevents'] = 'Group events';
$string['eventtypeglobal'] = 'global';
$string['eventtypesite'] = 'global';
$string['eventtypesite'] = 'site';
$string['eventtypecategory'] = 'category';
$string['eventtypecourse'] = 'course';
$string['eventtypemodule'] = 'module';
@ -225,6 +222,8 @@ $string['repeatweeksr'] = 'events';
$string['sat'] = 'Sat';
$string['saturday'] = 'Saturday';
$string['shown'] = 'shown';
$string['site'] = 'Site';
$string['siteevent'] = 'Site event';
$string['siteevents'] = 'Site events';
$string['spanningevents'] = 'Events underway';
$string['subscriptions'] = 'Subscriptions';
@ -271,3 +270,9 @@ $string['when'] = 'When';
$string['whendate'] = 'When: {$a}';
$string['yesterday'] = 'Yesterday';
$string['youcandeleteallrepeats'] = 'This event is part of a repeating event series. You can delete this event only, or all {$a} events in the series at once.';
// Deprecated since Moodle 3.8.
$string['global'] = 'Global';
$string['globalevent'] = 'Global event';
$string['globalevents'] = 'Global events';
$string['eventtypeglobal'] = 'global';

View File

@ -115,3 +115,7 @@ completeregistration,core_hub
registersite,core_hub
updatesite,core_hub
unregisterexplained,core_hub
global,core_calendar
globalevent,core_calendar
globalevents,core_calendar
eventtypeglobal,core_calendar

View File

@ -1145,7 +1145,6 @@ EOD;
require_once($CFG->dirroot . '/calendar/lib.php');
$record = new \stdClass();
$record->name = 'event name';
$record->eventtype = 'global';
$record->repeat = 0;
$record->repeats = 0;
$record->timestart = time();
@ -1176,7 +1175,7 @@ EOD;
unset($record->courseid);
unset($record->groupid);
break;
case 'global':
case 'site':
unset($record->categoryid);
unset($record->courseid);
unset($record->groupid);