Skip to content

Commit

Permalink
Tweak.
Browse files Browse the repository at this point in the history
Initialize variables. Don't modify existing event. Wrap.
  • Loading branch information
yunosh committed Oct 1, 2015
1 parent 1010943 commit 62457e6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions kronolith/lib/Ajax/Application/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public function saveEvent()
return $result;
}

$removed_attendees = $old_attendees = array();
if ($this->vars->recur_edit && $this->vars->recur_edit != 'all') {
switch ($this->vars->recur_edit) {
case 'current':
Expand All @@ -268,11 +269,11 @@ public function saveEvent()
$attributes->rend = $this->vars->rend;
$this->_addException($event, $attributes);

// Create a copy of the original event so we can read in the new
// form values for the exception. We also MUST reset the recurrence
// property even though we won't be using it, since clone() does not
// do a deep copy. Otherwise, the original event's recurrence will
// become corrupt.
// Create a copy of the original event so we can read in the
// new form values for the exception. We also MUST reset the
// recurrence property even though we won't be using it, since
// clone() does not do a deep copy. Otherwise, the original
// event's recurrence will become corrupt.
$newEvent = clone($event);
$newEvent->recurrence = new Horde_Date_Recurrence($event->start);
$newEvent->readForm($event);
Expand Down Expand Up @@ -311,7 +312,10 @@ public function saveEvent()
try {
$old_attendees = $event->attendees;
$event->readForm();
$removed_attendees = array_diff(array_keys($old_attendees), array_keys($event->attendees));
$removed_attendees = array_diff(
array_keys($old_attendees),
array_keys($event->attendees)
);
$result = $this->_saveEvent($event);
} catch (Exception $e) {
$GLOBALS['notification']->push($e);
Expand All @@ -320,15 +324,18 @@ public function saveEvent()
}

if (($result !== true) && $this->vars->sendupdates) {
$type = $event->status == Kronolith::STATUS_CANCELLED ? Kronolith::ITIP_CANCEL : Kronolith::ITIP_REQUEST;
$type = $event->status == Kronolith::STATUS_CANCELLED
? Kronolith::ITIP_CANCEL
: Kronolith::ITIP_REQUEST;
Kronolith::sendITipNotifications($event, $GLOBALS['notification'], $type);
}
if (!empty($removed_attendees)) {
foreach ($removed_attendees as $email) {
$to_cancel[$email] = $old_attendees[$email];
}
$event->attendees = $to_cancel;
Kronolith::sendITipNotifications($event, $GLOBALS['notification'], Kronolith::ITIP_CANCEL);
$cancelEvent = clone $event;
$cancelEvent->attendees = $to_cancel;
Kronolith::sendITipNotifications($cancelEvent, $GLOBALS['notification'], Kronolith::ITIP_CANCEL);
}
Kronolith::notifyOfResourceRejection($event);

Expand Down

0 comments on commit 62457e6

Please sign in to comment.