From 2973ed5de1ac4d20714d652b86968cfdf3ff5829 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 11 Jun 2006 17:26:54 +0000 Subject: [PATCH] fixed birthday reminder and made the days, it shows birthdays in advance, configurable --- .../inc/class.contacts_admin_prefs.inc.php | 11 +- addressbook/inc/hook_home.inc.php | 138 +++++++++--------- addressbook/setup/phpgw_de.lang | 7 +- addressbook/setup/phpgw_en.lang | 7 +- 4 files changed, 86 insertions(+), 77 deletions(-) diff --git a/addressbook/inc/class.contacts_admin_prefs.inc.php b/addressbook/inc/class.contacts_admin_prefs.inc.php index b7b004aeed..e77afbf753 100644 --- a/addressbook/inc/class.contacts_admin_prefs.inc.php +++ b/addressbook/inc/class.contacts_admin_prefs.inc.php @@ -116,10 +116,17 @@ class contacts_admin_prefs function settings() { $GLOBALS['settings']['mainscreen_showbirthdays'] = array( - 'type' => 'check', + 'type' => 'select', 'label' => 'Show birthday reminders on main screen', 'name' => 'mainscreen_showbirthdays', - 'help' => 'Displays a remider for birthdays happening today or tomorrow on the startpage (page you get when you enter eGroupWare or click on the homepage icon).', + 'help' => 'Displays a remider for birthdays on the startpage (page you get when you enter eGroupWare or click on the homepage icon).', + 'values' => array( + 0 => lang('No'), + 1 => lang('Yes, for today and tomorrow'), + 3 => lang('Yes, for the next three days'), + 7 => lang('Yes, for the next week'), + 14=> lang('Yes, for the next two weeks'), + ), 'xmlrpc' => True, 'admin' => False, ); diff --git a/addressbook/inc/hook_home.inc.php b/addressbook/inc/hook_home.inc.php index 987a6b07f1..261e267612 100644 --- a/addressbook/inc/hook_home.inc.php +++ b/addressbook/inc/hook_home.inc.php @@ -1,45 +1,41 @@ + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License + * @version $Id$ + */ - $d1 = strtolower(substr(EGW_APP_INC,0,3)); - if($d1 == 'htt' || $d1 == 'ftp' ) +if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && + ($days = $GLOBALS['egw_info']['user']['preferences']['addressbook']['mainscreen_showbirthdays'])) +{ + echo "\n\n"; + + if (!(int) $days) $days = 1; // old pref + + include_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php'); + $contacts =& new bocontacts(); + + $month_start = date('*-m-*',$contacts->now_su-$days*24*3600); + $bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family'); + + if (($month_end = date('*-m-*',$contacts->now_su)) != $month_start) { - echo "Failed attempt to break in via an old Security Hole!
\n"; - $GLOBALS['egw']->common->phpgw_exit(); + if (($bdays2 =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family'))) + { + $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); + } + unset($bdays2); } - unset($d1); + unset($month_start); unset($month_end); - if($GLOBALS['egw_info']['user']['apps']['addressbook'] - && $GLOBALS['egw_info']['user']['preferences']['addressbook']['mainscreen_showbirthdays']) + if ($bdays) { - echo "\n\n"; - - $c = CreateObject('phpgwapi.contacts'); - $qfields = array( - 'n_given' => 'n_given', - 'n_family' => 'n_family', - 'bday' => 'bday' - ); - $now = time() - ((60 * 60) * (int)$GLOBALS['egw_info']['user']['preferences']['common']['tz_offset']); - $today = $GLOBALS['egw']->common->show_date($now,'n/d/'); - - $bdays = $c->read(0,15,$qfields,$today,'tid=n','','',$GLOBALS['egw_info']['user']['account_id']); - - $title = '
'.lang('Birthdays').'
'; - $portalbox = CreateObject('phpgwapi.listbox', Array( - 'title' => $title, + 'title' => lang('Birthdays'), 'primary' => $GLOBALS['egw_info']['theme']['navbar_bg'], 'secondary' => $GLOBALS['egw_info']['theme']['navbar_bg'], 'tertiary' => $GLOBALS['egw_info']['theme']['navbar_bg'], @@ -50,59 +46,55 @@ ); $app_id = $GLOBALS['egw']->applications->name2id('addressbook'); $GLOBALS['portal_order'][] = $app_id; - $var = Array( + foreach(Array( 'up' => Array('url' => '/set_box.php', 'app' => $app_id), 'down' => Array('url' => '/set_box.php', 'app' => $app_id), 'close' => Array('url' => '/set_box.php', 'app' => $app_id), 'question' => Array('url' => '/set_box.php', 'app' => $app_id), 'edit' => Array('url' => '/set_box.php', 'app' => $app_id) - ); - - while(list($key,$value) = each($var)) + ) as $key => $contactue) { - $portalbox->set_controls($key,$value); + $portalbox->set_controls($key,$contactue); } - $portalbox->data = Array(); - - while(list($key,$val) = @each($bdays)) + for($n = 0; $n <= $days; ++$n) { - if(substr($val['bday'],0,strlen($today)) == $today) + $day = date('-m-d',$contacts->now_su+$n*24*3600); + foreach($bdays as $contact) { - $portalbox->data[] = array( - 'text' => lang("Today is %1's birthday!", $val['n_given'] . ' ' . $val['n_family']), - 'link' => $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $val['id']) - ); + if(substr($contact['bday'],-6) == $day) + { + switch($n) + { + case 0: + $text = lang("Today is %1's birthday!", $contact['n_given'].' '.$contact['n_family']); + break; + case 1: + $text = lang("Tomorrow is %1's birthday.", $contact['n_given'].' '.$contact['n_family']); + break; + default: + list($y,$m,$d) = explode('-',$contact['bday']); + $text = lang("In %1 days (%2) is %3's birthday.",$n, + $GLOBALS['egw']->common->dateformatorder($y,$m,$d,true), + $contact['n_given'].' '.$contact['n_family']); + break; + } + $portalbox->data[] = array( + 'text' => $text, + 'link' => $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $contact['id']) + ); + } } -// $tmp = '' -// . $val['n_given'] . ' ' . $val['n_family'] . ''; -// echo '' . lang("Today is %1's birthday!", $tmp) . '' . "\n"; - } - - $tomorrow = $GLOBALS['egw']->common->show_date($now + 86400,'n/d/'); - - $bdays = $c->read(0,15,$qfields,$tomorrow,'tid=n','','',$GLOBALS['egw_info']['user']['account_id']); - - while(list($key,$val) = @each($bdays)) - { - if(substr($val['bday'],0,strlen($tomorrow)) == $tomorrow) - { - $portalbox->data[] = array( - 'text' => lang("Tomorrow is %1's birthday.",$val['n_given'] . ' ' . $val['n_family']), - 'link' => $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='.$val['id']) - ); - } -// $tmp = '' -// . $val['n_given'] . ' ' . $val["n_family"] . ''; -// echo '' . lang("Tomorrow is %1's birthday.", $tmp) . '' . "\n"; } if(count($portalbox->data)) { echo $portalbox->draw(); } - unset($portalbox); - echo "\n\n"; + unset($portalbox); + unset($days); unset($day); + unset($n); unset($y); unset($m); unset($d); } -?> + unset($contacts); unset($bdays); + + echo "\n\n"; +} \ No newline at end of file diff --git a/addressbook/setup/phpgw_de.lang b/addressbook/setup/phpgw_de.lang index c33e8b3af6..0288fea425 100644 --- a/addressbook/setup/phpgw_de.lang +++ b/addressbook/setup/phpgw_de.lang @@ -85,7 +85,7 @@ deleted addressbook de gel deletes the photo addressbook de Löscht das Foto department common de Abteilung departments addressbook de Abteilungen -displays a remider for birthdays happening today or tomorrow on the startpage (page you get when you enter egroupware or click on the homepage icon). addressbook de Zeigt auf der Startseite eine Geburtstags Erinnerung an, falls heute oder morgen jemand Geburtstag hat. Die Startseite ist die Seite die Sie sehen, wenn Sie eGroupWare betreten oder auf das Startseiten Icon (Haus) klicken. +displays a remider for birthdays on the startpage (page you get when you enter egroupware or click on the homepage icon). addressbook de Zeigt auf der Startseite eine Geburtstags Erinnerung an. Die Startseite ist die Seite die Sie sehen, wenn Sie eGroupWare betreten oder auf das Startseiten Icon (Haus) klicken. do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook? addressbook de Wollen Sie ein privates Adressbuch, dass nicht von Benutzern einsehbar ist, denen Sie Zugriff auf Ihr persönliches Adressbuch gegeben haben? do your really want to delete this contact? addressbook de Wollen sie diesen Kontakt wirklich löschen? doesn't matter addressbook de egal @@ -146,6 +146,7 @@ import from outlook addressbook de Aus Outlook importieren import multiple vcard addressbook de Import mehrere VCards import next set addressbook de Nächsten Satz importieren import_instructions addressbook de In Netscape, öffnen Sie das Adressbuch und wählen Sie Exportieren aus dem Datei Menü aus. Die Dateien werden im LDIF Formaz exportiert.

