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');
|
$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
|
// add hooks to display alarms
|
||||||
$this->add_hook('pending_alarms', array($this, 'pending_alarms'));
|
$this->add_hook('pending_alarms', array($this, 'pending_alarms'));
|
||||||
|
@ -1004,6 +1010,18 @@ class calendar extends rcube_plugin
|
||||||
$this->rc->output->send();
|
$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']);
|
$cached = $cache->get($source['id']);
|
||||||
|
|
||||||
// iterate over (cached) contacts
|
// iterate over (cached) contacts
|
||||||
foreach ((array)($cached ?: $abook->list_records()) as $contact) {
|
foreach (($cached ?: $abook->list_records()) as $contact) {
|
||||||
if (!empty($contact['birthday'])) {
|
if (is_array($contact) && !empty($contact['birthday'])) {
|
||||||
try {
|
try {
|
||||||
if (is_array($contact['birthday']))
|
if (is_array($contact['birthday']))
|
||||||
$contact['birthday'] = reset($contact['birthday']);
|
$contact['birthday'] = reset($contact['birthday']);
|
||||||
|
@ -455,7 +455,7 @@ abstract class calendar_driver
|
||||||
$birthyear = $bday->format('Y');
|
$birthyear = $bday->format('Y');
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
// console('BIRTHDAY PARSE ERROR: ' . $e);
|
console('BIRTHDAY PARSE ERROR: ' . $e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue