Skip to content

Commit

Permalink
Merge branch 'MDL-37624-master' of git://github.com/mickhawkins/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Jul 4, 2018
2 parents 9dc7f25 + 4c838be commit a746b6e
Show file tree
Hide file tree
Showing 39 changed files with 291 additions and 27 deletions.
2 changes: 1 addition & 1 deletion backup/moodle2/backup_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ protected function define_structure() {
'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);
Expand Down
3 changes: 2 additions & 1 deletion backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2725,7 +2725,8 @@ public function process_calendarevents($data) {
'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 {
Expand Down
7 changes: 7 additions & 0 deletions calendar/classes/external/event_exporter_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function __construct(event_interface $event, $related = []) {
$event->get_id()
);
$data->descriptionformat = $event->get_description()->get_format();
$data->location = external_format_text($event->get_location(), FORMAT_PLAIN, $related['context']->id)[0];
$data->groupid = $groupid;
$data->userid = $userid;
$data->categoryid = $categoryid;
Expand Down Expand Up @@ -123,6 +124,12 @@ protected static function define_properties() {
'default' => null,
'null' => NULL_ALLOWED
],
'location' => [
'type' => PARAM_RAW_TRIMMED,
'optional' => true,
'default' => null,
'null' => NULL_ALLOWED
],
'categoryid' => [
'type' => PARAM_INT,
'optional' => true,
Expand Down
4 changes: 4 additions & 0 deletions calendar/classes/local/event/entities/action_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public function get_description() {
return $this->event->get_description();
}

public function get_location() {
return $this->event->get_location();
}

public function get_category() {
return $this->event->get_category();
}
Expand Down
14 changes: 13 additions & 1 deletion calendar/classes/local/event/entities/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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,
Expand All @@ -132,11 +138,13 @@ public function __construct(
$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;
Expand All @@ -161,6 +169,10 @@ public function get_description() {
return $this->description;
}

public function get_location() {
return $this->location;
}

public function get_category() {
return $this->category;
}
Expand Down
7 changes: 7 additions & 0 deletions calendar/classes/local/event/entities/event_interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ public function get_name();
*/
public function get_description();

/**
* Get the event's location.
*
* @return location_interface
*/
public function get_location();

/**
* Get the category object associated with the event.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public function create_instance(\stdClass $dbrow) {
(new \DateTimeImmutable())->setTimestamp($dbrow->timemodified)
),
!empty($dbrow->visible),
$subscription
$subscription,
$dbrow->location
);

$isactionevent = !empty($dbrow->type) && $dbrow->type == CALENDAR_EVENT_TYPE_ACTION;
Expand Down
4 changes: 4 additions & 0 deletions calendar/classes/local/event/forms/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public function definition() {
$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);

Expand Down
2 changes: 2 additions & 0 deletions calendar/classes/local/event/mappers/event_mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function from_legacy_event_to_event(\calendar_event $legacyevent) {
'id' => $coalesce('id'),
'name' => $coalesce('name'),
'description' => $coalesce('description'),
'location' => $coalesce('location'),
'format' => $coalesce('format'),
'categoryid' => $coalesce('categoryid'),
'courseid' => $coalesce('courseid'),
Expand Down Expand Up @@ -119,6 +120,7 @@ public function from_event_to_assoc_array(event_interface $event) {
'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,
Expand Down
2 changes: 2 additions & 0 deletions calendar/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ protected static function export_user_calendar_event_data(approved_contextlist $
$eventdetails = (object) [
'name' => $event->name,
'description' => $event->description,
'location' => $event->location,
'eventtype' => $event->eventtype,
'timestart' => transform::datetime($event->timestart),
'timeduration' => $event->timeduration
Expand Down Expand Up @@ -456,6 +457,7 @@ protected static function get_calendar_event_details_by_contextlist(approved_con
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
Expand Down
5 changes: 5 additions & 0 deletions calendar/export_execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@

$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
Expand Down
2 changes: 2 additions & 0 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
9 changes: 6 additions & 3 deletions calendar/templates/event_item.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@
</a>
{{/canedit}}
</div>
{{#icon}}{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}{{/icon}}
<h3 class="name d-inline-block">{{name}}</h3>
<span class="date pull-xs-right m-r-1">{{{formattedtime}}}</span>
{{#icon}}<div class="d-inline-block mt-1 align-top">{{#pix}} {{key}}, {{component}}, {{alttext}} {{/pix}}</div>{{/icon}}
<div class="d-inline-block">
<h3 class="name d-inline-block">{{name}}</h3>
<span class="date pull-xs-right m-r-1">{{{formattedtime}}}</span>
<div class="location">{{#location}}{{{location}}}{{/location}}</div>
</div>
</div>
<div class="description card-block calendar_event_{{eventtype}}">
<p>{{{description}}}</p>
Expand Down
7 changes: 7 additions & 0 deletions calendar/templates/event_summary_body.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
{
"timestart": 1490320388,
"description": "An random event description",
"location": "13th floor, building 42",
"eventtype": "User",
"source": "Ical imported",
"groupname": "Group 1"
Expand Down Expand Up @@ -53,6 +54,12 @@
<div class="description-content col-xs-11">{{{.}}}</div>
</div>
{{/description}}
{{#location}}
<div class="row m-t-1">
<div class="col-xs-1">{{#pix}} i/location, core, {{#str}} location {{/str}} {{/pix}}</div>
<div class="location-content col-xs-11">{{{.}}}</div>
</div>
{{/location}}
{{#isactionevent}}
<div class="row m-t-1">
<div class="col-xs-1">{{#pix}} i/courseevent, core, {{#str}} course {{/str}} {{/pix}}</div>
Expand Down
4 changes: 4 additions & 0 deletions calendar/tests/action_event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public function get_description() {
return new event_description('asdf', 1);
}

public function get_location() {
return 'Cube office';
}

public function get_category() {
return new \stdClass();
}
Expand Down
7 changes: 7 additions & 0 deletions calendar/tests/behat/calendar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,22 @@ 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"
And ".location-content" "css_element" should exist
And I should see "Cube office"
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | Mediocre event :( |
| Description | Wait, this event isn't that great. |
| Location | |
And I press "Save"
And I should see "Mediocre event"
And I click on "Mediocre event :(" "link"
Then I should see "Mediocre event"
And ".location-content" "css_element" should not exist

@javascript
Scenario: Module events editing
Expand Down
1 change: 1 addition & 0 deletions calendar/tests/behat/calendar_import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Feature: Import and edit calendar events
And I should see "Event on 2-15-2017"
And I should see "Event on 2-25-2017"
And I click on "Event on 2-15-2017" "link"
And I should see "Some place"
And I click on "Edit" "button"
And I set the following fields to these values:
| Event title | Event on 2-20-2017 |
Expand Down
12 changes: 9 additions & 3 deletions calendar/tests/container_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function test_event_factory_create_instance($dbrow) {
$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());
Expand Down Expand Up @@ -337,6 +338,7 @@ public function test_event_factory_with_completion_related_event() {
$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;
Expand Down Expand Up @@ -386,6 +388,7 @@ public function test_event_factory_unenrolled_user() {
$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;
Expand Down Expand Up @@ -490,7 +493,8 @@ public function get_event_factory_testcases() {
'timesort' => 1486396800,
'visible' => 1,
'timemodified' => 1485793098,
'subscriptionid' => null
'subscriptionid' => null,
'location' => 'Test location',
]
],

Expand All @@ -512,7 +516,8 @@ public function get_event_factory_testcases() {
'timesort' => 1486396800,
'visible' => 1,
'timemodified' => 1485793098,
'subscriptionid' => null
'subscriptionid' => null,
'location' => 'Test location',
]
]
];
Expand Down Expand Up @@ -567,7 +572,8 @@ protected function get_dbrow_from_skeleton($skeleton) {
'timesort' => 1486396800,
'visible' => 1,
'timemodified' => 1485793098,
'subscriptionid' => null
'subscriptionid' => null,
'location' => 'Test location',
];

foreach ((array) $skeleton as $key => $value) {
Expand Down
24 changes: 16 additions & 8 deletions calendar/tests/event_factory_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ function () {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => 1,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
]
);
}
Expand Down Expand Up @@ -177,7 +178,8 @@ function () {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => 1,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
]
);
}
Expand Down Expand Up @@ -226,7 +228,8 @@ function () {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => 1,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
]
);
}
Expand Down Expand Up @@ -275,7 +278,8 @@ function () {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => 1,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
]
);

Expand Down Expand Up @@ -330,7 +334,8 @@ function () {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => 1,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
]
);

Expand Down Expand Up @@ -364,7 +369,8 @@ public function create_instance_testcases() {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => true,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
],
'actioncallbackapplier' => function(event_interface $event) {
$event->testattribute = 'Hello';
Expand Down Expand Up @@ -398,7 +404,8 @@ public function create_instance_testcases() {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => true,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
],
'actioncallbackapplier' => function(event_interface $event) {
$event->testattribute = 'Hello';
Expand Down Expand Up @@ -432,7 +439,8 @@ public function create_instance_testcases() {
'timemodified' => 123456789,
'timesort' => 123456789,
'visible' => true,
'subscriptionid' => 1
'subscriptionid' => 1,
'location' => 'Test location',
],
'actioncallbackapplier' => function(event_interface $event) {
$event->testattribute = 'Hello';
Expand Down
Loading

0 comments on commit a746b6e

Please sign in to comment.