1<?php 2 /**************************************************************************\ 3 * phpGroupWare * 4 * http://www.phpgroupware.org * 5 * The file written by Joseph Engo <jengo@phpgroupware.org> * 6 * -------------------------------------------- * 7 * This program is free software; you can redistribute it and/or modify it * 8 * under the terms of the GNU General Public License as published by the * 9 * Free Software Foundation; either version 2 of the License, or (at your * 10 * option) any later version. * 11 \**************************************************************************/ 12 13 /* $Id: home.php 21091 2010-03-25 23:04:57Z Caeies $ */ 14 15 $phpgw_info = array(); 16 if (!is_file('header.inc.php')) 17 { 18 echo '<p style="{text-align: center; font-weight: bold;}"><a href="setup/index.php>"'; 19 echo lang('It appears that phpGroupWare is not setup yet, please run setup.'); 20 echo '</a></p>'; 21 exit; 22 } 23 24 $GLOBALS['sessionid'] = @$_GET['sessionid'] ? $_GET['sessionid'] : $_COOKIE['sessionid']; 25 if (!isset($GLOBALS['sessionid']) || !$GLOBALS['sessionid']) 26 { 27 Header('Location: login.php'); 28 exit; 29 } 30 31 $GLOBALS['phpgw_info']['flags'] = array( 32 'noheader' => True, 33 'nonavbar' => True, 34 'currentapp' => 'home', 35 'enable_network_class' => True, 36 'enable_contacts_class' => True, 37 'enable_nextmatchs_class' => True 38 ); 39 include('header.inc.php'); 40 41 // check if forward parameter is set 42 if (@$_GET['phpgw_forward']) 43 { 44 foreach($_GET as $name => $value) 45 { 46 // find phpgw_ in the $_GET parameters but skip phpgw_forward because of redirect call below 47 if (ereg('phpgw_', $name) && ($name != 'phpgw_forward')) 48 { 49 $name = substr($name, 6); // cut 'phpgw_' 50 $extra_vars[$name] = $value; 51 } 52 } 53 54 $GLOBALS['phpgw']->redirect_link($_GET['phpgw_forward'], $extra_vars); 55 exit; 56 } 57 58 if ($GLOBALS['phpgw_info']['server']['force_default_app'] 59 && $GLOBALS['phpgw_info']['server']['force_default_app'] != 'user_choice') 60 { 61 $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] = $GLOBALS['phpgw_info']['server']['force_default_app']; 62 } 63 64 if (($GLOBALS['phpgw_info']['user']['preferences']['common']['useframes'] && 65 $GLOBALS['phpgw_info']['server']['useframes'] == 'allowed') || 66 ($GLOBALS['phpgw_info']['server']['useframes'] == 'always')) 67 { 68 if ($_GET['cd'] == 'yes') 69 { 70 if (! $navbarframe && ! $framebody) 71 { 72 $tpl = new Template(PHPGW_TEMPLATE_DIR); 73 $tpl->set_file(array( 74 'frames' => 'frames.tpl', 75 'frame_body' => 'frames_body.tpl', 76 'frame_navbar' => 'frames_navbar.tpl' 77 )); 78 $tpl->set_var('navbar_link',$GLOBALS['phpgw']->link('index.php','navbarframe=True&cd=yes')); 79 if ($GLOBALS['forward']) 80 { 81 $tpl->set_var('body_link',$GLOBALS['phpgw']->link($GLOBALS['forward'])); 82 } 83 else 84 { 85 $tpl->set_var('body_link',$GLOBALS['phpgw']->link('index.php','framebody=True&cd=yes')); 86 } 87 88 if ($GLOBALS['phpgw_info']['user']['preferences']['common']['frame_navbar_location'] == 'bottom') 89 { 90 $tpl->set_var('frame_size','*,60'); 91 $tpl->parse('frames_','frame_body',True); 92 $tpl->parse('frames_','frame_navbar',True); 93 } 94 else 95 { 96 $tpl->set_var('frame_size','60,*'); 97 $tpl->parse('frames_','frame_navbar',True); 98 $tpl->parse('frames_','frame_body',True); 99 } 100 $tpl->pparse('out','frames'); 101 } 102 if ($navbarframe) 103 { 104 $GLOBALS['phpgw']->common->phpgw_header(); 105 echo parse_navbar(); 106 } 107 } 108 } 109 elseif ($_GET['cd']=='yes' && $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] 110 && $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['user']['preferences']['common']['default_app']]) 111 { 112 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] . '/' . 'index.php')); 113 } 114 else 115 { 116 $GLOBALS['phpgw']->common->phpgw_header(); 117 echo parse_navbar(); 118 } 119 120 $GLOBALS['phpgw']->translation->add_app('mainscreen'); 121 if (lang('mainscreen_message') != 'mainscreen_message*') 122 { 123 echo '<center>' . stripslashes(lang('mainscreen_message')) . '</center>'; 124 } 125 126 if ((isset($GLOBALS['phpgw_info']['user']['apps']['admin']) && 127 $GLOBALS['phpgw_info']['user']['apps']['admin']) && 128 (isset($GLOBALS['phpgw_info']['server']['checkfornewversion']) && 129 $GLOBALS['phpgw_info']['server']['checkfornewversion'])) 130 { 131 $GLOBALS['phpgw']->network->set_addcrlf(False); 132 $lines = $GLOBALS['phpgw']->network->gethttpsocketfile('http://www.phpgroupware.org/currentversion'); 133 for ($i=0; $i<count($lines); $i++) 134 { 135 if (ereg('currentversion',$lines[$i])) 136 { 137 $line_found = explode(':',chop($lines[$i])); 138 } 139 } 140 if($GLOBALS['phpgw']->common->cmp_version($GLOBALS['phpgw_info']['server']['versions']['phpgwapi'],$line_found[1])) 141 { 142 echo '<p>There is a new version of phpGroupWare available. <a href="' 143 . 'http://www.phpgroupware.org">http://www.phpgroupware.org</a>'; 144 } 145 146 $_found = False; 147 $GLOBALS['phpgw']->db->query("select app_name,app_version from phpgw_applications",__LINE__,__FILE__); 148 while($GLOBALS['phpgw']->db->next_record()) 149 { 150 $_db_version = $GLOBALS['phpgw']->db->f('app_version'); 151 $_app_name = $GLOBALS['phpgw']->db->f('app_name'); 152 $_versionfile = $GLOBALS['phpgw']->common->get_app_dir($_app_name) . '/setup/setup.inc.php'; 153 if(file_exists($_versionfile)) 154 { 155 include($_versionfile); 156 $_file_version = $setup_info[$_app_name]['version']; 157 $_app_title = $GLOBALS['phpgw_info']['apps'][$_app_name]['title']; 158 unset($setup_info); 159 160 if($GLOBALS['phpgw']->common->cmp_version_long($_db_version,$_file_version)) 161 { 162 $_found = True; 163 $_app_string .= '<br />' . $_app_title; 164 } 165 unset($_file_version); 166 unset($_app_title); 167 } 168 unset($_db_version); 169 unset($_versionfile); 170 } 171 if($_found) 172 { 173 echo '<br />' . lang('The following applications require upgrades') . ':' . "\n"; 174 echo $_app_string . "\n"; 175 echo '<br />' . lang('Please run setup to become current') . '.' . "\n"; 176 unset($_app_string); 177 } 178 } 179 180 if (isset($GLOBALS['phpgw_info']['user']['apps']['notifywindow']) && 181 $GLOBALS['phpgw_info']['user']['apps']['notifywindow']) 182 { 183?> 184<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> 185 var NotifyWindow; 186 187 function opennotifywindow() 188 { 189 if (NotifyWindow) 190 { 191 if (NotifyWindow.closed) 192 { 193 NotifyWindow.stop; 194 NotifyWindow.close; 195 } 196 } 197 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"); 198 if (NotifyWindow.opener == null) 199 { 200 NotifyWindow.opener = window; 201 } 202 } 203</SCRIPT> 204 205<?php 206 echo '<a href="javascript:opennotifywindow()">' . lang('Open notify window') . '</a>'; 207 } 208 209 /* This initializes the users portal_order preference if it does not exist. */ 210 if(!is_array($GLOBALS['phpgw_info']['user']['preferences']['portal_order']) && $GLOBALS['phpgw_info']['apps']) 211 { 212 $GLOBALS['phpgw']->preferences->delete('portal_order'); 213 @reset($GLOBALS['phpgw_info']['apps']); 214 $order = 0; 215 while (list(,$p) = each($GLOBALS['phpgw_info']['apps'])) 216 { 217 if($GLOBALS['phpgw_info']['user']['apps'][$p['name']]) 218 { 219 $GLOBALS['phpgw']->preferences->add('portal_order',$order++,$p['id']); 220 } 221 } 222 $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->save_repository(); 223 } 224 225 if(is_array($GLOBALS['phpgw_info']['user']['preferences']['portal_order'])) 226 { 227 $app_check = Array(); 228 @ksort($GLOBALS['phpgw_info']['user']['preferences']['portal_order']); 229 while(list($order,$app) = each($GLOBALS['phpgw_info']['user']['preferences']['portal_order'])) 230 { 231 if(!isset($app_check[intval($app)]) || !$app_check[intval($app)]) 232 { 233 $app_check[intval($app)] = True; 234 $sorted_apps[] = $GLOBALS['phpgw']->applications->id2name(intval($app)); 235 } 236 } 237 } 238 else 239 { 240 $sorted_apps = Array( 241 'email', 242 'calendar', 243 'news_admin', 244 'addressbook', 245 'squirrelmail' 246 ); 247 } 248 @reset($sorted_apps); 249 $GLOBALS['phpgw']->hooks->process('home',$sorted_apps); 250 251 if($GLOBALS['portal_order']) 252 { 253 $GLOBALS['phpgw']->preferences->delete('portal_order'); 254 @reset($GLOBALS['portal_order']); 255 while(list($app_order,$app_id) = each($GLOBALS['portal_order'])) 256 { 257 $GLOBALS['phpgw']->preferences->add('portal_order',$app_order,$app_id); 258 } 259 $GLOBALS['phpgw']->preferences->save_repository(); 260 } 261 262 //$phpgw->common->debug_phpgw_info(); 263 //$phpgw->common->debug_list_core_functions(); 264 $GLOBALS['phpgw']->common->phpgw_footer(); 265?> 266