Skip to content

Commit

Permalink
calendar MDL-22559 Fixed bug whereby calendar update was assuming a f…
Browse files Browse the repository at this point in the history
…ull event was being provided
  • Loading branch information
Sam Hemelryk committed May 27, 2010
1 parent 5233807 commit 438e4ad
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions calendar/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ function calendar_edit_event_allowed($event) {
}

// if groupid is set, it's definitely a group event
if ($event->groupid) {
if (!empty($event->groupid)) {
// Allow users to add/edit group events if:
// 1) They have manageentries (= entries for whole course)
// 2) They have managegroupentries AND are in the group
Expand All @@ -1399,11 +1399,11 @@ function calendar_edit_event_allowed($event) {
has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_COURSE, $group->courseid)) ||
(has_capability('moodle/calendar:managegroupentries', get_context_instance(CONTEXT_COURSE, $group->courseid))
&& groups_is_member($event->groupid)));
} else if ($event->courseid) {
} else if (!empty($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) {
} else if (!empty($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));
}
Expand Down Expand Up @@ -1905,7 +1905,10 @@ public function count_repeats() {
public function update($data) {
global $CFG, $DB, $USER;

$this->properties = (object)$data;
foreach ($data as $key=>$value) {
$this->properties->$key = $value;
}

$this->properties->timemodified = time();
$usingeditor = (!empty($this->properties->description) && is_array($this->properties->description));

Expand Down Expand Up @@ -2276,7 +2279,7 @@ public static function calendar_event_hook($action, array $args) {
if($extcalendarinc === false) {
return false;
}
$hook = $CFG->dirroot .'_'.$action;
$hook = $CFG->calendar .'_'.$action;
if (function_exists($hook)) {
call_user_func_array($hook, $args);
return true;
Expand Down

0 comments on commit 438e4ad

Please sign in to comment.