From: Michael J. Rubinsky Date: Tue, 8 Sep 2009 16:44:47 +0000 (-0400) Subject: Stqrt hashing out the isFree() method. Remove deprecated Resource.php file, phpdoc X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4949ce6b5caaae40c3a32d541aa18450b7330bc6;p=horde.git Stqrt hashing out the isFree() method. Remove deprecated Resource.php file, phpdoc --- diff --git a/kronolith/lib/Event/Sql.php b/kronolith/lib/Event/Sql.php index 93cd9818c..6d751e050 100644 --- a/kronolith/lib/Event/Sql.php +++ b/kronolith/lib/Event/Sql.php @@ -210,7 +210,7 @@ class Kronolith_Event_Sql extends Kronolith_Event /** * Function to check availability and auto accept/decline for each resource * attached to this event. Needed here instead of in Kronolith_Driver::saveEvent - * since the _properties array is already built at that point. + * since self::_properties is already built at that point. * * @return unknown_type */ diff --git a/kronolith/lib/Resource.php b/kronolith/lib/Resource.php deleted file mode 100644 index db84dda90..000000000 --- a/kronolith/lib/Resource.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @package Kronolith - */ -class Kronolith_Resource -{ - static protected $_driver; - - /** - * Removes a resource from storage - * - * @param Kronolith_Resource $resource - * @return boolean - * @throws Horde_Exception - */ - static public function removeResource($resource) - { - - } - - static public function isResourceCalendar($calendar) - { - if (strncmp($calendar, 'resource_', 9) === 0) { - return true; - } - } - -} \ No newline at end of file diff --git a/kronolith/lib/Resource/Single.php b/kronolith/lib/Resource/Single.php index f22da70eb..8f942ecac 100644 --- a/kronolith/lib/Resource/Single.php +++ b/kronolith/lib/Resource/Single.php @@ -22,6 +22,30 @@ 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, $this->calendar); + if (is_a($busy, 'PEAR_Error')) { + return $busy; + } + + if (!count($busy)) { + return true; + } + + foreach ($busy as $e) { + if (!($e->hasStatus(Kronolith::STATUS_CANCELLED) || + $e->hasStatus(Kronolith::STATUS_FREE))) { + + return false; + } + } + + $event->setStatus($old_status); return true; } @@ -41,7 +65,9 @@ class Kronolith_Resource_Single extends Kronolith_Resource_Base $uid = $event->getUID(); $existing = $driver->getByUID($uid, array($this->calendar)); if (!($existing instanceof PEAR_Error)) { + /* Already attached, just update */ $existing->fromiCalendar($event->toiCalendar(new Horde_iCalendar('2.0'))); + $existing->status = $event->status; $existing->save(); } else { /* Create a new event */ diff --git a/kronolith/resources.php b/kronolith/resources.php index 7dd71a9c0..cffeebe39 100644 --- a/kronolith/resources.php +++ b/kronolith/resources.php @@ -72,10 +72,10 @@ var_dump($resources); $resource = Kronolith::getDriver('Resource')->getResource(9); /* Any driver/event */ -$driver = Kronolith::getDriver('Sql'); -$event = $driver->getByUID('20090903183552.146242hgs864c92c@localhost'); -$event->addResource($resource, Kronolith::RESPONSE_NONE); -$event->save(); +//$driver = Kronolith::getDriver('Sql'); +//$event = $driver->getByUID('20090904121938.17551lvwtt52y728@localhost'); +//$event->addResource($resource, Kronolith::RESPONSE_NONE); +//$event->save(); //