From ef4e04ee267bab81fb75a6bf7d9ae86d902fb32e Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Thu, 24 May 2018 09:44:54 +0800 Subject: [PATCH] MDL-37624 calendar: Added location support --- backup/moodle2/backup_stepslib.php | 2 +- backup/moodle2/restore_stepslib.php | 3 +- .../classes/external/event_exporter_base.php | 7 ++ .../local/event/entities/action_event.php | 4 + .../classes/local/event/entities/event.php | 14 +++- .../local/event/entities/event_interface.php | 7 ++ .../factories/event_abstract_factory.php | 3 +- calendar/classes/local/event/forms/create.php | 4 + .../local/event/mappers/event_mapper.php | 2 + calendar/classes/privacy/provider.php | 2 + calendar/export_execute.php | 5 ++ calendar/lib.php | 2 + calendar/templates/event_item.mustache | 9 +- .../templates/event_summary_body.mustache | 7 ++ calendar/tests/action_event_test.php | 4 + calendar/tests/behat/calendar.feature | 6 ++ calendar/tests/behat/calendar_import.feature | 1 + calendar/tests/container_test.php | 12 ++- calendar/tests/event_factory_test.php | 24 ++++-- calendar/tests/event_mapper_test.php | 10 ++- calendar/tests/event_test.php | 6 +- calendar/tests/externallib_test.php | 12 +++ calendar/tests/fixtures/import.ics | 1 + calendar/tests/helpers.php | 3 +- calendar/tests/lib_test.php | 8 ++ calendar/tests/local_api_test.php | 8 ++ .../raw_event_retrieval_strategy_test.php | 11 ++- .../tests/repeat_event_collection_test.php | 3 +- .../output/icon_system_fontawesome.php | 1 + lib/db/install.xml | 1 + lib/db/upgrade.php | 14 ++++ pix/i/location.png | Bin 0 -> 260 bytes pix/i/location.svg | 3 + theme/boost/scss/moodle/calendar.scss | 15 +++- theme/bootstrapbase/less/moodle/calendar.less | 9 ++ theme/bootstrapbase/style/moodle.css | 8 ++ .../core_calendar/event_item.mustache | 77 ++++++++++++++++++ .../core_calendar/event_summary_body.mustache | 7 ++ version.php | 2 +- 39 files changed, 290 insertions(+), 27 deletions(-) create mode 100644 pix/i/location.png create mode 100644 pix/i/location.svg create mode 100644 theme/bootstrapbase/templates/core_calendar/event_item.mustache diff --git a/backup/moodle2/backup_stepslib.php b/backup/moodle2/backup_stepslib.php index a2f922a573d..3793d9b7ce7 100644 --- a/backup/moodle2/backup_stepslib.php +++ b/backup/moodle2/backup_stepslib.php @@ -865,7 +865,7 @@ class backup_calendarevents_structure_step extends backup_structure_step { 'name', 'description', 'format', 'courseid', 'groupid', 'userid', 'repeatid', 'modulename', 'instance', 'type', 'eventtype', 'timestart', 'timeduration', 'timesort', 'visible', 'uuid', 'sequence', 'timemodified', - 'priority')); + 'priority', 'location')); // Build the tree $events->add_child($event); diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index 56ca4d89767..844317424c7 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -2725,7 +2725,8 @@ class restore_calendarevents_structure_step extends restore_structure_step { 'uuid' => $data->uuid, 'sequence' => $data->sequence, 'timemodified' => $data->timemodified, - 'priority' => isset($data->priority) ? $data->priority : null); + 'priority' => isset($data->priority) ? $data->priority : null, + 'location' => isset($data->location) ? $data->location : null); if ($this->name == 'activity_calendar') { $params['instance'] = $this->task->get_activityid(); } else { diff --git a/calendar/classes/external/event_exporter_base.php b/calendar/classes/external/event_exporter_base.php index a6bef22d17e..ab3f5ca9718 100644 --- a/calendar/classes/external/event_exporter_base.php +++ b/calendar/classes/external/event_exporter_base.php @@ -79,6 +79,7 @@ class event_exporter_base extends exporter { $event->get_id() ); $data->descriptionformat = $event->get_description()->get_format(); + $data->location = htmlspecialchars($event->get_location()); $data->groupid = $groupid; $data->userid = $userid; $data->categoryid = $categoryid; @@ -123,6 +124,12 @@ class event_exporter_base extends exporter { 'default' => null, 'null' => NULL_ALLOWED ], + 'location' => [ + 'type' => PARAM_RAW_TRIMMED, + 'optional' => true, + 'default' => null, + 'null' => NULL_ALLOWED + ], 'categoryid' => [ 'type' => PARAM_INT, 'optional' => true, diff --git a/calendar/classes/local/event/entities/action_event.php b/calendar/classes/local/event/entities/action_event.php index ad1d98c6ce3..6c8b0f1797b 100644 --- a/calendar/classes/local/event/entities/action_event.php +++ b/calendar/classes/local/event/entities/action_event.php @@ -78,6 +78,10 @@ class action_event implements action_event_interface { return $this->event->get_description(); } + public function get_location() { + return $this->event->get_location(); + } + public function get_category() { return $this->event->get_category(); } diff --git a/calendar/classes/local/event/entities/event.php b/calendar/classes/local/event/entities/event.php index 2f5ea39a079..fdfee976161 100644 --- a/calendar/classes/local/event/entities/event.php +++ b/calendar/classes/local/event/entities/event.php @@ -52,6 +52,11 @@ class event implements event_interface { */ protected $description; + /** + * @var string $location Location of this event. + */ + protected $location; + /** * @var proxy_interface $category Category for this event. */ @@ -118,6 +123,7 @@ class event implements event_interface { * @param times_interface $times The times associated with the event. * @param bool $visible The event's visibility. True for visible, false for invisible. * @param proxy_interface $subscription The event's subscription. + * @param string $location The event's location. */ public function __construct( $id, @@ -132,11 +138,13 @@ class event implements event_interface { $type, times_interface $times, $visible, - proxy_interface $subscription = null + proxy_interface $subscription = null, + $location = null ) { $this->id = $id; $this->name = $name; $this->description = $description; + $this->location = $location; $this->category = $category; $this->course = $course; $this->group = $group; @@ -161,6 +169,10 @@ class event implements event_interface { return $this->description; } + public function get_location() { + return $this->location; + } + public function get_category() { return $this->category; } diff --git a/calendar/classes/local/event/entities/event_interface.php b/calendar/classes/local/event/entities/event_interface.php index 0e2de4f77c4..5561f622f58 100644 --- a/calendar/classes/local/event/entities/event_interface.php +++ b/calendar/classes/local/event/entities/event_interface.php @@ -56,6 +56,13 @@ interface event_interface { */ public function get_description(); + /** + * Get the event's location. + * + * @return location_interface + */ + public function get_location(); + /** * Get the category object associated with the event. * diff --git a/calendar/classes/local/event/factories/event_abstract_factory.php b/calendar/classes/local/event/factories/event_abstract_factory.php index 9574f7fd1c6..807ecadf61b 100644 --- a/calendar/classes/local/event/factories/event_abstract_factory.php +++ b/calendar/classes/local/event/factories/event_abstract_factory.php @@ -189,7 +189,8 @@ abstract class event_abstract_factory implements event_factory_interface { (new \DateTimeImmutable())->setTimestamp($dbrow->timemodified) ), !empty($dbrow->visible), - $subscription + $subscription, + $dbrow->location ); $isactionevent = !empty($dbrow->type) && $dbrow->type == CALENDAR_EVENT_TYPE_ACTION; diff --git a/calendar/classes/local/event/forms/create.php b/calendar/classes/local/event/forms/create.php index 1e36407d74b..6697a3716ca 100644 --- a/calendar/classes/local/event/forms/create.php +++ b/calendar/classes/local/event/forms/create.php @@ -98,6 +98,10 @@ class create extends \moodleform { $mform->setType('description', PARAM_RAW); $mform->setAdvanced('description'); + $mform->addElement('text', 'location', get_string('location', 'moodle'), 'size="50"'); + $mform->setType('location', PARAM_RAW_TRIMMED); + $mform->setAdvanced('location'); + // Add the variety of elements allowed for selecting event duration. $this->add_event_duration_elements($mform); diff --git a/calendar/classes/local/event/mappers/event_mapper.php b/calendar/classes/local/event/mappers/event_mapper.php index 214983fec6e..5600ec76bca 100644 --- a/calendar/classes/local/event/mappers/event_mapper.php +++ b/calendar/classes/local/event/mappers/event_mapper.php @@ -68,6 +68,7 @@ class event_mapper implements event_mapper_interface { 'id' => $coalesce('id'), 'name' => $coalesce('name'), 'description' => $coalesce('description'), + 'location' => $coalesce('location'), 'format' => $coalesce('format'), 'categoryid' => $coalesce('categoryid'), 'courseid' => $coalesce('courseid'), @@ -119,6 +120,7 @@ class event_mapper implements event_mapper_interface { 'name' => $event->get_name(), 'description' => $event->get_description()->get_value(), 'format' => $event->get_description()->get_format(), + 'location' => $event->get_location(), 'courseid' => $event->get_course() ? $event->get_course()->get('id') : null, 'categoryid' => $event->get_category() ? $event->get_category()->get('id') : null, 'groupid' => $event->get_group() ? $event->get_group()->get('id') : null, diff --git a/calendar/classes/privacy/provider.php b/calendar/classes/privacy/provider.php index 4fc58deccee..33324214b47 100644 --- a/calendar/classes/privacy/provider.php +++ b/calendar/classes/privacy/provider.php @@ -273,6 +273,7 @@ class provider implements $eventdetails = (object) [ 'name' => $event->name, 'description' => $event->description, + 'location' => $event->location, 'eventtype' => $event->eventtype, 'timestart' => transform::datetime($event->timestart), 'timeduration' => $event->timeduration @@ -456,6 +457,7 @@ class provider implements details.id as eventid, details.name as name, details.description as description, + details.location as location, details.eventtype as eventtype, details.timestart as timestart, details.timeduration as timeduration diff --git a/calendar/export_execute.php b/calendar/export_execute.php index ca162a2037f..53bd01d4add 100644 --- a/calendar/export_execute.php +++ b/calendar/export_execute.php @@ -211,6 +211,11 @@ foreach($events as $event) { $ev->add_property('class', 'PUBLIC'); // PUBLIC / PRIVATE / CONFIDENTIAL $ev->add_property('last-modified', Bennu::timestamp_to_datetime($event->timemodified)); + + if (!empty($event->location)) { + $ev->add_property('location', $event->location); + } + $ev->add_property('dtstamp', Bennu::timestamp_to_datetime()); // now if ($event->timeduration > 0) { //dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer diff --git a/calendar/lib.php b/calendar/lib.php index 0f684dd9c4a..60d3d0f5bee 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -2912,6 +2912,8 @@ function calendar_add_icalendar_event($event, $unused = null, $subscriptionid, $ \core_date::set_default_server_timezone(); } + $eventrecord->location = empty($event->properties['LOCATION'][0]->value) ? '' : + str_replace('\\', '', $event->properties['LOCATION'][0]->value); $eventrecord->uuid = $event->properties['UID'][0]->value; $eventrecord->timemodified = time(); diff --git a/calendar/templates/event_item.mustache b/calendar/templates/event_item.mustache index 91d07519887..157a65297d7 100644 --- a/calendar/templates/event_item.mustache +++ b/calendar/templates/event_item.mustache @@ -54,9 +54,12 @@ {{/canedit}} - {{#icon}}{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}{{/icon}} -

