Performance: Use initialized calendars if available, skipping redundant folder cache synchronization
This commit is contained in:
parent
a7e3a938a7
commit
cb7f4d635b
2 changed files with 22 additions and 10 deletions
|
@ -346,13 +346,16 @@ class kolab_driver extends calendar_driver
|
|||
$this->_read_calendars();
|
||||
|
||||
// create calendar object if necesary
|
||||
if (!$this->calendars[$id] && in_array($id, array(self::INVITATIONS_CALENDAR_PENDING, self::INVITATIONS_CALENDAR_DECLINED))) {
|
||||
$this->calendars[$id] = new kolab_invitation_calendar($id, $this->cal);
|
||||
}
|
||||
else if (!$this->calendars[$id] && $id !== self::BIRTHDAY_CALENDAR_ID) {
|
||||
$calendar = kolab_calendar::factory($id, $this->cal);
|
||||
if ($calendar->ready)
|
||||
$this->calendars[$calendar->id] = $calendar;
|
||||
if (!$this->calendars[$id]) {
|
||||
if (in_array($id, array(self::INVITATIONS_CALENDAR_PENDING, self::INVITATIONS_CALENDAR_DECLINED))) {
|
||||
$this->calendars[$id] = new kolab_invitation_calendar($id, $this->cal);
|
||||
}
|
||||
else if ($id !== self::BIRTHDAY_CALENDAR_ID) {
|
||||
$calendar = kolab_calendar::factory($id, $this->cal);
|
||||
if ($calendar->ready) {
|
||||
$this->calendars[$calendar->id] = $calendar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->calendars[$id];
|
||||
|
|
|
@ -197,7 +197,7 @@ class kolab_invitation_calendar
|
|||
else {
|
||||
$cal = null;
|
||||
foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) {
|
||||
$cal = new kolab_calendar($foldername, $this->cal);
|
||||
$cal = $this->_get_calendar($foldername);
|
||||
if ($cal->ready && $cal->storage && $cal->get_event($event['id'])) {
|
||||
break;
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ class kolab_invitation_calendar
|
|||
// aggregate events from all calendar folders
|
||||
$events = array();
|
||||
foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) {
|
||||
$cal = new kolab_calendar($foldername, $this->cal);
|
||||
$cal = $this->_get_calendar($foldername);
|
||||
if ($cal->get_namespace() == 'other')
|
||||
continue;
|
||||
|
||||
|
@ -287,7 +287,7 @@ class kolab_invitation_calendar
|
|||
// aggregate counts from all calendar folders
|
||||
$count = 0;
|
||||
foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) {
|
||||
$cal = new kolab_calendar($foldername, $this->cal);
|
||||
$cal = $this->_get_calendar($foldername);
|
||||
if ($cal->get_namespace() == 'other')
|
||||
continue;
|
||||
|
||||
|
@ -297,6 +297,15 @@ class kolab_invitation_calendar
|
|||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get calendar object instance (that maybe already initialized)
|
||||
*/
|
||||
private function _get_calendar($folder_name)
|
||||
{
|
||||
$id = kolab_storage::folder_id($folder_name, true);
|
||||
return $this->cal->driver->get_calendar($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to modify some event properties
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue