public function saveEvent($event)
{
/* Check for acceptence/denial of resources */
- $event->checkResources();
if ($event->isStored() || $event->exists()) {
$values = array();
return PEAR::raiseError('Event not yet initialized');
}
+ // TODO: Should this go here?
+ Kronolith::checkResources($this);
$this->toDriver();
$result = $this->getDriver()->saveEvent($this);
if (!is_a($result, 'PEAR_Error') &&
return $this->_properties;
}
- /**
- * Function to check availability and auto accept/decline for each resource
- * attached to this event. Needed here instead of in Kronolith_Driver::saveEvent
- * since self::_properties is already built at that point, and since it's
- * not public, we need to access it from within this class.
- *
- * @return unknown_type
- */
- public function checkResources()
- {
- foreach ($this->_resources as $id => $resource) {
- $r = Kronolith::getDriver('Resource')->getResource($id);
- if ($r->isFree($this)) {
- $r->addEvent($this);
- $this->addResource($r, Kronolith::RESPONSE_ACCEPTED);
- } else {
- $this->addResource($r, Kronolith::RESPONSE_DECLINED);
- }
- }
- $driver = $this->getDriver();
- $this->_properties['event_resources'] = serialize($driver->convertToDriver($this->_resources));
- }
-
}
return false;
}
+ /**
+ * Function to check availability and auto accept/decline for each resource
+ * attached to the event.
+ *
+ * @return unknown_type
+ */
+ static public function checkResources($event)
+ {
+ foreach ($event->getResources() as $id => $resource) {
+ $r = Kronolith::getDriver('Resource')->getResource($id);
+ if ($r->isFree($event)) {
+ $r->addEvent($event);
+ $event->addResource($r, Kronolith::RESPONSE_ACCEPTED);
+ } else {
+ $event->addResource($r, Kronolith::RESPONSE_DECLINED);
+ }
+ }
+ }
static public function getInternalCalendar($target)
{