{{name}}

- {{{formattedtime}}} + {{#icon}}
{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}
{{/icon}} +
+

{{name}}

+ {{{formattedtime}}} +
{{#location}}{{{location}}}{{/location}}
+

{{{description}}}

diff --git a/calendar/templates/event_summary_body.mustache b/calendar/templates/event_summary_body.mustache index de5424e0ae0..576ffbe1eae 100644 --- a/calendar/templates/event_summary_body.mustache +++ b/calendar/templates/event_summary_body.mustache @@ -23,6 +23,7 @@ { "timestart": 1490320388, "description": "An random event description", + "location": "13th floor, building 42", "eventtype": "User", "source": "Ical imported", "groupname": "Group 1" @@ -53,6 +54,12 @@
{{{.}}}
{{/description}} + {{#location}} +
+
{{#pix}} i/location, core, {{#str}} location {{/str}} {{/pix}}
+
{{{.}}}
+
+ {{/location}} {{#isactionevent}}
{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}
diff --git a/calendar/tests/action_event_test.php b/calendar/tests/action_event_test.php index acb864331a2..d6ae9f6d6cf 100644 --- a/calendar/tests/action_event_test.php +++ b/calendar/tests/action_event_test.php @@ -108,6 +108,10 @@ class core_calendar_action_event_test_event implements event_interface { return new event_description('asdf', 1); } + public function get_location() { + return 'Cube office'; + } + public function get_category() { return new \stdClass(); } diff --git a/calendar/tests/behat/calendar.feature b/calendar/tests/behat/calendar.feature index e0e7850dc1e..6d5a6021248 100644 --- a/calendar/tests/behat/calendar.feature +++ b/calendar/tests/behat/calendar.feature @@ -38,6 +38,7 @@ Feature: Perform basic calendar functionality | Type of event | site | | Event title | Really awesome event! | | Description | Come join this awesome event, sucka! | + | Location | Cube office | And I log out And I log in as "student1" And I am on "Course 1" course homepage @@ -56,6 +57,7 @@ Feature: Perform basic calendar functionality | Course | Course 1 | | Event title | Really awesome event! | | Description | Come join this awesome event, sucka! | + | Location | Cube office | And I log out And I log in as "student1" When I am on "Course 1" course homepage @@ -77,6 +79,7 @@ Feature: Perform basic calendar functionality | Group | Group 1 | | Event title | Really awesome event! | | Description | Come join this awesome event | + | Location | Cube office | And I log out And I log in as "student1" When I am on "Course 1" course homepage @@ -90,6 +93,7 @@ Feature: Perform basic calendar functionality | Type of event | user | | Event title | Really awesome event! | | Description | Come join this awesome event, sucka! | + | Location | Cube office | And I log out And I log in as "student1" When I am on "Course 1" course homepage @@ -118,6 +122,7 @@ Feature: Perform basic calendar functionality | Type of event | user | | Event title | Really awesome event! | | Description | Come join this awesome event, sucka! | + | Location | Cube office | And I am on "Course 1" course homepage When I follow "This month" And I click on "Really awesome event!" "link" @@ -125,6 +130,7 @@ Feature: Perform basic calendar functionality And I set the following fields to these values: | Event title | Mediocre event :( | | Description | Wait, this event isn't that great. | + | Location | The park | And I press "Save" Then I should see "Mediocre event" diff --git a/calendar/tests/behat/calendar_import.feature b/calendar/tests/behat/calendar_import.feature index 6930b1ecec9..c56e4d1b4b6 100644 --- a/calendar/tests/behat/calendar_import.feature +++ b/calendar/tests/behat/calendar_import.feature @@ -35,6 +35,7 @@ Feature: Import and edit calendar events And I set the following fields to these values: | Event title | Event on 2-20-2017 | | Description | Event on 2-20-2017 | + | Location | Some place | | timestart[day] | 20 | And I press "Save" When I view the calendar for "2" "2017" diff --git a/calendar/tests/container_test.php b/calendar/tests/container_test.php index 8439caaea80..011464bad38 100644 --- a/calendar/tests/container_test.php +++ b/calendar/tests/container_test.php @@ -100,6 +100,7 @@ class core_calendar_container_testcase extends advanced_testcase { $this->assertEquals($dbrow->description, $event->get_description()->get_value()); $this->assertEquals($dbrow->format, $event->get_description()->get_format()); $this->assertEquals($dbrow->courseid, $event->get_course()->get('id')); + $this->assertEquals($dbrow->location, $event->get_location()); if ($dbrow->groupid == 0) { $this->assertNull($event->get_group()); @@ -337,6 +338,7 @@ class core_calendar_container_testcase extends advanced_testcase { $event = new \stdClass(); $event->name = 'An event'; $event->description = 'Event description'; + $event->location = 'Event location'; $event->format = FORMAT_HTML; $event->eventtype = \core_completion\api::COMPLETION_EVENT_TYPE_DATE_COMPLETION_EXPECTED; $event->userid = 1; @@ -386,6 +388,7 @@ class core_calendar_container_testcase extends advanced_testcase { $event = new \stdClass(); $event->name = 'An event'; $event->description = 'Event description'; + $event->location = 'Event location'; $event->format = FORMAT_HTML; $event->eventtype = 'close'; $event->userid = $user->id; @@ -490,7 +493,8 @@ class core_calendar_container_testcase extends advanced_testcase { 'timesort' => 1486396800, 'visible' => 1, 'timemodified' => 1485793098, - 'subscriptionid' => null + 'subscriptionid' => null, + 'location' => 'Test location', ] ], @@ -512,7 +516,8 @@ class core_calendar_container_testcase extends advanced_testcase { 'timesort' => 1486396800, 'visible' => 1, 'timemodified' => 1485793098, - 'subscriptionid' => null + 'subscriptionid' => null, + 'location' => 'Test location', ] ] ]; @@ -567,7 +572,8 @@ class core_calendar_container_testcase extends advanced_testcase { 'timesort' => 1486396800, 'visible' => 1, 'timemodified' => 1485793098, - 'subscriptionid' => null + 'subscriptionid' => null, + 'location' => 'Test location', ]; foreach ((array) $skeleton as $key => $value) { diff --git a/calendar/tests/event_factory_test.php b/calendar/tests/event_factory_test.php index e2bf0bffd7b..abf40ea5410 100644 --- a/calendar/tests/event_factory_test.php +++ b/calendar/tests/event_factory_test.php @@ -128,7 +128,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => 1, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ] ); } @@ -177,7 +178,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => 1, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ] ); } @@ -226,7 +228,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => 1, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ] ); } @@ -275,7 +278,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => 1, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ] ); @@ -330,7 +334,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => 1, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ] ); @@ -364,7 +369,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => true, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ], 'actioncallbackapplier' => function(event_interface $event) { $event->testattribute = 'Hello'; @@ -398,7 +404,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => true, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ], 'actioncallbackapplier' => function(event_interface $event) { $event->testattribute = 'Hello'; @@ -432,7 +439,8 @@ class core_calendar_event_factory_testcase extends advanced_testcase { 'timemodified' => 123456789, 'timesort' => 123456789, 'visible' => true, - 'subscriptionid' => 1 + 'subscriptionid' => 1, + 'location' => 'Test location', ], 'actioncallbackapplier' => function(event_interface $event) { $event->testattribute = 'Hello'; diff --git a/calendar/tests/event_mapper_test.php b/calendar/tests/event_mapper_test.php index 47f3f4bb458..d59bccc6da7 100644 --- a/calendar/tests/event_mapper_test.php +++ b/calendar/tests/event_mapper_test.php @@ -203,6 +203,10 @@ class event_mapper_test_action_event implements action_event_interface { return $this->event->get_description(); } + public function get_location() { + return $this->event->get_location(); + } + public function get_category() { return $this->event->get_category(); } @@ -293,7 +297,7 @@ class event_mapper_test_event implements event_interface { /** * Constructor. * - * @param calendar_event $legacyevent Legacy event to exctract IDs etc from. + * @param calendar_event $legacyevent Legacy event to extract IDs etc from. */ public function __construct($legacyevent = null) { if ($legacyevent) { @@ -322,6 +326,10 @@ class event_mapper_test_event implements event_interface { return new event_description('asdf', 1); } + public function get_location() { + return 'Cube office'; + } + public function get_category() { return $this->categoryproxy; } diff --git a/calendar/tests/event_test.php b/calendar/tests/event_test.php index 8b28046d2b8..3a70913c635 100644 --- a/calendar/tests/event_test.php +++ b/calendar/tests/event_test.php @@ -58,7 +58,8 @@ class core_calendar_event_testcase extends advanced_testcase { $constructorparams['type'], $constructorparams['times'], $constructorparams['visible'], - $constructorparams['subscription'] + $constructorparams['subscription'], + $constructorparams['location'] ); foreach ($constructorparams as $name => $value) { @@ -98,7 +99,8 @@ class core_calendar_event_testcase extends advanced_testcase { (new \DateTimeImmutable())->setTimestamp(time()) ), 'visible' => true, - 'subscription' => new std_proxy(1, $lamecallable) + 'subscription' => new std_proxy(1, $lamecallable), + 'location' => 'Test', ] ], ]; diff --git a/calendar/tests/externallib_test.php b/calendar/tests/externallib_test.php index 9fcf147e005..28b42d30585 100644 --- a/calendar/tests/externallib_test.php +++ b/calendar/tests/externallib_test.php @@ -1516,6 +1516,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'text' => '', 'format' => 1, ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -1574,6 +1575,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'format' => 1, 'itemid' => 0 ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -1637,6 +1639,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'text' => '', 'format' => 1, ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -1698,6 +1701,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'format' => 1, 'itemid' => 0 ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -1762,6 +1766,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'text' => '', 'format' => 1, ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -1826,6 +1831,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'format' => 1, 'itemid' => 0, ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -1894,6 +1900,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'text' => '', 'format' => 1, ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -1959,6 +1966,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'text' => '', 'format' => 1, ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -2026,6 +2034,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'format' => 1, 'itemid' => 0 ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -2098,6 +2107,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'format' => 1, 'itemid' => 0 ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -2171,6 +2181,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'format' => 1, 'itemid' => 0 ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), @@ -2243,6 +2254,7 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase { 'text' => '', 'format' => 1, ], + 'location' => 'Test', 'duration' => 1, 'timedurationuntil' => [ 'day' => $timedurationuntil->format('j'), diff --git a/calendar/tests/fixtures/import.ics b/calendar/tests/fixtures/import.ics index d414e63e801..5ccd1897342 100644 --- a/calendar/tests/fixtures/import.ics +++ b/calendar/tests/fixtures/import.ics @@ -18,6 +18,7 @@ SUMMARY:Event on 2-25-2017 DESCRIPTION:Event on 2-25-2017 CLASS:PUBLIC LAST-MODIFIED:20170226T014258Z +LOCATION:Some place DTSTAMP:20170226T014355Z DTSTART;VALUE=DATE:20170224 DTEND;VALUE=DATE:20170225 diff --git a/calendar/tests/helpers.php b/calendar/tests/helpers.php index aa53fd4b35d..92f2e2e4ac8 100644 --- a/calendar/tests/helpers.php +++ b/calendar/tests/helpers.php @@ -136,7 +136,8 @@ class action_event_test_factory implements event_factory_interface { (new \DateTimeImmutable())->setTimestamp($record->timemodified) ), !empty($record->visible), - $subscription + $subscription, + $record->location ); $action = new action( diff --git a/calendar/tests/lib_test.php b/calendar/tests/lib_test.php index 6c6e7536ceb..bf8b6ca9339 100644 --- a/calendar/tests/lib_test.php +++ b/calendar/tests/lib_test.php @@ -61,6 +61,7 @@ class core_calendar_lib_testcase extends advanced_testcase { [ 'name' => 'Start of assignment', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => 0, @@ -74,6 +75,7 @@ class core_calendar_lib_testcase extends advanced_testcase { ], [ 'name' => 'Start of lesson', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => 0, @@ -272,6 +274,7 @@ class core_calendar_lib_testcase extends advanced_testcase { [ 'name' => 'Assignment 1 due date', 'description' => '', + 'location' => 'Test', 'format' => 0, 'courseid' => $course->id, 'groupid' => 0, @@ -285,6 +288,7 @@ class core_calendar_lib_testcase extends advanced_testcase { ], [ 'name' => 'Assignment 1 due date - User override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => 0, 'groupid' => 0, @@ -299,6 +303,7 @@ class core_calendar_lib_testcase extends advanced_testcase { ], [ 'name' => 'Assignment 1 due date - Group A override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => $group1->id, @@ -313,6 +318,7 @@ class core_calendar_lib_testcase extends advanced_testcase { ], [ 'name' => 'Assignment 1 due date - Group B override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => $group2->id, @@ -372,6 +378,7 @@ class core_calendar_lib_testcase extends advanced_testcase { [ 'name' => 'Repeating site event', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => SITEID, 'groupid' => 0, @@ -387,6 +394,7 @@ class core_calendar_lib_testcase extends advanced_testcase { [ 'name' => 'Repeating site event', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => SITEID, 'groupid' => 0, diff --git a/calendar/tests/local_api_test.php b/calendar/tests/local_api_test.php index ff2e065fb96..a6466dc06bb 100644 --- a/calendar/tests/local_api_test.php +++ b/calendar/tests/local_api_test.php @@ -662,6 +662,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { [ 'name' => 'Start of assignment', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => 0, @@ -675,6 +676,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { ], [ 'name' => 'Start of lesson', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => 0, @@ -754,6 +756,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { [ 'name' => 'Assignment 1 due date', 'description' => '', + 'location' => 'Test', 'format' => 0, 'courseid' => $course->id, 'groupid' => 0, @@ -767,6 +770,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { ], [ 'name' => 'Assignment 1 due date - User override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => 0, 'groupid' => 0, @@ -781,6 +785,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { ], [ 'name' => 'Assignment 1 due date - Group A override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => $group1->id, @@ -795,6 +800,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { ], [ 'name' => 'Assignment 1 due date - Group B override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => $group2->id, @@ -854,6 +860,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { [ 'name' => 'Repeating site event', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => SITEID, 'groupid' => 0, @@ -869,6 +876,7 @@ class core_calendar_local_api_testcase extends advanced_testcase { [ 'name' => 'Repeating site event', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => SITEID, 'groupid' => 0, diff --git a/calendar/tests/raw_event_retrieval_strategy_test.php b/calendar/tests/raw_event_retrieval_strategy_test.php index 9d8b1375b65..1a927c2a169 100644 --- a/calendar/tests/raw_event_retrieval_strategy_test.php +++ b/calendar/tests/raw_event_retrieval_strategy_test.php @@ -53,6 +53,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc [ 'name' => 'Start of assignment', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => 0, @@ -66,6 +67,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc ], [ 'name' => 'Start of lesson', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => 0, @@ -144,6 +146,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc [ 'name' => 'Assignment 1 due date', 'description' => '', + 'location' => 'Test', 'format' => 0, 'courseid' => $course->id, 'groupid' => 0, @@ -157,6 +160,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc ], [ 'name' => 'Assignment 1 due date - User override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => 0, 'groupid' => 0, @@ -171,6 +175,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc ], [ 'name' => 'Assignment 1 due date - Group A override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => $group1->id, @@ -185,6 +190,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc ], [ 'name' => 'Assignment 1 due date - Group B override', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => $course->id, 'groupid' => $group2->id, @@ -240,6 +246,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc [ 'name' => 'Repeating site event', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => SITEID, 'groupid' => 0, @@ -255,6 +262,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc [ 'name' => 'Repeating site event', 'description' => '', + 'location' => 'Test', 'format' => 1, 'courseid' => SITEID, 'groupid' => 0, @@ -294,6 +302,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc 'name' => 'E1', 'eventtype' => 'category', 'description' => '', + 'location' => 'Test', 'format' => 1, 'categoryid' => $category1->id, 'userid' => 2, @@ -303,6 +312,7 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc 'name' => 'E2', 'eventtype' => 'category', 'description' => '', + 'location' => 'Test', 'format' => 1, 'categoryid' => $category2->id, 'userid' => 2, @@ -342,4 +352,3 @@ class core_calendar_raw_event_retrieval_strategy_testcase extends advanced_testc $this->assertCount(2, $events); } } - diff --git a/calendar/tests/repeat_event_collection_test.php b/calendar/tests/repeat_event_collection_test.php index 98c1c0be35f..7d335eae1fa 100644 --- a/calendar/tests/repeat_event_collection_test.php +++ b/calendar/tests/repeat_event_collection_test.php @@ -204,7 +204,8 @@ class core_calendar_repeat_event_collection_event_test_factory implements event_ (new \DateTimeImmutable())->setTimestamp($dbrow->timemodified) ), !empty($dbrow->visible), - new std_proxy($dbrow->subscriptionid, $identity) + new std_proxy($dbrow->subscriptionid, $identity), + $dbrow->location ); } } diff --git a/lib/classes/output/icon_system_fontawesome.php b/lib/classes/output/icon_system_fontawesome.php index 71d15a671e6..75abeda9b87 100644 --- a/lib/classes/output/icon_system_fontawesome.php +++ b/lib/classes/output/icon_system_fontawesome.php @@ -243,6 +243,7 @@ class icon_system_fontawesome extends icon_system_font { 'core:i/item' => 'fa-circle', 'core:i/loading' => 'fa-circle-o-notch fa-spin', 'core:i/loading_small' => 'fa-circle-o-notch fa-spin', + 'core:i/location' => 'fa-map-marker', 'core:i/lock' => 'fa-lock', 'core:i/log' => 'fa-list-alt', 'core:i/mahara_host' => 'fa-id-badge', diff --git a/lib/db/install.xml b/lib/db/install.xml index b9b900372d2..e453f28d656 100644 --- a/lib/db/install.xml +++ b/lib/db/install.xml @@ -445,6 +445,7 @@ + diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index cc7edbd15a3..ce13b245bb1 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2233,5 +2233,19 @@ function xmldb_main_upgrade($oldversion) { // Automatically generated Moodle v3.5.0 release upgrade line. // Put any upgrade step following this. + if ($oldversion < 2018062800.01) { + // Define field location to be added to event. + $table = new xmldb_table('event'); + $field = new xmldb_field('location', XMLDB_TYPE_TEXT, null, null, null, null, null, 'priority'); + + // Conditionally launch add field location. + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + // Main savepoint reached. + upgrade_main_savepoint(true, 2018062800.01); + } + return true; } diff --git a/pix/i/location.png b/pix/i/location.png new file mode 100644 index 0000000000000000000000000000000000000000..e9fa8a1a4a4a34d219be24b1a392c8f980ec2cda GIT binary patch literal 260 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPFP2=EDU1=2G~0h|6Tb_D9-FA4Gs zW)M&?2uLVs=%2rS|M~mxQ*)aPfKnx%E{-7_vaAO;@-{gzI9&8MFblYF*`iVS!tQ3n zgN}0=j%jA(v@o9OO?t?XuDG+~)OXv2^|lUct(?T{A3h5Ttgu;IvcNas#SznkVd*{v zVIQ}@47unY;yV3wtm=waKCAbY6)p;ypUwVh#rqFy7X->O^4&Ttzi&bKojjqt=YaMz Nc)I$ztaD0e0suF#Z1VsB literal 0 HcmV?d00001 diff --git a/pix/i/location.svg b/pix/i/location.svg new file mode 100644 index 00000000000..937f4494bac --- /dev/null +++ b/pix/i/location.svg @@ -0,0 +1,3 @@ + +]> \ No newline at end of file diff --git a/theme/boost/scss/moodle/calendar.scss b/theme/boost/scss/moodle/calendar.scss index 8c88d89f57f..97a40a04ea2 100644 --- a/theme/boost/scss/moodle/calendar.scss +++ b/theme/boost/scss/moodle/calendar.scss @@ -238,8 +238,15 @@ $calendarEventUserColor: #dce7ec !default; // Pale blue. } } - .event .card-header img { - vertical-align: baseline; + .event { + .card-header img { + vertical-align: baseline; + } + + .location { + word-break: break-all; + overflow-wrap: break-word; + } } } @@ -426,4 +433,8 @@ table.calendartable caption { margin: 0; } } + + .location-content { + overflow-wrap: break-word; + } } diff --git a/theme/bootstrapbase/less/moodle/calendar.less b/theme/bootstrapbase/less/moodle/calendar.less index a201eccc6aa..d8e50ce6b11 100644 --- a/theme/bootstrapbase/less/moodle/calendar.less +++ b/theme/bootstrapbase/less/moodle/calendar.less @@ -253,6 +253,11 @@ .side { width: 22px; } + .location { + clear: both; + word-break: break-all; + overflow-wrap: break-word; + } .description { background-color: @white; clear: both; @@ -416,4 +421,8 @@ margin: 0; } } + + .location-content { + overflow-wrap: break-word; + } } diff --git a/theme/bootstrapbase/style/moodle.css b/theme/bootstrapbase/style/moodle.css index ce1163d9577..c5a4a99cf93 100644 --- a/theme/bootstrapbase/style/moodle.css +++ b/theme/bootstrapbase/style/moodle.css @@ -5790,6 +5790,11 @@ img.iconsmall { .path-calendar .maincalendar .eventlist .event .side { width: 22px; } +.path-calendar .maincalendar .eventlist .event .location { + clear: both; + word-break: break-all; + overflow-wrap: break-word; +} .path-calendar .maincalendar .eventlist .event .description { background-color: #fff; clear: both; @@ -5915,6 +5920,9 @@ img.iconsmall { .summary-modal-container .description-content > p { margin: 0; } +.summary-modal-container .location-content { + overflow-wrap: break-word; +} /* course.less */ /* COURSE CONTENT */ /* stylelint-disable unit-blacklist */ diff --git a/theme/bootstrapbase/templates/core_calendar/event_item.mustache b/theme/bootstrapbase/templates/core_calendar/event_item.mustache new file mode 100644 index 00000000000..8fde5edfcc6 --- /dev/null +++ b/theme/bootstrapbase/templates/core_calendar/event_item.mustache @@ -0,0 +1,77 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template calendar/event_item + + Calendar event item. + + The purpose of this template is to render the event item. + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Example context (json): + { + } +}} + +
+
+ + {{#icon}}{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}{{/icon}} +

{{name}}

+ {{{formattedtime}}} +
{{#location}}{{{location}}}{{/location}}
+
+
+

{{{description}}}

+ {{#iscourseevent}} + + {{/iscourseevent}} + {{> core_calendar/event_subscription}} + {{#isactionevent}} + {{#str}} gotoactivity, core_calendar {{/str}} + {{/isactionevent}} + {{#groupname}} + +
{{{groupname}}}
+ {{/groupname}} +
+
+
\ No newline at end of file diff --git a/theme/bootstrapbase/templates/core_calendar/event_summary_body.mustache b/theme/bootstrapbase/templates/core_calendar/event_summary_body.mustache index 980e2d2b6c4..56370e0a586 100644 --- a/theme/bootstrapbase/templates/core_calendar/event_summary_body.mustache +++ b/theme/bootstrapbase/templates/core_calendar/event_summary_body.mustache @@ -23,6 +23,7 @@ { "timestart": 1490320388, "description": "An random event description", + "location": "13th floor, building 42", "eventtype": "User", "source": "Ical imported", "groupname": "Group 1" @@ -53,6 +54,12 @@
{{{.}}}
{{/description}} + {{#location}} +
+
{{#pix}} i/location, core, {{#str}} location {{/str}} {{/pix}}
+
{{{.}}}
+
+ {{/location}} {{#isactionevent}}
{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}
diff --git a/version.php b/version.php index d6966f378ef..f21cafbaef5 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2018062800.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2018062800.01; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes. -- 2.43.0