mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-24 23:58:54 +01:00
More Home progress:
- Add birthday reminders - Prevent infolog favorites from setting an app header
This commit is contained in:
parent
63a6ac9a6d
commit
ba13371430
@ -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(
|
||||
|
@ -1,117 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Addressbook - birthday reminder on home-page
|
||||
*
|
||||
* @package addressbook
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @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<!-- Birthday info -->\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<!-- Birthday info -->\n";
|
||||
}
|
197
home/inc/class.home_birthday_portlet.inc.php
Normal file
197
home/inc/class.home_birthday_portlet.inc.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Egroupware
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package home
|
||||
* @subpackage portlet
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Show birthdays
|
||||
*
|
||||
*/
|
||||
class home_birthday_portlet extends home_portlet {
|
||||
/**
|
||||
* Constructor sets up the portlet according to the user's saved property values
|
||||
* for this particular portlet. It is possible to have multiple instances of the
|
||||
* same portlet with different properties.
|
||||
*
|
||||
* The implementing class is allowed to modify the context, if needed, but it is
|
||||
* better to use get_properties().
|
||||
*
|
||||
* @param context Array portlet settings such as size, as well as values for properties
|
||||
* @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
}
|
@ -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']);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
16
home/templates/default/birthdays.xet
Normal file
16
home/templates/default/birthdays.xet
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="home.birthdays" template="" lang="" group="0" version="1.9.001">
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<link id="${row}"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
</overlay>
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user