/**
* 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
*/
+++ /dev/null
-<?php
-/**
- * Base class for dealing with Kronolith_Resource objects. Handles basic
- * creation/deletion/listing by delegating to the underlying Kronolith_Driver
- * object.
- *
- * For now, assume SQL driver only. Could probably easily extend this to use
- * different backend drivers if/when support is added to those drivers for
- * resources.
- *
- * Copyright 2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- * @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
*/
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;
}
$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 */
$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();
//