MDL-59393 calendar: stop user editing module events

This commit is contained in:
Ryan Wyllie 2017-08-18 05:29:07 +00:00
parent 5ca142dc5b
commit 909d08588d
5 changed files with 72 additions and 5 deletions

View file

@ -2435,9 +2435,10 @@ function calendar_set_filters(array $courseeventsfrom, $ignorefilters = false) {
* Return the capability for editing calendar event.
*
* @param calendar_event $event event object
* @param bool $manualedit is the event being edited manually by the user
* @return bool capability to edit event
*/
function calendar_edit_event_allowed($event) {
function calendar_edit_event_allowed($event, $manualedit = false) {
global $USER, $DB;
// Must be logged in.
@ -2450,6 +2451,12 @@ function calendar_edit_event_allowed($event) {
return false;
}
if ($manualedit && !empty($event->modulename)) {
// A user isn't allowed to directly edit an event generated
// by a module.
return false;
}
// You cannot edit URL based calendar subscription events presently.
if (!empty($event->subscriptionid)) {
if (!empty($event->subscription->url)) {