- Fix updating birthday events
- Use address book search to fetch contacts with birthday values only
Attention: this requires changes from [0950ff12dc
] and clearing the cache
for Kolab contact objects:
DELETE FROM kolab_folders WHERE type='contact';
This commit is contained in:
parent
0950ff12dc
commit
2230e97ee9
4 changed files with 13 additions and 7 deletions
|
@ -653,7 +653,7 @@ class calendar extends rcube_plugin
|
||||||
'calendar_date_format' => null, // clear previously saved values
|
'calendar_date_format' => null, // clear previously saved values
|
||||||
'calendar_time_format' => null,
|
'calendar_time_format' => null,
|
||||||
'calendar_contact_birthdays' => get_input_value('_contact_birthdays', RCUBE_INPUT_POST) ? true : false,
|
'calendar_contact_birthdays' => get_input_value('_contact_birthdays', RCUBE_INPUT_POST) ? true : false,
|
||||||
'calendar_birthday_adressbooks' => array_filter((array)get_input_value('_birthday_adressbooks', RCUBE_INPUT_POST)),
|
'calendar_birthday_adressbooks' => (array)get_input_value('_birthday_adressbooks', RCUBE_INPUT_POST),
|
||||||
'calendar_birthdays_alarm_type' => get_input_value('_birthdays_alarm_type', RCUBE_INPUT_POST),
|
'calendar_birthdays_alarm_type' => get_input_value('_birthdays_alarm_type', RCUBE_INPUT_POST),
|
||||||
'calendar_birthdays_alarm_offset' => $birthdays_alarm_value ?: null,
|
'calendar_birthdays_alarm_offset' => $birthdays_alarm_value ?: null,
|
||||||
);
|
);
|
||||||
|
|
|
@ -412,10 +412,16 @@ abstract class calendar_driver
|
||||||
* @param integer Event's new start (unix timestamp)
|
* @param integer Event's new start (unix timestamp)
|
||||||
* @param integer Event's new end (unix timestamp)
|
* @param integer Event's new end (unix timestamp)
|
||||||
* @param string Search query (optional)
|
* @param string Search query (optional)
|
||||||
|
* @param integer Only list events modified since this time (unix timestamp)
|
||||||
* @return array A list of event records
|
* @return array A list of event records
|
||||||
*/
|
*/
|
||||||
public function load_birthday_events($start, $end, $search = null)
|
public function load_birthday_events($start, $end, $search = null, $modifiedsince = null)
|
||||||
{
|
{
|
||||||
|
// ignore update requests for simplicity reasons
|
||||||
|
if (!empty($modifiedsince)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
// convert to DateTime for comparisons
|
// convert to DateTime for comparisons
|
||||||
$start = new DateTime('@'.$start);
|
$start = new DateTime('@'.$start);
|
||||||
$end = new DateTime('@'.$end);
|
$end = new DateTime('@'.$end);
|
||||||
|
@ -451,7 +457,7 @@ abstract class calendar_driver
|
||||||
$cached = $cache->get($source);
|
$cached = $cache->get($source);
|
||||||
|
|
||||||
// iterate over (cached) contacts
|
// iterate over (cached) contacts
|
||||||
foreach (($cached ?: $abook->list_records()) as $contact) {
|
foreach (($cached ?: $abook->search('*', '', 2, true, true, array('birthday'))) as $contact) {
|
||||||
if (is_array($contact) && !empty($contact['birthday'])) {
|
if (is_array($contact) && !empty($contact['birthday'])) {
|
||||||
try {
|
try {
|
||||||
if (is_array($contact['birthday']))
|
if (is_array($contact['birthday']))
|
||||||
|
@ -472,7 +478,7 @@ abstract class calendar_driver
|
||||||
// add stripped record to cache
|
// add stripped record to cache
|
||||||
if (empty($cached)) {
|
if (empty($cached)) {
|
||||||
$cache_records[] = array(
|
$cache_records[] = array(
|
||||||
'id' => $contact['ID'],
|
'ID' => $contact['ID'],
|
||||||
'name' => $display_name,
|
'name' => $display_name,
|
||||||
'birthday' => $bday->format('Y-m-d'),
|
'birthday' => $bday->format('Y-m-d'),
|
||||||
);
|
);
|
||||||
|
@ -497,7 +503,7 @@ abstract class calendar_driver
|
||||||
if ($bday <= $end && $bday >= $start) {
|
if ($bday <= $end && $bday >= $start) {
|
||||||
$age = $year - $birthyear;
|
$age = $year - $birthyear;
|
||||||
$event = array(
|
$event = array(
|
||||||
'id' => md5('bday_' . $contact['id'] . $year),
|
'id' => md5('bday_' . $contact['ID'] . $year),
|
||||||
'calendar' => self::BIRTHDAY_CALENDAR_ID,
|
'calendar' => self::BIRTHDAY_CALENDAR_ID,
|
||||||
'title' => $event_title,
|
'title' => $event_title,
|
||||||
'description' => $rcmail->gettext(array('name' => 'birthdayage', 'vars' => array('age' => $age)), 'calendar'),
|
'description' => $rcmail->gettext(array('name' => 'birthdayage', 'vars' => array('age' => $age)), 'calendar'),
|
||||||
|
|
|
@ -813,7 +813,7 @@ class database_driver extends calendar_driver
|
||||||
|
|
||||||
// add events from the address books birthday calendar
|
// add events from the address books birthday calendar
|
||||||
if (in_array(self::BIRTHDAY_CALENDAR_ID, $calendars)) {
|
if (in_array(self::BIRTHDAY_CALENDAR_ID, $calendars)) {
|
||||||
$events = array_merge($events, $this->load_birthday_events($start, $end, $search));
|
$events = array_merge($events, $this->load_birthday_events($start, $end, $search, $modifiedsince));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
|
|
|
@ -758,7 +758,7 @@ class kolab_driver extends calendar_driver
|
||||||
|
|
||||||
// add events from the address books birthday calendar
|
// add events from the address books birthday calendar
|
||||||
if (in_array(self::BIRTHDAY_CALENDAR_ID, $calendars)) {
|
if (in_array(self::BIRTHDAY_CALENDAR_ID, $calendars)) {
|
||||||
$events = array_merge($events, $this->load_birthday_events($start, $end, $search));
|
$events = array_merge($events, $this->load_birthday_events($start, $end, $search, $modifiedsince));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add new categories to user prefs
|
// add new categories to user prefs
|
||||||
|
|
Loading…
Add table
Reference in a new issue