2001-07-09 19:33:19 +02:00
< ? php
2001-12-05 17:00:39 +01:00
/************************************************************************** \
2003-11-20 22:21:35 +01:00
* eGroupWare *
* http :// www . egroupware . org *
2001-12-05 17:00:39 +01:00
* The file written by Joseph Engo < jengo @ phpgroupware . org > *
2003-11-20 22:21:35 +01:00
* This file modified by Greg Haygood < shrykedude @ bellsouth . net > *
2001-12-05 17:00:39 +01:00
* -------------------------------------------- *
* 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 . *
\ **************************************************************************/
2001-07-09 19:33:19 +02:00
2001-12-05 17:00:39 +01:00
/* $Id$ */
2001-07-09 19:33:19 +02:00
2001-12-05 17:00:39 +01:00
$phpgw_info = array ();
2001-07-09 19:33:19 +02:00
if ( ! is_file ( 'header.inc.php' ))
{
2003-11-03 23:28:30 +01:00
Header ( 'Location: setup/index.php' );
2001-07-09 19:33:19 +02:00
exit ;
}
2001-12-05 17:00:39 +01:00
2004-04-02 19:25:37 +02:00
$GLOBALS [ 'sessionid' ] = @ $_GET [ 'sessionid' ] ? $_GET [ 'sessionid' ] : @ $_COOKIE [ 'sessionid' ];
2001-08-21 20:34:56 +02:00
if ( ! isset ( $GLOBALS [ 'sessionid' ]) || ! $GLOBALS [ 'sessionid' ])
2001-07-09 19:33:19 +02:00
{
Header ( 'Location: login.php' );
exit ;
}
2003-08-28 16:16:30 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ] = array (
'noheader' => True ,
'nonavbar' => True ,
'currentapp' => 'home' ,
'enable_network_class' => True ,
'enable_contacts_class' => True ,
'enable_nextmatchs_class' => True
2001-07-09 19:33:19 +02:00
);
include ( 'header.inc.php' );
2004-01-25 18:35:27 +01:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'app_header' ] = lang ( 'home' );
2001-07-09 19:33:19 +02:00
2004-09-12 01:54:57 +02:00
// Commented by alpeb: The following prevented anonymous users to get a home page. Perhaps it was done with anonymous users such as the ones
// used by wiki and sitemgr in mind. However, if you mark a normal user as anonymous just to avoid being shown in sessions and access log (like you would for an admin that doesn't want to be noticed), the user won't be able to login anymore. That's why I commented the code.
/* if ( $GLOBALS [ 'phpgw' ] -> session -> session_flags == 'A' )
2004-04-02 19:25:37 +02:00
{
if ( $_SERVER [ 'HTTP_REFERER' ] && strstr ( $_SERVER [ 'HTTP_REFERER' ], 'home.php' ) === False )
{
$GLOBALS [ 'phpgw' ] -> redirect ( $_SERVER [ 'HTTP_REFERER' ]);
}
else
{
2004-06-13 22:35:01 +02:00
// redirect to the login-page, better then giving an empty page
$GLOBALS [ 'phpgw' ] -> redirect ( 'login.php' );
2004-04-02 19:25:37 +02:00
}
exit ;
2004-09-12 01:54:57 +02:00
} */
2004-04-02 19:25:37 +02:00
2003-08-28 16:16:30 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_default_app' ] && $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_default_app' ] != 'user_choice' )
2001-07-09 19:33:19 +02:00
{
2003-08-28 16:16:30 +02:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'default_app' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_default_app' ];
2001-07-09 19:33:19 +02:00
}
2003-08-28 16:16:30 +02:00
if (( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'useframes' ] &&
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'useframes' ] == 'allowed' ) ||
( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'useframes' ] == 'always' ))
2001-07-09 19:33:19 +02:00
{
2003-11-20 22:21:35 +01:00
if ( $_GET [ 'cd' ] == 'yes' )
2001-07-09 19:33:19 +02:00
{
2003-08-28 16:16:30 +02:00
if ( ! $navbarframe && ! $framebody )
{
$tpl = new Template ( PHPGW_TEMPLATE_DIR );
$tpl -> set_file ( array (
'frames' => 'frames.tpl' ,
'frame_body' => 'frames_body.tpl' ,
'frame_navbar' => 'frames_navbar.tpl'
));
$tpl -> set_var ( 'navbar_link' , $GLOBALS [ 'phpgw' ] -> link ( 'index.php' , 'navbarframe=True&cd=yes' ));
if ( $GLOBALS [ 'forward' ])
{
$tpl -> set_var ( 'body_link' , $GLOBALS [ 'phpgw' ] -> link ( $GLOBALS [ 'forward' ]));
}
else
{
$tpl -> set_var ( 'body_link' , $GLOBALS [ 'phpgw' ] -> link ( 'index.php' , 'framebody=True&cd=yes' ));
}
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'frame_navbar_location' ] == 'bottom' )
{
$tpl -> set_var ( 'frame_size' , '*,60' );
$tpl -> parse ( 'frames_' , 'frame_body' , True );
$tpl -> parse ( 'frames_' , 'frame_navbar' , True );
}
else
{
$tpl -> set_var ( 'frame_size' , '60,*' );
$tpl -> parse ( 'frames_' , 'frame_navbar' , True );
$tpl -> parse ( 'frames_' , 'frame_body' , True );
}
$tpl -> pparse ( 'out' , 'frames' );
}
if ( $navbarframe )
{
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
echo parse_navbar ();
}
2001-07-09 19:33:19 +02:00
}
2002-10-30 00:11:21 +01:00
}
2003-12-14 17:41:35 +01:00
elseif ( $_GET [ 'cd' ] == 'yes' && $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'default_app' ] &&
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'default_app' ]])
2002-10-30 00:11:21 +01:00
{
2003-08-28 16:16:30 +02:00
$GLOBALS [ 'phpgw' ] -> redirect ( $GLOBALS [ 'phpgw' ] -> link ( '/' . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'default_app' ] . '/' . 'index.php' ));
}
else
{
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ();
echo parse_navbar ();
}
$GLOBALS [ 'phpgw' ] -> translation -> add_app ( 'mainscreen' );
if ( lang ( 'mainscreen_message' ) != 'mainscreen_message*' )
{
echo '<center>' . stripslashes ( lang ( 'mainscreen_message' )) . '</center>' ;
2002-10-30 00:11:21 +01:00
}
2001-09-08 18:02:59 +02:00
2003-08-28 16:16:30 +02:00
if (( isset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'admin' ]) &&
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'admin' ]) &&
( isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'checkfornewversion' ]) &&
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'checkfornewversion' ]))
{
$GLOBALS [ 'phpgw' ] -> network -> set_addcrlf ( False );
2004-01-26 15:00:52 +01:00
$lines = $GLOBALS [ 'phpgw' ] -> network -> gethttpsocketfile ( 'http://www.egroupware.org/currentversion' );
2004-01-26 15:02:12 +01:00
for ( $i = 0 ; $i < count ( $lines ); $i ++ )
2003-08-28 16:16:30 +02:00
{
2004-01-26 15:02:12 +01:00
if ( strstr ( $lines [ $i ], 'currentversion' ))
2003-08-28 16:16:30 +02:00
{
$line_found = explode ( ':' , chop ( $lines [ $i ]));
}
}
2004-01-26 23:03:26 +01:00
if ( $GLOBALS [ 'phpgw' ] -> common -> cmp_version_long ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'versions' ][ 'phpgwapi' ], $line_found [ 1 ]))
2003-08-28 16:16:30 +02:00
{
2003-11-20 22:21:35 +01:00
echo '<p>There is a new version of eGroupWare available. <a href="'
2004-01-26 23:03:26 +01:00
. 'http://www.egroupware.org">http://www.egroupware.org</a></p>' ;
2003-08-28 16:16:30 +02:00
}
$_found = False ;
2001-09-08 18:02:59 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " select app_name,app_version from phpgw_applications " , __LINE__ , __FILE__ );
while ( $GLOBALS [ 'phpgw' ] -> db -> next_record ())
{
$_db_version = $GLOBALS [ 'phpgw' ] -> db -> f ( 'app_version' );
$_app_name = $GLOBALS [ 'phpgw' ] -> db -> f ( 'app_name' );
2004-05-22 12:14:31 +02:00
$_app_dir = $GLOBALS [ 'phpgw' ] -> common -> get_app_dir ( $_app_name );
$_versionfile = $_app_dir . '/setup/setup.inc.php' ;
if ( $_app_dir && file_exists ( $_versionfile ))
2001-09-08 18:02:59 +02:00
{
include ( $_versionfile );
$_file_version = $setup_info [ $_app_name ][ 'version' ];
2003-08-28 16:16:30 +02:00
$_app_title = $GLOBALS [ 'phpgw_info' ][ 'apps' ][ $_app_name ][ 'title' ];
2001-09-08 18:02:59 +02:00
unset ( $setup_info );
if ( $GLOBALS [ 'phpgw' ] -> common -> cmp_version_long ( $_db_version , $_file_version ))
{
2001-09-08 18:07:05 +02:00
$_found = True ;
2003-08-28 16:16:30 +02:00
$_app_string .= '<br>' . $_app_title ;
2001-09-08 18:02:59 +02:00
}
unset ( $_file_version );
2003-08-28 16:16:30 +02:00
unset ( $_app_title );
2001-09-08 18:02:59 +02:00
}
unset ( $_db_version );
unset ( $_versionfile );
}
if ( $_found )
{
2003-08-28 16:16:30 +02:00
echo '<br>' . lang ( 'The following applications require upgrades' ) . ':' . " \n " ;
echo $_app_string . " \n " ;
2004-06-28 09:08:13 +02:00
echo '<br><a href="setup/" target="_blank">' . lang ( 'Please run setup to become current' ) . '.' . " </a> \n " ;
2001-09-08 18:02:59 +02:00
unset ( $_app_string );
}
2001-07-09 19:33:19 +02:00
}
2001-10-06 09:56:34 +02:00
if ( isset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'notifywindow' ]) &&
2001-11-23 20:43:55 +01:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'notifywindow' ])
{
2003-08-28 16:16:30 +02:00
?>
2001-07-09 19:33:19 +02:00
< SCRIPT LANGUAGE = " JavaScript " TYPE = " text/javascript " >
var NotifyWindow ;
function opennotifywindow ()
{
if ( NotifyWindow )
{
if ( NotifyWindow . closed )
{
2001-09-12 02:07:01 +02:00
NotifyWindow . stop ;
NotifyWindow . close ;
2001-07-09 19:33:19 +02:00
}
}
2001-08-21 20:34:56 +02:00
NotifyWindow = window . open ( " <?php echo $GLOBALS['phpgw'] ->link('/notify.php')?> " , " NotifyWindow " , " width=300,height=35,location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=yes,status=yes " );
2001-07-09 19:33:19 +02:00
if ( NotifyWindow . opener == null )
{
NotifyWindow . opener = window ;
}
}
</ SCRIPT >
2003-08-28 16:16:30 +02:00
< ? php
2001-10-06 09:56:34 +02:00
echo '<a href="javascript:opennotifywindow()">' . lang ( 'Open notify window' ) . '</a>' ;
}
2001-07-09 19:33:19 +02:00
2001-10-21 12:49:29 +02:00
/* This initializes the users portal_order preference if it does not exist. */
2001-11-04 05:08:17 +01:00
if ( ! is_array ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]) && $GLOBALS [ 'phpgw_info' ][ 'apps' ])
2001-10-21 12:49:29 +02:00
{
$GLOBALS [ 'phpgw' ] -> preferences -> delete ( 'portal_order' );
@ reset ( $GLOBALS [ 'phpgw_info' ][ 'apps' ]);
$order = 0 ;
while ( list (, $p ) = each ( $GLOBALS [ 'phpgw_info' ][ 'apps' ]))
{
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ $p [ 'name' ]])
{
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'portal_order' , $order ++ , $p [ 'id' ]);
}
}
2001-11-23 20:43:55 +01:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ] = $GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
2001-10-21 12:49:29 +02:00
}
if ( is_array ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]))
{
$app_check = Array ();
@ ksort ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]);
while ( list ( $order , $app ) = each ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'portal_order' ]))
{
2003-12-14 17:41:35 +01:00
if ( ! isset ( $app_check [( int ) $app ]) || ! $app_check [( int ) $app ])
2001-10-21 12:49:29 +02:00
{
2003-12-14 17:41:35 +01:00
$app_check [( int ) $app ] = True ;
$sorted_apps [] = $GLOBALS [ 'phpgw' ] -> applications -> id2name (( int ) $app );
2001-10-21 12:49:29 +02:00
}
}
}
else
{
2003-08-28 16:16:30 +02:00
$sorted_apps = Array (
2001-10-21 12:49:29 +02:00
'calendar' ,
2003-11-20 22:21:35 +01:00
'email' ,
'infolog' ,
'news_admin'
2001-10-21 12:49:29 +02:00
);
}
2003-12-03 06:28:29 +01:00
// Now add the rest of the user's apps, to make sure we pick up any additions to the home display
@ reset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ]);
2003-12-14 17:41:35 +01:00
while ( list (, $p ) = each ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ]))
2003-12-03 06:28:29 +01:00
{
$sorted_apps [] = $p [ 'name' ];
}
2003-11-20 22:21:35 +01:00
//$GLOBALS['phpgw']->hooks->process('home',$sorted_apps);
2003-12-14 17:41:35 +01:00
2003-11-20 22:21:35 +01:00
function migrate_pref ( $appname , $var_old , $var_new , $type = 'user' )
{
if ( empty ( $appname ) || empty ( $var_old ) || empty ( $var_new ))
{
return false ;
}
$allowedtypes = array ( 'user' , 'default' , 'forced' );
if ( $type == 'all' )
{
$types = $allowedtypes ;
}
elseif ( in_array ( $type , $allowedtypes ))
{
$types [] = $type ;
}
else
{
return false ;
}
$result = false ;
foreach ( $types as $_type )
{
if ( isset ( $GLOBALS [ 'phpgw' ] -> preferences -> $_type [ $appname ][ $var_old ]))
{
$GLOBALS [ 'phpgw' ] -> preferences -> $_type [ $appname ][ $var_new ] =
2003-12-14 17:41:35 +01:00
$GLOBALS [ 'phpgw' ] -> preferences -> $_type [ $appname ][ $var_old ];
2003-11-20 22:21:35 +01:00
$result = true ;
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ] =
2003-12-14 17:41:35 +01:00
$GLOBALS [ 'phpgw' ] -> preferences -> save_repository ( false , $_type );
2003-11-20 22:21:35 +01:00
}
}
return $result ;
}
2003-12-03 06:28:29 +01:00
2003-11-21 07:12:20 +01:00
$portal_oldvarnames = array ( 'mainscreen_showevents' , 'homeShowEvents' , 'homeShowLatest' , 'mainscreen_showmail' , 'mainscreen_showbirthdays' , 'mainscreen_show_new_updated' );
$migrate_oldvarnames = false ;
if ( $migrate_oldvarnames )
2003-11-20 22:21:35 +01:00
{
$_apps = $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ];
2003-12-03 06:28:29 +01:00
@ reset ( $_apps );
2003-11-20 22:21:35 +01:00
foreach ( $_apps as $_appname )
{
2003-12-03 06:28:29 +01:00
@ reset ( $portal_oldvarnames );
2003-11-20 22:21:35 +01:00
foreach ( $portal_oldvarnames as $varname )
{
2003-12-03 06:28:29 +01:00
//echo "Want to migrate '$appname' from '$varname' to 'homepage_display'.<br>";
//migrate_pref($appname,$varname,'homepage_display','all');
2003-11-20 22:21:35 +01:00
}
}
}
2003-12-03 06:28:29 +01:00
$neworder = array ();
$done = array ();
2003-11-20 22:21:35 +01:00
// Display elements, within appropriate table cells
print '<table border="0" cellpadding="5" cellspacing="0" width="100%">' ;
$tropen = 0 ;
$tdopen = 0 ;
$lastd = 0 ;
$numcols = 2 ;
$curcol = 1 ;
2003-12-03 06:28:29 +01:00
@ reset ( $sorted_apps );
foreach ( $sorted_apps as $appname )
2003-11-20 22:21:35 +01:00
{
2003-12-14 17:41:35 +01:00
if (( int ) $done [ $appname ] == 1 || empty ( $appname ))
2003-11-20 22:21:35 +01:00
{
continue ;
}
$varnames = $portal_oldvarnames ;
$varnames [] = 'homepage_display' ;
$thisd = 0 ;
foreach ( $varnames as $varcheck )
{
2003-12-14 17:41:35 +01:00
//echo "$appname:$varcheck=".$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]."<br>";
if ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ $appname ][ $varcheck ] == 'True' )
2003-11-20 22:21:35 +01:00
{
2003-12-03 06:28:29 +01:00
$thisd = 1 ;
2003-11-20 22:21:35 +01:00
break ;
}
2003-12-03 06:28:29 +01:00
else
{
2003-12-14 17:41:35 +01:00
$_thisd = ( int ) $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ $appname ][ $varcheck ];
2003-12-03 06:28:29 +01:00
if ( $_thisd > 0 )
{
//echo "Found $appname=$_thisd through $varcheck<br>";
$thisd = $_thisd ;
break ;
}
}
2003-11-20 22:21:35 +01:00
}
2003-12-03 06:28:29 +01:00
//echo "$appname: $thisd<br>";
2003-11-20 22:21:35 +01:00
if ( $thisd > 0 )
{
if ((( $curcol ++> $numcols ) || ( $thisd + $lastd == 3 )) && $tropen == 1 )
{
print '</tr>' ;
$tropen = 0 ;
2003-12-03 07:37:11 +01:00
//$curcol = 1;
2003-11-20 22:21:35 +01:00
}
if ( ! $tropen )
{
print '<tr>' ;
$tropen = 1 ;
}
$tdwidth = ( $thisd == 2 ) ? '50' : '100' ;
$colspan = ( $thisd == 2 ) ? '1' : '2' ;
print '<td valign="top" colspan="' . $colspan . '" width="' . $tdwidth . '%">' ;
$result = $GLOBALS [ 'phpgw' ] -> hooks -> single ( 'home' , $appname );
print '</td>' ;
if (( $thisd != 2 || ( $thisd == 2 && $lastd == 2 )) && $tropen )
{
print '</tr>' ;
2003-12-03 07:37:11 +01:00
$tropen = 0 ;
$lastd = 0 ;
2003-11-20 22:21:35 +01:00
$curcol = 1 ;
2003-12-03 07:37:11 +01:00
}
else
{
$lastd = $thisd ;
2003-11-20 22:21:35 +01:00
}
2003-12-03 06:28:29 +01:00
$neworder [] = $appname ;
2003-11-20 22:21:35 +01:00
}
2003-12-03 06:28:29 +01:00
$done [ $appname ] = 1 ;
2003-11-20 22:21:35 +01:00
}
print '</table>' ;
2001-10-21 12:49:29 +02:00
2003-11-20 22:21:35 +01:00
// Update stored value of order
2003-12-03 06:28:29 +01:00
//_debug_array($neworder);
if ( count ( $neworder ) > 0 ) //$GLOBALS['portal_order'])
2001-10-21 12:49:29 +02:00
{
2001-11-04 05:08:17 +01:00
$GLOBALS [ 'phpgw' ] -> preferences -> delete ( 'portal_order' );
2003-12-03 06:28:29 +01:00
@ reset ( $neworder );
while ( list ( $app_order , $app_name ) = each ( $neworder ))
2001-11-04 05:08:17 +01:00
{
2003-12-03 06:28:29 +01:00
$app_id = $GLOBALS [ 'phpgw' ] -> applications -> name2id ( $app_name );
2003-12-08 07:21:12 +01:00
//echo "neworder: $app_order=$app_id:$app_name<br>";
2001-11-04 05:08:17 +01:00
$GLOBALS [ 'phpgw' ] -> preferences -> add ( 'portal_order' , $app_order , $app_id );
}
2003-12-03 06:28:29 +01:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ] = $GLOBALS [ 'phpgw' ] -> preferences -> save_repository ();
2001-10-21 12:49:29 +02:00
}
2003-12-03 07:37:11 +01:00
//_debug_array($GLOBALS['phpgw_info']['user']['preferences']);
2002-10-25 05:04:28 +02:00
2003-08-28 16:16:30 +02:00
//$phpgw->common->debug_phpgw_info();
//$phpgw->common->debug_list_core_functions();
$GLOBALS [ 'phpgw' ] -> common -> phpgw_footer ();
2001-07-09 19:33:19 +02:00
?>