Clear birthdays calendar cache when contact is updated
This commit is contained in:
parent
4112437fe9
commit
b9ed08ce78
2 changed files with 21 additions and 3 deletions
|
@ -182,6 +182,12 @@ class calendar extends rcube_plugin
|
|||
$this->api->output->add_label('calendar.createfrommail');
|
||||
}
|
||||
}
|
||||
else if ($args['task'] == 'addressbook') {
|
||||
if ($this->rc->config->get('calendar_contact_birthdays')) {
|
||||
$this->add_hook('contact_update', array($this, 'contact_update'));
|
||||
$this->add_hook('contact_create', array($this, 'contact_update'));
|
||||
}
|
||||
}
|
||||
|
||||
// add hooks to display alarms
|
||||
$this->add_hook('pending_alarms', array($this, 'pending_alarms'));
|
||||
|
@ -1004,6 +1010,18 @@ class calendar extends rcube_plugin
|
|||
$this->rc->output->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook triggered when a contact is saved
|
||||
*/
|
||||
function contact_update($p)
|
||||
{
|
||||
// clear birthdays calendar cache
|
||||
if (!empty($p['record']['birthday'])) {
|
||||
$cache = $this->rc->get_cache('calendar.birthdays', 'db');
|
||||
$cache->remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -444,8 +444,8 @@ abstract class calendar_driver
|
|||
$cached = $cache->get($source['id']);
|
||||
|
||||
// iterate over (cached) contacts
|
||||
foreach ((array)($cached ?: $abook->list_records()) as $contact) {
|
||||
if (!empty($contact['birthday'])) {
|
||||
foreach (($cached ?: $abook->list_records()) as $contact) {
|
||||
if (is_array($contact) && !empty($contact['birthday'])) {
|
||||
try {
|
||||
if (is_array($contact['birthday']))
|
||||
$contact['birthday'] = reset($contact['birthday']);
|
||||
|
@ -455,7 +455,7 @@ abstract class calendar_driver
|
|||
$birthyear = $bday->format('Y');
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// console('BIRTHDAY PARSE ERROR: ' . $e);
|
||||
console('BIRTHDAY PARSE ERROR: ' . $e);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue