/**
* Synchronize kolab storage backend.
*
* We delay initial synchronization to the first use so multiple calendars
* don't add to the total latency. This function must be called before all
* internal driver functions.
*
* @param boolean $force If true, forces synchronization, even if we have
* already done so.
*/
public function synchronize($force = false)
{
if ($this->_synchronized && !$force) {
return;
}
// Connect to the Kolab backend
try {
$this->_data = $this->_kolab->getData($GLOBALS['calendar_manager']->getEntry(Kronolith::ALL_CALENDARS, $this->calendar)->share()->get('folder'), 'event');
} catch (Kolab_Storage_Exception $e) {
throw new Kronolith_Exception($e);
}
// build internal event cache
$this->_events_cache = $uids = array();
$events = $this->_data->getObjects();
foreach ($events as $event) {
$this->_events_cache[Horde_Url::uriB64Encode($event['uid'])] = new Kronolith_Event_Kolab($this, $event);
$uids[] = $event['uid'];
}
$tags = Kronolith::getTagger()->getTags(array_unique($uids));
foreach ($this->_events_cache as &$event) {
if (isset($tags[$event->uid])) {
$event->synchronizeTags($tags[$event->uid]);
}
}
$this->_synchronized = true;
}