mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-51853_m33v3' of https://github.com/sbourget/moodle
This commit is contained in:
commit
4c6edf9dd8
@ -125,6 +125,13 @@ if ($eventid !== 0) {
|
||||
if (!calendar_add_event_allowed($event)) {
|
||||
print_error('nopermissions');
|
||||
}
|
||||
|
||||
// Check to see if this event is part of a subscription or import.
|
||||
// If so display a warning on edit.
|
||||
if (isset($event->subscriptionid) && ($event->subscriptionid != null)) {
|
||||
\core\notification::add(get_string('eventsubscriptioneditwarning', 'calendar'), \core\output\notification::NOTIFY_INFO);
|
||||
}
|
||||
|
||||
} else {
|
||||
$title = get_string('newevent', 'calendar');
|
||||
calendar_get_allowed_types($formoptions->eventtypes, $course);
|
||||
|
@ -1667,9 +1667,12 @@ function calendar_edit_event_allowed($event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// You cannot edit calendar subscription events presently.
|
||||
if (!empty($event->subscriptionid)) {
|
||||
return false;
|
||||
// You cannot edit URL based calendar subscription events presently.
|
||||
if (isset($event->subscriptionid)) {
|
||||
if (!empty($event->subscription->url)) {
|
||||
// This event can be updated externally, so it cannot be edited.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
|
@ -110,4 +110,17 @@ class behat_calendar extends behat_base {
|
||||
$todaysday = ltrim($todaysday, '0');
|
||||
return $this->i_hover_over_day_of_this_month_in_calendar($todaysday);
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to a specific date in the calendar.
|
||||
*
|
||||
* @Given /^I view the calendar for "(?P<month>\d+)" "(?P<year>\d+)"$/
|
||||
* @param int $month the month selected as a number
|
||||
* @param int $year the four digit year
|
||||
*/
|
||||
public function i_view_the_calendar_for($month, $year) {
|
||||
$time = make_timestamp($year, $month, 1);
|
||||
$this->getSession()->visit($this->locate_path('/calendar/view.php?view=month&course=1&time='.$time));
|
||||
|
||||
}
|
||||
}
|
||||
|
49
calendar/tests/behat/calendar_import.feature
Normal file
49
calendar/tests/behat/calendar_import.feature
Normal file
@ -0,0 +1,49 @@
|
||||
@core @core_calendar @_file_upload @javascript
|
||||
Feature: Import and edit calendar events
|
||||
In order to manipulate imported calendar events
|
||||
As an user
|
||||
I need to import calendar events then edit them.
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | format |
|
||||
| Course 1 | C1 | topics |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
|
||||
Scenario: Import then edit a calendar event.
|
||||
Given I log in as "teacher1"
|
||||
And I view the calendar for "1" "2016"
|
||||
And I press "Manage subscriptions"
|
||||
And I set the following fields to these values:
|
||||
| Calendar name | Test Import |
|
||||
| Import from | Calendar file (.ics) |
|
||||
| Type of event | User events |
|
||||
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
|
||||
And I press "Add"
|
||||
And I should see "Events imported: 2"
|
||||
And I view the calendar for "2" "2017"
|
||||
And I should see "February 2017"
|
||||
And I should see "Event on 2-15-2017"
|
||||
And I should see "Event on 2-25-2017"
|
||||
And I follow "Event on 2-15-2017"
|
||||
And I should see "Event source: Test Import"
|
||||
And I follow "Edit event"
|
||||
And I set the following fields to these values:
|
||||
| Event title | Event on 2-20-2017 |
|
||||
| Description | Event on 2-20-2017 |
|
||||
| timestart[day] | 20 |
|
||||
And I press "Save changes"
|
||||
When I view the calendar for "2" "2017"
|
||||
Then I should see "Event on 2-20-2017"
|
||||
And I should see "Event on 2-25-2017"
|
||||
And I should not see "Event on 2-15-2017"
|
||||
And I press "Manage subscriptions"
|
||||
And I press "Remove"
|
||||
And I view the calendar for "2" "2017"
|
||||
And I should not see "Event on 2-25-2017"
|
||||
And I should not see "Event on 2-20-2017"
|
25
calendar/tests/fixtures/import.ics
vendored
Normal file
25
calendar/tests/fixtures/import.ics
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
BEGIN:VCALENDAR
|
||||
METHOD:PUBLISH
|
||||
PRODID:-//John Papaioannou/NONSGML Bennu 0.1//EN
|
||||
VERSION:2.0
|
||||
BEGIN:VEVENT
|
||||
UID:198001@127.0.0.1:8888/moodle32
|
||||
SUMMARY:Event on 2-15-2017
|
||||
DESCRIPTION:Event on 2-15-2017
|
||||
CLASS:PUBLIC
|
||||
LAST-MODIFIED:20170226T014326Z
|
||||
DTSTAMP:20170226T014355Z
|
||||
DTSTART;VALUE=DATE:20170214
|
||||
DTEND;VALUE=DATE:20170215
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:198000@127.0.0.1:8888/moodle32
|
||||
SUMMARY:Event on 2-25-2017
|
||||
DESCRIPTION:Event on 2-25-2017
|
||||
CLASS:PUBLIC
|
||||
LAST-MODIFIED:20170226T014258Z
|
||||
DTSTAMP:20170226T014355Z
|
||||
DTSTART;VALUE=DATE:20170224
|
||||
DTEND;VALUE=DATE:20170225
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
@ -99,6 +99,7 @@ $string['eventcalendareventdeleted'] = 'Calendar event deleted';
|
||||
$string['eventsubscriptioncreated'] = 'Calendar subscription created';
|
||||
$string['eventsubscriptionupdated'] = 'Calendar subscription updated';
|
||||
$string['eventsubscriptiondeleted'] = 'Calendar subscription deleted';
|
||||
$string['eventsubscriptioneditwarning'] = 'This calendar event is part of a subscription. Any changes you make to this event will be lost if the subscription is deleted.';
|
||||
$string['expired'] = 'Expired';
|
||||
$string['explain_site_timeformat'] = 'You can choose to see times in either 12 or 24 hour format for the whole site. If you choose "default", then the format will be automatically chosen according to the language you use in the site. This setting can be overridden by user preferences.';
|
||||
$string['export'] = 'Export';
|
||||
|
Loading…
x
Reference in New Issue
Block a user