2005-06-15 12:43:11 +02:00
|
|
|
<?php
|
2005-11-24 12:52:14 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* eGroupWare *
|
|
|
|
* http://www.egroupware.org *
|
|
|
|
* The file written by Joseph Engo <jengo@phpgroupware.org> *
|
|
|
|
* This file modified by Greg Haygood <shrykedude@bellsouth.net> *
|
|
|
|
* This file modified by Edo van Bruggend <edovanbruggen@raketnet.nl> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
/* $Id$ */
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
/*
|
|
|
|
** Initializing the home application
|
|
|
|
*/
|
|
|
|
$GLOBALS['egw_info'] = array(
|
|
|
|
'flags' => array(
|
2010-09-22 11:48:27 +02:00
|
|
|
'noheader' => true,//False,
|
|
|
|
'nonavbar' => true,//False,
|
2005-11-24 12:52:14 +01:00
|
|
|
'currentapp' => 'home',
|
|
|
|
'enable_network_class' => False,
|
|
|
|
'enable_contacts_class' => False,
|
2006-12-15 21:31:44 +01:00
|
|
|
'enable_nextmatchs_class' => False,
|
|
|
|
'include_xajax' => True,
|
2005-11-24 12:52:14 +01:00
|
|
|
)
|
|
|
|
);
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
include('../header.inc.php');
|
2010-09-22 11:48:27 +02:00
|
|
|
auth::check_password_age('home','index');
|
|
|
|
$GLOBALS['egw_info']['flags']['nonavbar']=false;
|
2011-06-02 16:52:12 +02:00
|
|
|
|
2012-03-21 13:54:16 +01:00
|
|
|
// Display the header which contains all includes etc.
|
|
|
|
common::egw_header();
|
2011-06-02 16:52:12 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
/*
|
|
|
|
** Initializing the template
|
|
|
|
*/
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2012-03-21 13:54:16 +01:00
|
|
|
$GLOBALS['tpl'] = new Template(common::get_tpl_dir('home'));
|
2005-11-24 12:52:14 +01:00
|
|
|
$GLOBALS['tpl']->set_unknowns('remove');
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
$GLOBALS['tpl']->set_file(
|
|
|
|
array(
|
|
|
|
'home' => 'home.tpl'
|
|
|
|
)
|
|
|
|
);
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
$GLOBALS['tpl']->set_block('home','notify_window','notify_window');
|
|
|
|
$GLOBALS['tpl']->set_block('home','begin_table','begin_table');
|
|
|
|
$GLOBALS['tpl']->set_block('home','end_table','end_table');
|
|
|
|
$GLOBALS['tpl']->set_block('home','begin_row','begin_row');
|
|
|
|
$GLOBALS['tpl']->set_block('home','end_row','end_row');
|
|
|
|
$GLOBALS['tpl']->set_block('home','cell','cell');
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2012-03-21 13:54:16 +01:00
|
|
|
if ($GLOBALS['egw']->session->session_flags == 'A')
|
2005-11-24 12:52:14 +01:00
|
|
|
{
|
|
|
|
if ($_SERVER['HTTP_REFERER'] && strstr($_SERVER['HTTP_REFERER'],'home.php') === False)
|
|
|
|
{
|
|
|
|
$GLOBALS['egw']->redirect($_SERVER['HTTP_REFERER']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// redirect to the login-page, better then giving an empty page
|
|
|
|
$GLOBALS['egw']->redirect('login.php');
|
|
|
|
}
|
|
|
|
exit;
|
2012-03-21 13:54:16 +01:00
|
|
|
}
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
/*
|
|
|
|
** Show the updates
|
|
|
|
*/
|
|
|
|
$GLOBALS['egw']->hooks->single('showUpdates','home');
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-25 09:23:18 +01:00
|
|
|
/*
|
|
|
|
** Display the mainscreen message
|
|
|
|
*/
|
2012-03-21 13:54:16 +01:00
|
|
|
translation::add_app('mainscreen');
|
2010-10-05 10:30:50 +02:00
|
|
|
$greeting = translation::translate('mainscreen_message',false,'');
|
|
|
|
|
2012-03-21 13:54:16 +01:00
|
|
|
if($greeting == 'mainscreen_message'|| empty($greeting))
|
2010-10-01 16:15:47 +02:00
|
|
|
{
|
|
|
|
translation::add_app('mainscreen','en'); // trying the en one
|
2010-10-05 10:30:50 +02:00
|
|
|
$greeting = translation::translate('mainscreen_message',false,'');
|
2010-10-01 16:15:47 +02:00
|
|
|
}
|
2012-03-21 13:54:16 +01:00
|
|
|
if(!($greeting == 'mainscreen_message'|| empty($greeting)))
|
2005-11-25 09:23:18 +01:00
|
|
|
{
|
2010-10-05 10:30:50 +02:00
|
|
|
echo '<div style="text-align: center;">' . $greeting . "</div>\n";
|
2005-11-25 09:23:18 +01:00
|
|
|
}
|
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
/*
|
|
|
|
** Display the notification window
|
|
|
|
*/
|
|
|
|
if (isset($GLOBALS['egw_info']['user']['apps']['notifywindow']) && $GLOBALS['egw_info']['user']['apps']['notifywindow'])
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2005-11-24 12:52:14 +01:00
|
|
|
$var['link'] = $GLOBALS['egw']->link('/notify.php');
|
|
|
|
$var['notifywindow'] = lang('Open notify window');
|
|
|
|
$GLOBALS['tpl']->set_var($var);
|
|
|
|
$GLOBALS['tpl']->pfp('out','notify_window');
|
2005-06-15 12:43:11 +02:00
|
|
|
}
|
|
|
|
|
2012-03-21 13:54:16 +01:00
|
|
|
if (is_array($GLOBALS['egw_info']['user']['preferences']['portal_order']))
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2012-03-21 13:54:16 +01:00
|
|
|
$sorted_apps = array();
|
|
|
|
ksort($GLOBALS['egw_info']['user']['preferences']['portal_order']);
|
|
|
|
foreach($GLOBALS['egw_info']['user']['preferences']['portal_order'] as $order => $app)
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2012-03-21 13:54:16 +01:00
|
|
|
$sorted_apps[$app] = $GLOBALS['egw']->applications->id2name((int)$app);
|
2005-06-15 12:43:11 +02:00
|
|
|
}
|
|
|
|
}
|
2005-11-24 12:52:14 +01:00
|
|
|
else
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2005-11-24 12:52:14 +01:00
|
|
|
$sorted_apps = Array(
|
|
|
|
'calendar',
|
|
|
|
'email',
|
|
|
|
'infolog',
|
|
|
|
'news_admin'
|
|
|
|
);
|
2005-06-15 12:43:11 +02:00
|
|
|
}
|
2005-11-24 12:52:14 +01:00
|
|
|
|
|
|
|
// Now add the rest of the user's apps, to make sure we pick up any additions to the home display
|
|
|
|
foreach($GLOBALS['egw_info']['user']['apps'] as $app)
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2010-04-21 13:09:38 +02:00
|
|
|
if(!in_array($app['name'], $sorted_apps))
|
|
|
|
{
|
|
|
|
$sorted_apps[] = $app['name'];
|
|
|
|
}
|
2005-06-15 12:43:11 +02:00
|
|
|
}
|
2005-11-24 12:52:14 +01:00
|
|
|
|
2012-03-21 13:54:16 +01:00
|
|
|
// make sure to show only apps user has rights to
|
|
|
|
$sorted_apps = array_intersect($sorted_apps, array_keys($GLOBALS['egw_info']['user']['apps']));
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
$portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated');
|
|
|
|
$neworder = array();
|
|
|
|
$done = array();
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
/*
|
|
|
|
** Display application hooks
|
2005-12-11 01:50:08 +01:00
|
|
|
**
|
2005-11-24 12:52:14 +01:00
|
|
|
*/
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
$GLOBALS['tpl']->pfp('out','begin_table');
|
|
|
|
$tropen=0;
|
|
|
|
$tdopen=0;
|
|
|
|
$lastd = 0;
|
|
|
|
$numcols = 2;
|
|
|
|
$curcol = 1;
|
2010-04-21 13:09:38 +02:00
|
|
|
$searchlist = array();
|
2005-11-24 12:52:14 +01:00
|
|
|
foreach($sorted_apps as $appname)
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2005-11-24 12:52:14 +01:00
|
|
|
if((int)$done[$appname] == 1 || empty($appname))
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2005-11-24 12:52:14 +01:00
|
|
|
continue;
|
2005-06-15 12:43:11 +02:00
|
|
|
}
|
2005-11-24 12:52:14 +01:00
|
|
|
$varnames = $portal_oldvarnames;
|
|
|
|
$varnames[] = 'homepage_display';
|
|
|
|
foreach($varnames as $varcheck)
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2005-11-24 12:52:14 +01:00
|
|
|
//echo "$appname:$varcheck=".$GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]."<br>";
|
2006-04-09 07:52:52 +02:00
|
|
|
$thisd = (int)$GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck];
|
|
|
|
if (!$thisd && $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck]) $thisd = 1;
|
|
|
|
if($thisd>0)
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2006-04-09 07:52:52 +02:00
|
|
|
//echo "Found $appname=$_thisd through $varcheck<br>";
|
2005-06-15 12:43:11 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-11-24 12:52:14 +01:00
|
|
|
//echo "$appname: $thisd<br>";
|
|
|
|
if($thisd>0)
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2010-04-21 13:09:38 +02:00
|
|
|
$searchlist[$appname] = $thisd;
|
|
|
|
$neworder[] = $appname;
|
|
|
|
$done[$appname] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach($neworder as $index => $appname)
|
|
|
|
{
|
|
|
|
$thisd = $searchlist[$appname];
|
|
|
|
//echo "$appname: $thisd<br>";
|
|
|
|
if((($curcol++>$numcols) || ($thisd==1)) && $tropen==1)
|
|
|
|
{
|
|
|
|
$GLOBALS['tpl']->pfp('out','end_row');
|
|
|
|
$tropen = 0;
|
|
|
|
//$curcol = 1;
|
|
|
|
}
|
|
|
|
if(!$tropen)
|
|
|
|
{
|
|
|
|
$GLOBALS['tpl']->pfp('out','begin_row');
|
|
|
|
$tropen=1;
|
|
|
|
}
|
2005-11-24 12:52:14 +01:00
|
|
|
|
2010-04-21 15:28:02 +02:00
|
|
|
$small = ($thisd>1) && (count($neworder) >= $index + 1) && ($searchlist[$neworder[$index + 1]] > 1 || $searchlist[$neworder[$index - 1]] > 1);
|
2010-04-21 13:09:38 +02:00
|
|
|
$var['tdwidth'] = $small ? '50' : '100';
|
|
|
|
$var['colspan'] = $small ? '1' : '2';
|
2005-11-24 12:52:14 +01:00
|
|
|
|
2010-04-21 13:09:38 +02:00
|
|
|
ob_start();
|
|
|
|
$var['content'] = $GLOBALS['egw']->hooks->single('home',$appname);
|
|
|
|
if (!$var['content'] || $var['content'] == 1) // content has been echoed and not returned
|
|
|
|
{
|
|
|
|
$var['content'] = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
$GLOBALS['tpl']->set_var($var);
|
2005-11-24 12:52:14 +01:00
|
|
|
|
2010-04-21 13:09:38 +02:00
|
|
|
$GLOBALS['tpl']->pfp('out','cell');
|
|
|
|
|
|
|
|
if(($thisd<=1 || ($thisd>1&&$lastd>1)) && $tropen && $var['content'])
|
|
|
|
{
|
|
|
|
$GLOBALS['tpl']->pfp('out','end_row');
|
|
|
|
$tropen = 0;
|
|
|
|
$lastd = 0;
|
|
|
|
$curcol = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$lastd = $thisd;
|
2005-06-15 12:43:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
$GLOBALS['tpl']->pfp('out','end_table');
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2005-11-24 12:52:14 +01:00
|
|
|
// Update stored value of order
|
|
|
|
//_debug_array($neworder);
|
|
|
|
if(count($neworder)>0)//$GLOBALS['portal_order'])
|
2005-06-15 12:43:11 +02:00
|
|
|
{
|
2005-11-24 12:52:14 +01:00
|
|
|
$GLOBALS['egw']->preferences->delete('portal_order');
|
2012-03-21 13:54:16 +01:00
|
|
|
foreach($neworder as $app_order => $app_name)
|
2005-11-24 12:52:14 +01:00
|
|
|
{
|
|
|
|
$app_id = $GLOBALS['egw']->applications->name2id($app_name);
|
|
|
|
//echo "neworder: $app_order=$app_id:$app_name<br>";
|
|
|
|
$GLOBALS['egw']->preferences->add('portal_order',$app_order,$app_id);
|
|
|
|
}
|
|
|
|
$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->save_repository();
|
2005-06-15 12:43:11 +02:00
|
|
|
}
|
2005-11-24 12:52:14 +01:00
|
|
|
//_debug_array($GLOBALS['egw_info']['user']['preferences']);
|
2005-06-15 12:43:11 +02:00
|
|
|
|
2012-03-21 13:54:16 +01:00
|
|
|
common::egw_footer();
|