diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php index 9cca70d37c..29c47ca6ae 100644 --- a/addressbook/inc/class.addressbook_hooks.inc.php +++ b/addressbook/inc/class.addressbook_hooks.inc.php @@ -115,26 +115,6 @@ class addressbook_hooks 'xmlrpc' => True, 'admin' => False, ); - if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') // calendar config - { - /* disabled until we have a home app again - $settings['mainscreen_showbirthdays'] = array( - 'type' => 'select', - 'label' => 'Show birthday reminders on main screen', - 'name' => 'mainscreen_showbirthdays', - '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, - 'default'=> 3, - );*/ - } if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap') { $settings['private_addressbook'] = array( diff --git a/addressbook/inc/hook_home.inc.php b/addressbook/inc/hook_home.inc.php deleted file mode 100644 index c5c715aeeb..0000000000 --- a/addressbook/inc/hook_home.inc.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License - * @version $Id$ - */ - -if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && - ($days = $GLOBALS['egw_info']['user']['preferences']['addressbook']['mainscreen_showbirthdays']) && - $GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') -{ - echo "\n\n"; - - if (!(int) $days) $days = 1; // old pref - - $contacts = new addressbook_bo(); - - $month_start = date('-m-',$contacts->now_su); - $bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family','','%'); - // search accounts too, if not stored in accounts repository - $extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) && - !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']; - if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'), - 'n_given,n_family','','%',false,'AND',false,array('owner' => 0)))) - { - $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); - } - if (($month_end = date('-m-',$contacts->now_su+$days*24*3600)) != $month_start) - { - if (($bdays2 =& $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'),'n_given,n_family','','%'))) - { - $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); - } - // search accounts too, if not stored in accounts repository - if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'), - 'n_given,n_family','','%',false,'AND',false,array('owner' => 0)))) - { - $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); - } - } - unset($bdays2); unset($extra_accounts_search); - unset($month_start); unset($month_end); - - if ($bdays) - { - $portalbox = CreateObject('phpgwapi.listbox', - Array( - 'title' => lang('Birthdays'), - 'primary' => $GLOBALS['egw_info']['theme']['navbar_bg'], - 'secondary' => $GLOBALS['egw_info']['theme']['navbar_bg'], - 'tertiary' => $GLOBALS['egw_info']['theme']['navbar_bg'], - 'width' => '100%', - 'outerborderwidth' => '0', - 'header_background_image' => $GLOBALS['egw']->common->image($GLOBALS['egw']->common->get_tpl_dir('phpgwapi'),'bg_filler') - ) - ); - $app_id = $GLOBALS['egw']->applications->name2id('addressbook'); - $GLOBALS['portal_order'][] = $app_id; - 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) - ) as $key => $contactue) - { - $portalbox->set_controls($key,$contactue); - } - $portalbox->data = Array(); - foreach($bdays as $contact) $buff[$contact['id']] = $contact; - $bdays=$buff; - for($n = 0; $n <= $days; ++$n) - { - $day = date('-m-d',$contacts->now_su+$n*24*3600); - foreach($bdays as $contact) - { - if(substr($contact['bday'],-6) == $day) - { - if (!$ab_lang_loaded++) $GLOBALS['egw']->translation->add_app('addressbook'); - 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']); - if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = ''; - $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.addressbook_ui.view&contact_id=' . $contact['id']) - ); - } - } - } - if(count($portalbox->data)) - { - echo $portalbox->draw(); - } - unset($portalbox); - unset($days); unset($day); - unset($n); unset($y); unset($m); unset($d); - } - unset($contacts); unset($bdays); - - echo "\n\n"; -} diff --git a/home/inc/class.home_birthday_portlet.inc.php b/home/inc/class.home_birthday_portlet.inc.php new file mode 100644 index 0000000000..192199f9d4 --- /dev/null +++ b/home/inc/class.home_birthday_portlet.inc.php @@ -0,0 +1,197 @@ +context = $context; + } + + /** + * Some descriptive information about the portlet, so that users can decide if + * they want it or not, and for inclusion in lists, hover text, etc. + * + * These should be already translated, no further translation will be done. + * + * @return Array with keys: + * - displayName: Used in lists + * - title: Put in the portlet header + * - description: A short description of what this portlet does or displays + */ + public function get_description() + { + return array( + 'displayName'=> lang('Birthday reminders'), + 'title'=> lang('Birthday reminders'), + 'description'=> lang('Birthday reminders') + ); + } + + /** + * Generate a list of birthdays according to properties + * + * @param id String unique ID, provided to the portlet so it can make sure content is + * unique, if needed. + * @param etemplate etemplate_new Etemplate to generate content + */ + public function exec($id = null, etemplate_new &$etemplate = null) + { + $content = array(); + + $etemplate->read('home.birthdays'); + + if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') // calendar config + { + $content = $this->get_birthdays(); + } + $etemplate->set_dom_id($id); + + $etemplate->exec('home.home_list_portlet.exec',$content); + } + + /** + * Get a list of birthdays + */ + protected function get_birthdays() + { + $contacts = new addressbook_bo(); + $month_start = date('-m-',$contacts->now_su); + $days = $this->context['days']; + $birthdays = array(); + + $bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family','','%'); + // search accounts too, if not stored in accounts repository + $extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) && + !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']; + if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'), + 'n_given,n_family','','%',false,'AND',false,array('owner' => 0)))) + { + $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); + } + if (($month_end = date('-m-',$contacts->now_su+$days*24*3600)) != $month_start) + { + if (($bdays2 =& $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'),'n_given,n_family','','%'))) + { + $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); + } + // search accounts too, if not stored in accounts repository + if ($extra_accounts_search && ($bdays2 = $contacts->search(array('bday' => $month_end),array('id','n_family','n_given','bday'), + 'n_given,n_family','','%',false,'AND',false,array('owner' => 0)))) + { + $bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2); + } + } + unset($bdays2); unset($extra_accounts_search); + unset($month_start); unset($month_end); +error_log(array2string($bdays)); + if ($bdays) + { + for($n = 0; $n <= $days; ++$n) + { + $day = date('-m-d',$contacts->now_su+$n*24*3600); + foreach($bdays as $contact) + { + if(substr($contact['bday'],-6) == $day) + { + if (!$ab_lang_loaded++) $GLOBALS['egw']->translation->add_app('addressbook'); + 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']); + if ($GLOBALS['egw_info']['server']['hide_birthdays'] == 'dateonly') $y = ''; + $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; + } + + // Cheat the link widget by providing whatever title we want + $birthdays[] = array( + 'title' => $text, + 'app' => 'addressbook', + 'id' => $contact['id'] + ); + } + } + } + } + return $birthdays; + } + + /** + * Return a list of settings to customize the portlet. + * + * Settings should be in the same style as for preferences. It is OK to return an empty array + * for no customizable settings. + * + * These should be already translated, no further translation will be done. + * + * @see preferences/inc/class.preferences_settings.inc.php + * @return Array of settings. Each setting should have the following keys: + * - name: Internal reference + * - type: Widget type for editing + * - label: Human name + * - help: Description of the setting, and what it does + * - default: Default value, for when it's not set yet + */ + public function get_properties() + { + $properties = parent::get_properties(); + + $properties[] = array( + 'name' => 'days', + 'type' => 'listbox', + 'label' => '', + 'default' => 3, + 'select_options' => array( + 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'), + ), + ); + return $properties; + } + + /** + * Return a list of allowable actions for the portlet. + * + * These actions will be merged with the default portlet actions. Use the + * same id / key to override the default action. + */ + public function get_actions() + { + return array(); + } + } diff --git a/home/inc/class.home_favorite_portlet.inc.php b/home/inc/class.home_favorite_portlet.inc.php index 0c12f355f3..d92d538a4c 100644 --- a/home/inc/class.home_favorite_portlet.inc.php +++ b/home/inc/class.home_favorite_portlet.inc.php @@ -109,6 +109,10 @@ class home_favorite_portlet extends home_portlet unset($content['sel_options']); $etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']); + + // Always load app's css + egw_framework::includeCSS($this->context['appname'],'app'); + // Always load app's javascript, so most actions have a chance of working egw_framework::validate_file('','app',$this->context['appname']); diff --git a/home/inc/class.home_portlet.inc.php b/home/inc/class.home_portlet.inc.php index 57cc63db99..19428a2d5d 100644 --- a/home/inc/class.home_portlet.inc.php +++ b/home/inc/class.home_portlet.inc.php @@ -53,7 +53,6 @@ abstract class home_portlet * @param id String unique ID, provided to the portlet so it can make sure content is * unique, if needed. * @param etemplate etemplate_new Etemplate to generate content - * @param dom_id String ID of the etemplate targe DOM node. If passed, send -1 to etemplate->exec() */ public abstract function exec($id = null, etemplate_new &$etemplate = null); diff --git a/home/inc/class.home_ui.inc.php b/home/inc/class.home_ui.inc.php index 6790baac99..08d5c13a4f 100644 --- a/home/inc/class.home_ui.inc.php +++ b/home/inc/class.home_ui.inc.php @@ -282,7 +282,7 @@ class home_ui foreach($portal_oldvarnames as $varcheck) { $thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]; - if(!(int)$thisd && $thisd) + if($thisd) { $no_pref = false; break; @@ -321,6 +321,7 @@ class home_ui // Ignore some problem files and base classes that shouldn't be options $ignore = array( '.','..', + 'class.home_portlet.inc.php', 'class.home_legacy_portlet.inc.php', 'class.home_favorite_portlet.inc.php' ); @@ -341,6 +342,10 @@ class home_ui { $classes[$appname][] = $classname; } + else + { + error_log("Could not load $classname from $entry"); + } } } @@ -373,7 +378,7 @@ class home_ui return $list; }, array(), 60); - + return $list; } diff --git a/home/templates/default/birthdays.xet b/home/templates/default/birthdays.xet new file mode 100644 index 0000000000..63f18435ec --- /dev/null +++ b/home/templates/default/birthdays.xet @@ -0,0 +1,16 @@ + + + + + diff --git a/infolog/inc/class.infolog_favorite_portlet.inc.php b/infolog/inc/class.infolog_favorite_portlet.inc.php index 9466600053..420b6639d6 100644 --- a/infolog/inc/class.infolog_favorite_portlet.inc.php +++ b/infolog/inc/class.infolog_favorite_portlet.inc.php @@ -37,7 +37,7 @@ class infolog_favorite_portlet extends home_favorite_portlet 'info_priority' => $ui->bo->enums['priority'], ); $this->nm_settings += array( - 'get_rows' => 'infolog.infolog_ui.get_rows', + 'get_rows' => 'infolog_favorite_portlet::get_rows', // Use a different template so it can be accessed from client side 'template' => 'infolog.home', // Don't overwrite infolog @@ -49,6 +49,22 @@ class infolog_favorite_portlet extends home_favorite_portlet ); } + /** + * Override from infolog to clear the app header + * + * @param type $query + * @param type $rows + * @param type $readonlys + * @return integer Total rows found + */ + public static function get_rows(&$query, &$rows, &$readonlys) + { + $ui = new infolog_ui(); + $total = $ui->get_rows($query, $rows, $readonlys); + unset($GLOBALS['egw_info']['flags']['app_header']); + return $total; + } + /** * Here we need to handle any incoming data. Setup is done in the constructor, * output is handled by parent.