*/
public function saveEvent($event)
{
+ /* Deal with Kronolith_Resources before anything else is done */
+ foreach ($event->getResources() as $resource) {
+ if ($resource->isFree($this)) {
+ $resource->attachToEvent($this);
+ $event->addResource($resource, Kronolith::RESPONSE_ACCEPTED);
+ } else {
+ $event->addResource($resource, Kronolith::RESPONSE_DECLINED);
+ }
+ }
+
if ($event->isStored() || $event->exists()) {
$values = array();
public $attendees = array();
/**
+ * All resources of this event.
+ *
+ * This is an associative array where keys are resource uids values are
+ * associative arrays with keys attendance and response... actually, do we
+ * *need* an attendence setting for resources? Shouldn't they be required
+ * by definition?
+ *
+ * @var unknown_type
+ */
+ protected $_resources = array();
+
+ /**
* The start time of the event.
*
* @var Horde_Date
}
}
+ /**
+ * Adds a Kronolith_Resource to this event.
+ * No validation or acceptence/denial is done here...it should be done
+ * when saving the Event so we can capture any errors?
+ *
+ * @param Kronolith_Resource $resource The resource to add
+ *
+ * @return void
+ */
+ public function addResource($resource, $response)
+ {
+ $this->_resources[$resource->uid] = array(
+ 'attendance' => Kronolith::PART_REQUIRED,
+ 'response' => $response,
+ 'name' => $resource->name
+ );
+ }
+
+ /**
+ * Remove a Kronolith_Resource from this event
+ *
+ * @param Kronolith_Resource $resource The resource to remove
+ *
+ * @return void
+ */
+ function removeResource($resource)
+ {
+ if (isset($this->_resources[$resource->uid])) {
+ unset ($this->_resources[$resource->uid]);
+ }
+ }
+
+ /**
+ * Returns the entire resources array.
+ *
+ * @return array A copy of the attendees array.
+ */
+ public function getResources()
+ {
+ return $this->_resources;
+ }
+
+ /**
+ * Checks to see whether the specified resource is associated with this
+ * event.
+ *
+ * @param string $uid The resource uid.
+ *
+ * @return boolean True if the specified attendee is present for this
+ * event.
+ */
+ public function hasResource($uid)
+ {
+ return isset($this->_resources[$uid]);
+ }
+
public function isAllDay()
{
return $this->allday ||
if (isset($SQLEvent['event_attendees'])) {
$this->attendees = array_change_key_case($driver->convertFromDriver(unserialize($SQLEvent['event_attendees'])));
}
+ if (isset($SQLEvent['event_resources'])) {
+ $this->_resources = array_change_key_case($driver->convertFromDriver(unserialize($SQLEvent['event_resources'])));
+ }
if (isset($SQLEvent['event_description'])) {
$this->description = $driver->convertFromDriver($SQLEvent['event_description']);
}
$this->_properties['event_private'] = (int)$this->isPrivate();
$this->_properties['event_status'] = $this->getStatus();
$this->_properties['event_attendees'] = serialize($driver->convertToDriver($this->getAttendees()));
+ $this->_properties['event_resources'] = serialize($driver->convertToDriver($this->getResources()));
$this->_properties['event_modified'] = $_SERVER['REQUEST_TIME'];
if ($this->isAllDay()) {