[903] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare * |
---|
| 4 | * http://www.egroupware.org * |
---|
| 5 | * The file written by Joseph Engo <jengo@phpgroupware.org> * |
---|
| 6 | * This file modified by Greg Haygood <shrykedude@bellsouth.net> * |
---|
| 7 | * -------------------------------------------- * |
---|
| 8 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 9 | * under the terms of the GNU General Public License as published by the * |
---|
| 10 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 11 | * option) any later version. * |
---|
| 12 | \**************************************************************************/ |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | $phpgw_info = array(); |
---|
| 16 | if (!is_file('header.inc.php')) |
---|
| 17 | { |
---|
| 18 | Header('Location: setup/index.php'); |
---|
| 19 | exit; |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | $GLOBALS['sessionid'] = @$_GET['sessionid'] ? $_GET['sessionid'] : @$_COOKIE['sessionid']; |
---|
| 23 | if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) |
---|
| 24 | { |
---|
| 25 | Header('Location: login.php'); |
---|
| 26 | exit; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | $GLOBALS['phpgw_info']['flags'] = array( |
---|
| 30 | 'noheader' => True, |
---|
| 31 | 'nonavbar' => True, |
---|
| 32 | 'currentapp' => 'home', |
---|
| 33 | 'enable_network_class' => True, |
---|
| 34 | 'enable_contacts_class' => True, |
---|
| 35 | 'enable_nextmatchs_class' => True |
---|
| 36 | ); |
---|
| 37 | include('header.inc.php'); |
---|
| 38 | $GLOBALS['phpgw_info']['flags']['app_header']=lang('home'); |
---|
| 39 | |
---|
| 40 | // Commented by alpeb: The following prevented anonymous users to get a home page. Perhaps it was done with anonymous users such as the ones |
---|
| 41 | // 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. |
---|
| 42 | /*if ($GLOBALS['phpgw']->session->session_flags == 'A') |
---|
| 43 | { |
---|
| 44 | if ($_SERVER['HTTP_REFERER'] && strstr($_SERVER['HTTP_REFERER'],'home.php') === False) |
---|
| 45 | { |
---|
| 46 | $GLOBALS['phpgw']->redirect($_SERVER['HTTP_REFERER']); |
---|
| 47 | } |
---|
| 48 | else |
---|
| 49 | { |
---|
| 50 | // redirect to the login-page, better then giving an empty page |
---|
| 51 | $GLOBALS['phpgw']->redirect('login.php'); |
---|
| 52 | } |
---|
| 53 | exit; |
---|
| 54 | }*/ |
---|
| 55 | |
---|
| 56 | if ($GLOBALS['phpgw_info']['server']['force_default_app'] && $GLOBALS['phpgw_info']['server']['force_default_app'] != 'user_choice') |
---|
| 57 | { |
---|
| 58 | $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] = $GLOBALS['phpgw_info']['server']['force_default_app']; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | if (($GLOBALS['phpgw_info']['user']['preferences']['common']['useframes'] && |
---|
| 62 | $GLOBALS['phpgw_info']['server']['useframes'] == 'allowed') || |
---|
| 63 | ($GLOBALS['phpgw_info']['server']['useframes'] == 'always')) |
---|
| 64 | { |
---|
| 65 | if ($_GET['cd'] == 'yes') |
---|
| 66 | { |
---|
| 67 | if (! $navbarframe && ! $framebody) |
---|
| 68 | { |
---|
| 69 | $tpl = new Template(PHPGW_TEMPLATE_DIR); |
---|
| 70 | $tpl->set_file(array( |
---|
| 71 | 'frames' => 'frames.tpl', |
---|
| 72 | 'frame_body' => 'frames_body.tpl', |
---|
| 73 | 'frame_navbar' => 'frames_navbar.tpl' |
---|
| 74 | )); |
---|
| 75 | $tpl->set_var('navbar_link',$GLOBALS['phpgw']->link('index.php','navbarframe=True&cd=yes')); |
---|
| 76 | if ($GLOBALS['forward']) |
---|
| 77 | { |
---|
| 78 | $tpl->set_var('body_link',$GLOBALS['phpgw']->link($GLOBALS['forward'])); |
---|
| 79 | } |
---|
| 80 | else |
---|
| 81 | { |
---|
| 82 | $tpl->set_var('body_link',$GLOBALS['phpgw']->link('index.php','framebody=True&cd=yes')); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | if ($GLOBALS['phpgw_info']['user']['preferences']['common']['frame_navbar_location'] == 'bottom') |
---|
| 86 | { |
---|
| 87 | $tpl->set_var('frame_size','*,60'); |
---|
| 88 | $tpl->parse('frames_','frame_body',True); |
---|
| 89 | $tpl->parse('frames_','frame_navbar',True); |
---|
| 90 | } |
---|
| 91 | else |
---|
| 92 | { |
---|
| 93 | $tpl->set_var('frame_size','60,*'); |
---|
| 94 | $tpl->parse('frames_','frame_navbar',True); |
---|
| 95 | $tpl->parse('frames_','frame_body',True); |
---|
| 96 | } |
---|
| 97 | $tpl->pparse('out','frames'); |
---|
| 98 | } |
---|
| 99 | if ($navbarframe) |
---|
| 100 | { |
---|
| 101 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 102 | echo parse_navbar(); |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | } |
---|
| 106 | elseif ($_GET['cd']=='yes' && $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] && |
---|
| 107 | $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['user']['preferences']['common']['default_app']]) |
---|
| 108 | { |
---|
| 109 | $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] . '/' . 'index.php')); |
---|
| 110 | } |
---|
| 111 | else |
---|
| 112 | { |
---|
| 113 | $GLOBALS['phpgw']->common->phpgw_header(); |
---|
| 114 | echo parse_navbar(); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | $GLOBALS['phpgw']->translation->add_app('mainscreen'); |
---|
| 118 | if (lang('mainscreen_message') != 'mainscreen_message*') |
---|
| 119 | { |
---|
| 120 | echo '<center>' . stripslashes(lang('mainscreen_message')) . '</center>'; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | if ((isset($GLOBALS['phpgw_info']['user']['apps']['admin']) && |
---|
| 124 | $GLOBALS['phpgw_info']['user']['apps']['admin']) && |
---|
| 125 | (isset($GLOBALS['phpgw_info']['server']['checkfornewversion']) && |
---|
| 126 | $GLOBALS['phpgw_info']['server']['checkfornewversion'])) |
---|
| 127 | { |
---|
| 128 | $GLOBALS['phpgw']->network->set_addcrlf(False); |
---|
| 129 | $lines = $GLOBALS['phpgw']->network->gethttpsocketfile('http://www.egroupware.org/currentversion'); |
---|
| 130 | for($i=0; $i<count($lines); $i++) |
---|
| 131 | { |
---|
| 132 | if(strstr($lines[$i],'currentversion')) |
---|
| 133 | { |
---|
| 134 | $line_found = explode(':',chop($lines[$i])); |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | if($GLOBALS['phpgw']->common->cmp_version_long($GLOBALS['phpgw_info']['server']['versions']['phpgwapi'],$line_found[1])) |
---|
| 138 | { |
---|
| 139 | echo '<p>There is a new version of eGroupWare available. <a href="' |
---|
| 140 | . 'http://www.egroupware.org">http://www.egroupware.org</a></p>'; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | $_found = False; |
---|
| 144 | $GLOBALS['phpgw']->db->query("select app_name,app_version from phpgw_applications",__LINE__,__FILE__); |
---|
| 145 | while($GLOBALS['phpgw']->db->next_record()) |
---|
| 146 | { |
---|
| 147 | $_db_version = $GLOBALS['phpgw']->db->f('app_version'); |
---|
| 148 | $_app_name = $GLOBALS['phpgw']->db->f('app_name'); |
---|
| 149 | $_app_dir = $GLOBALS['phpgw']->common->get_app_dir($_app_name); |
---|
| 150 | $_versionfile = $_app_dir . '/setup/setup.inc.php'; |
---|
| 151 | if($_app_dir && file_exists($_versionfile)) |
---|
| 152 | { |
---|
| 153 | include($_versionfile); |
---|
| 154 | $_file_version = $setup_info[$_app_name]['version']; |
---|
| 155 | $_app_title = $GLOBALS['phpgw_info']['apps'][$_app_name]['title']; |
---|
| 156 | unset($setup_info); |
---|
| 157 | |
---|
| 158 | if($GLOBALS['phpgw']->common->cmp_version_long($_db_version,$_file_version)) |
---|
| 159 | { |
---|
| 160 | $_found = True; |
---|
| 161 | $_app_string .= '<br>' . $_app_title; |
---|
| 162 | } |
---|
| 163 | unset($_file_version); |
---|
| 164 | unset($_app_title); |
---|
| 165 | } |
---|
| 166 | unset($_db_version); |
---|
| 167 | unset($_versionfile); |
---|
| 168 | } |
---|
| 169 | if($_found) |
---|
| 170 | { |
---|
| 171 | echo '<br>' . lang('The following applications require upgrades') . ':' . "\n"; |
---|
| 172 | echo $_app_string . "\n"; |
---|
| 173 | echo '<br><a href="setup/" target="_blank">' . lang('Please run setup to become current') . '.' . "</a>\n"; |
---|
| 174 | unset($_app_string); |
---|
| 175 | } |
---|
| 176 | } |
---|
| 177 | |
---|
| 178 | if (isset($GLOBALS['phpgw_info']['user']['apps']['notifywindow']) && |
---|
| 179 | $GLOBALS['phpgw_info']['user']['apps']['notifywindow']) |
---|
| 180 | { |
---|
| 181 | ?> |
---|
| 182 | <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> |
---|
| 183 | var NotifyWindow; |
---|
| 184 | |
---|
| 185 | function opennotifywindow() |
---|
| 186 | { |
---|
| 187 | if (NotifyWindow) |
---|
| 188 | { |
---|
| 189 | if (NotifyWindow.closed) |
---|
| 190 | { |
---|
| 191 | NotifyWindow.stop; |
---|
| 192 | NotifyWindow.close; |
---|
| 193 | } |
---|
| 194 | } |
---|
| 195 | 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"); |
---|
| 196 | if (NotifyWindow.opener == null) |
---|
| 197 | { |
---|
| 198 | NotifyWindow.opener = window; |
---|
| 199 | } |
---|
| 200 | } |
---|
| 201 | </SCRIPT> |
---|
| 202 | |
---|
| 203 | <?php |
---|
| 204 | echo '<a href="javascript:opennotifywindow()">' . lang('Open notify window') . '</a>'; |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | /* This initializes the users portal_order preference if it does not exist. */ |
---|
| 208 | if(!is_array($GLOBALS['phpgw_info']['user']['preferences']['portal_order']) && $GLOBALS['phpgw_info']['apps']) |
---|
| 209 | { |
---|
| 210 | $GLOBALS['phpgw']->preferences->delete('portal_order'); |
---|
| 211 | @reset($GLOBALS['phpgw_info']['apps']); |
---|
| 212 | $order = 0; |
---|
| 213 | while (list(,$p) = each($GLOBALS['phpgw_info']['apps'])) |
---|
| 214 | { |
---|
| 215 | if($GLOBALS['phpgw_info']['user']['apps'][$p['name']]) |
---|
| 216 | { |
---|
| 217 | $GLOBALS['phpgw']->preferences->add('portal_order',$order++,$p['id']); |
---|
| 218 | } |
---|
| 219 | } |
---|
| 220 | $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | if(is_array($GLOBALS['phpgw_info']['user']['preferences']['portal_order'])) |
---|
| 224 | { |
---|
| 225 | $app_check = Array(); |
---|
| 226 | @ksort($GLOBALS['phpgw_info']['user']['preferences']['portal_order']); |
---|
| 227 | while(list($order,$app) = each($GLOBALS['phpgw_info']['user']['preferences']['portal_order'])) |
---|
| 228 | { |
---|
| 229 | if(!isset($app_check[(int)$app]) || !$app_check[(int)$app]) |
---|
| 230 | { |
---|
| 231 | $app_check[(int)$app] = True; |
---|
| 232 | $sorted_apps[] = $GLOBALS['phpgw']->applications->id2name((int)$app); |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | } |
---|
| 236 | else |
---|
| 237 | { |
---|
| 238 | $sorted_apps = Array( |
---|
| 239 | 'calendar', |
---|
| 240 | 'email', |
---|
| 241 | 'infolog', |
---|
| 242 | 'news_admin' |
---|
| 243 | ); |
---|
| 244 | } |
---|
| 245 | |
---|
| 246 | // Now add the rest of the user's apps, to make sure we pick up any additions to the home display |
---|
| 247 | @reset($GLOBALS['phpgw_info']['user']['apps']); |
---|
| 248 | while(list(,$p) = each($GLOBALS['phpgw_info']['user']['apps'])) |
---|
| 249 | { |
---|
| 250 | $sorted_apps[] = $p['name']; |
---|
| 251 | } |
---|
| 252 | //$GLOBALS['phpgw']->hooks->process('home',$sorted_apps); |
---|
| 253 | |
---|
| 254 | function migrate_pref($appname,$var_old,$var_new,$type='user') |
---|
| 255 | { |
---|
| 256 | if(empty($appname) || empty($var_old) || empty($var_new)) |
---|
| 257 | { |
---|
| 258 | return false; |
---|
| 259 | } |
---|
| 260 | $allowedtypes = array('user','default','forced'); |
---|
| 261 | if($type=='all') |
---|
| 262 | { |
---|
| 263 | $types = $allowedtypes; |
---|
| 264 | } |
---|
| 265 | elseif(in_array($type,$allowedtypes)) |
---|
| 266 | { |
---|
| 267 | $types[] = $type; |
---|
| 268 | } |
---|
| 269 | else |
---|
| 270 | { |
---|
| 271 | return false; |
---|
| 272 | } |
---|
| 273 | $result = false; |
---|
| 274 | foreach($types as $_type) |
---|
| 275 | { |
---|
| 276 | if(isset($GLOBALS['phpgw']->preferences->$_type[$appname][$var_old])) |
---|
| 277 | { |
---|
| 278 | $GLOBALS['phpgw']->preferences->$_type[$appname][$var_new] = |
---|
| 279 | $GLOBALS['phpgw']->preferences->$_type[$appname][$var_old]; |
---|
| 280 | $result = true; |
---|
| 281 | $GLOBALS['phpgw_info']['user']['preferences'] = |
---|
| 282 | $GLOBALS['phpgw']->preferences->save_repository(false,$_type); |
---|
| 283 | } |
---|
| 284 | } |
---|
| 285 | return $result; |
---|
| 286 | } |
---|
| 287 | |
---|
| 288 | $portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated'); |
---|
| 289 | $migrate_oldvarnames = false; |
---|
| 290 | if($migrate_oldvarnames) |
---|
| 291 | { |
---|
| 292 | $_apps = $GLOBALS['phpgw_info']['user']['apps']; |
---|
| 293 | @reset($_apps); |
---|
| 294 | foreach($_apps as $_appname) |
---|
| 295 | { |
---|
| 296 | @reset($portal_oldvarnames); |
---|
| 297 | foreach($portal_oldvarnames as $varname) |
---|
| 298 | { |
---|
| 299 | //echo "Want to migrate '$appname' from '$varname' to 'homepage_display'.<br>"; |
---|
| 300 | //migrate_pref($appname,$varname,'homepage_display','all'); |
---|
| 301 | } |
---|
| 302 | } |
---|
| 303 | } |
---|
| 304 | |
---|
| 305 | $neworder = array(); |
---|
| 306 | $done = array(); |
---|
| 307 | // Display elements, within appropriate table cells |
---|
| 308 | print '<table border="0" cellpadding="5" cellspacing="0" width="100%">'; |
---|
| 309 | $tropen=0; |
---|
| 310 | $tdopen=0; |
---|
| 311 | $lastd = 0; |
---|
| 312 | $numcols = 2; |
---|
| 313 | $curcol = 1; |
---|
| 314 | @reset($sorted_apps); |
---|
| 315 | foreach($sorted_apps as $appname) |
---|
| 316 | { |
---|
| 317 | if((int)$done[$appname] == 1 || empty($appname)) |
---|
| 318 | { |
---|
| 319 | continue; |
---|
| 320 | } |
---|
| 321 | $varnames = $portal_oldvarnames; |
---|
| 322 | $varnames[] = 'homepage_display'; |
---|
| 323 | $thisd = 0; |
---|
| 324 | $tmp = ''; |
---|
| 325 | foreach($varnames as $varcheck) |
---|
| 326 | { |
---|
| 327 | if($appname == 'expressoMail1_2') { |
---|
| 328 | $tmp = $appname; |
---|
| 329 | $appname = 'expressoMail'; |
---|
| 330 | } |
---|
| 331 | // echo "$appname:$varcheck=".$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]."<br>"; |
---|
| 332 | if($GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]=='True') |
---|
| 333 | { |
---|
| 334 | $thisd = 1; |
---|
| 335 | break; |
---|
| 336 | } |
---|
| 337 | else |
---|
| 338 | { |
---|
| 339 | $_thisd = (int)$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]; |
---|
| 340 | if($_thisd>0) |
---|
| 341 | { |
---|
| 342 | //echo "Found $appname=$_thisd through $varcheck<br>"; |
---|
| 343 | $thisd = $_thisd; |
---|
| 344 | break; |
---|
| 345 | } |
---|
| 346 | } |
---|
| 347 | } |
---|
| 348 | //echo "$appname: $thisd<br>"; |
---|
| 349 | if($thisd>0) |
---|
| 350 | { |
---|
| 351 | if((($curcol++>$numcols) || ($thisd+$lastd==3)) && $tropen==1) |
---|
| 352 | { |
---|
| 353 | print '</tr>'; |
---|
| 354 | $tropen = 0; |
---|
| 355 | //$curcol = 1; |
---|
| 356 | } |
---|
| 357 | if(!$tropen) |
---|
| 358 | { |
---|
| 359 | print '<tr>'; |
---|
| 360 | $tropen=1; |
---|
| 361 | } |
---|
| 362 | $tdwidth = ($thisd==2)?'50':'100'; |
---|
| 363 | $colspan = ($thisd==2)?'1':'2'; |
---|
| 364 | print '<td valign="top" colspan="'.$colspan.'" width="'.$tdwidth.'%">'; |
---|
| 365 | if($tmp) { |
---|
| 366 | $appname = $tmp; |
---|
| 367 | $tmp = ''; |
---|
| 368 | } |
---|
| 369 | $result = $GLOBALS['phpgw']->hooks->single('home',$appname); |
---|
| 370 | print '</td>'; |
---|
| 371 | if(($thisd!=2 || ($thisd==2&&$lastd==2)) && $tropen) |
---|
| 372 | { |
---|
| 373 | print '</tr>'; |
---|
| 374 | $tropen = 0; |
---|
| 375 | $lastd = 0; |
---|
| 376 | $curcol = 1; |
---|
| 377 | } |
---|
| 378 | else |
---|
| 379 | { |
---|
| 380 | $lastd = $thisd; |
---|
| 381 | } |
---|
| 382 | $neworder[] = $appname; |
---|
| 383 | } |
---|
| 384 | $done[$appname] = 1; |
---|
| 385 | } |
---|
| 386 | print '</table>'; |
---|
| 387 | |
---|
| 388 | // Update stored value of order |
---|
| 389 | //_debug_array($neworder); |
---|
| 390 | if(count($neworder)>0)//$GLOBALS['portal_order']) |
---|
| 391 | { |
---|
| 392 | $GLOBALS['phpgw']->preferences->delete('portal_order'); |
---|
| 393 | @reset($neworder); |
---|
| 394 | while(list($app_order,$app_name) = each($neworder)) |
---|
| 395 | { |
---|
| 396 | $app_id = $GLOBALS['phpgw']->applications->name2id($app_name); |
---|
| 397 | //echo "neworder: $app_order=$app_id:$app_name<br>"; |
---|
| 398 | $GLOBALS['phpgw']->preferences->add('portal_order',$app_order,$app_id); |
---|
| 399 | } |
---|
| 400 | $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->save_repository(); |
---|
| 401 | } |
---|
| 402 | //_debug_array($GLOBALS['phpgw_info']['user']['preferences']); |
---|
| 403 | |
---|
| 404 | //$phpgw->common->debug_phpgw_info(); |
---|
| 405 | //$phpgw->common->debug_list_core_functions(); |
---|
| 406 | $GLOBALS['phpgw']->common->phpgw_footer(); |
---|
| 407 | ?> |
---|