From c0a2c3615729e1d39d6ae138e6dc07080294076b Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Thu, 5 Apr 2007 07:58:31 +0000 Subject: [PATCH] fix for MDL-9186, capability fix for calendar --- calendar/lib.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/calendar/lib.php b/calendar/lib.php index af5e5c50ed..a00291ba73 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -1191,13 +1191,9 @@ function calendar_edit_event_allowed($event) { if (has_capability('moodle/calendar:manageentries', $sitecontext)) { return true; } - - // editting userid account - if ($event->userid) { - if ($event->userid == $USER->id) { - return (has_capability('moodle/calendar:manageownentries', $sitecontext)); - } - } else if ($event->groupid) { + + // if groupid is set, it's definitely a group event + if ($event->groupid) { //TODO:check. if (! groups_group_exists($event->groupid)) { return false; @@ -1207,10 +1203,15 @@ function calendar_edit_event_allowed($event) { // to edit group calendar too // there is no need to check membership, because if you have this capability // you will have a role in this group context - return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_GROUP, $event->groupid)); + return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_GROUP, $event->groupid)); } else if ($event->courseid) { - return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid)); - } + // if groupid is not set, but course is set, + // it's definiely a course event + return has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $event->courseid)); + } else if ($event->userid && $event->userid == $USER->id) { + // if course is not set, but userid id set, it's a user event + return (has_capability('moodle/calendar:manageownentries', $sitecontext)); + } return false; } -- 2.39.5