From: Michael J. Rubinsky Date: Wed, 9 Sep 2009 00:02:28 +0000 (-0400) Subject: Easier way of exlcuding the current event from checking resource availability. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=86603fa19971fc310bf10ccf074688d35a93a22f;p=horde.git Easier way of exlcuding the current event from checking resource availability. --- diff --git a/kronolith/lib/Resource/Single.php b/kronolith/lib/Resource/Single.php index 63b36f261..3b0156dc1 100644 --- a/kronolith/lib/Resource/Single.php +++ b/kronolith/lib/Resource/Single.php @@ -22,32 +22,31 @@ class Kronolith_Resource_Single extends Kronolith_Resource_Base */ public function isFree($event) { - // Need to make sure to remove the $event's fb info from this calendar - // before checking...otherwise, if it's an update the time will block. - $old_status = $event->status; - $event->setStatus(Kronolith::STATUS_FREE); - /* Fetch events. */ $busy = Kronolith::listEvents($event->start, $event->end, array($this->calendar)); if ($busy instanceof PEAR_Error) { throw new Horde_Exception($busy->getMessage()); } + /* No events at all during time period for requested event */ if (!count($busy)) { return true; } - foreach ($busy as $e) { - if (!($e->hasStatus(Kronolith::STATUS_CANCELLED) || - $e->hasStatus(Kronolith::STATUS_FREE))) { + /* Check for conflicts, ignoring the conflict if it's for the + * same event that is passed. */ + $uid = $event->getUID(); + foreach ($busy as $events) { + foreach ($events as $e) { + if (!($e->hasStatus(Kronolith::STATUS_CANCELLED) || + $e->hasStatus(Kronolith::STATUS_FREE)) && + $e->getUID() !== $uid) { - $event-SetStatus($old_status); - return false; + return false; + } } } - $event->setStatus($old_status); - return true; }