In Outlook wählen Sie den Ordner Kontakte aus, wählen Sie Importieren und Exportieren...

aus dem Datei Menü aus und Exportieren Sie die Kontakte als eine CSV Datei.

In Palm Desktop 4.0 oder größer, öffnen Sie Ihr Adressbuch und wählen Sie Export aus dem Datei-Menü aus. Die Datei wird im VCard-Format exportiert. +in %1 days (%2) is %3's birthday. addressbook de In %1 Tagen (%2) ist der Geburtstag von %3. income addressbook de Einkommen international addressbook de International label addressbook de Adressetikett @@ -248,6 +249,10 @@ which fields should be exported. all means every field stored in the addressbook whole query addressbook de gesamte Abfrage work phone addressbook de Tel dienstl. write (update or add) a single entry by passing the fields. addressbook de Schreibt (aktualiseren oder zufügen) eines einzelnen Eintrags durch Übergabe der Felder +yes, for the next three days addressbook de Ja, für die nächsten drei Tage +yes, for the next two weeks addressbook de Ja, für die nächsten zwei Wochen +yes, for the next week addressbook de Ja, für die nächste Woche +yes, for today and tomorrow addressbook de Ja, für heute und morgen you are not permitted to delete contact %1 addressbook de Sie haben nicht die Berechtigungen um den Kontakt %1 zu löschen you are not permittet to delete this contact addressbook de Sie haben nicht die Berechtigung diesen Kontakt zu löschen you are not permittet to edit this contact addressbook de Sie haben nicht die Berechtigung diesen Kontakt zu bearbeiten diff --git a/addressbook/setup/phpgw_en.lang b/addressbook/setup/phpgw_en.lang index 1afac96379..1336d5d668 100644 --- a/addressbook/setup/phpgw_en.lang +++ b/addressbook/setup/phpgw_en.lang @@ -85,7 +85,7 @@ deleted addressbook en deleted deletes the photo addressbook en Deletes the photo department common en Department departments addressbook en departments -displays a remider for birthdays happening today or tomorrow on the startpage (page you get when you enter egroupware or click on the homepage icon). addressbook en Displays a remider for birthdays happening today or tomorrow on the startpage (page you get when you enter eGroupWare or click on the homepage icon). +displays a remider for birthdays on the startpage (page you get when you enter egroupware or click on the homepage icon). addressbook en Displays a remider for birthdays on the startpage (page you get when you enter eGroupWare or click on the homepage icon). do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook? addressbook en Do you want a private addressbook, which can not be viewed by users, you grant access to your personal addressbook? do your really want to delete this contact? addressbook en Do your really want to delete this contact? doesn't matter addressbook en doesn't matter @@ -146,6 +146,7 @@ import from outlook addressbook en Import from Outlook import multiple vcard addressbook en Import Multiple VCard import next set addressbook en Import next set import_instructions addressbook en In Netscape, open the Addressbook and select Export from the File menu. The file exported will be in LDIF format.

Or, in Outlook, select your Contacts folder, select Import and Export... from the File menu and export your contacts into a comma separated text (CSV) file.

Or, in Palm Desktop 4.0 or greater, visit your addressbook and select Export from the File menu. The file exported will be in VCard format. +in %1 days (%2) is %3's birthday. addressbook en In %1 days (%2) is %3's birthday. income addressbook en Income international addressbook en International label addressbook en Label @@ -248,6 +249,10 @@ which fields should be exported. all means every field stored in the addressbook whole query addressbook en whole query work phone addressbook en Work Phone write (update or add) a single entry by passing the fields. addressbook en Write (update or add) a single entry by passing the fields. +yes, for the next three days addressbook en Yes, for the next three days +yes, for the next two weeks addressbook en Yes, for the next two weeks +yes, for the next week addressbook en Yes, for the next week +yes, for today and tomorrow addressbook en Yes, for today and tomorrow you are not permitted to delete contact %1 addressbook en You are not permitted to delete contact %1 you are not permittet to delete this contact addressbook en You are not permittet to delete this contact you are not permittet to edit this contact addressbook en You are not permittet to edit this contact