- Timestamp:
- 01/03/08 14:11:13 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/home.php
r2 r142 11 11 * option) any later version. * 12 12 \**************************************************************************/ 13 14 15 13 $phpgw_info = array(); 16 14 if (!is_file('header.inc.php')) … … 59 57 } 60 58 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']) 59 if ($_GET['cd']=='yes' && $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] && 60 $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['user']['preferences']['common']['default_app']]) 180 61 { 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 } 62 $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['default_app'] . '/' . 'index.php')); 235 63 } 236 64 else 237 65 { 238 $sorted_apps = Array( 66 $GLOBALS['phpgw']->common->phpgw_header(); 67 echo parse_navbar(); 68 } 69 // Default Applications (Home Page) 70 $default_apps = Array( 71 'workflow', 72 'expressoMail1_2', 239 73 'calendar', 240 'email',241 'infolog',242 74 'news_admin' 243 75 ); 76 $sorted_apps = array(); 77 $user_apps = $GLOBALS['phpgw_info']['user']['apps']; 78 @reset($user_apps); 79 for($i = 0; $i < count($default_apps);$i++) { 80 if(array_key_exists($default_apps[$i], $user_apps)){ 81 $sorted_apps[] = $default_apps[$i]; 82 } 244 83 } 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 { 84 85 foreach($GLOBALS['phpgw_info']['user']['apps'] as $i => $p) { 250 86 $sorted_apps[] = $p['name']; 251 87 } 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 88 288 89 $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 90 $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; 91 // Display elements, within appropriate table cells 314 92 @reset($sorted_apps); 93 $idx = 1; 94 echo "<table width='100%' cellpadding=5>"; 315 95 foreach($sorted_apps as $appname) 316 96 { 317 if((int)$done[$appname] == 1 || empty($appname)) 318 { 97 if((int)$done[$appname] == 1 || empty($appname)){ 319 98 continue; 320 } 99 } 321 100 $varnames = $portal_oldvarnames; 322 101 $varnames[] = 'homepage_display'; 323 102 $thisd = 0; 324 103 $tmp = ''; 104 325 105 foreach($varnames as $varcheck) 326 106 { 327 if($appname == 'expressoMail1_2') { 107 108 /*if($appname == 'expressoMail1_2') { 328 109 $tmp = $appname; 329 110 $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 { 111 }*/ 112 113 if(array_search($appname, $default_apps) !== False){ 334 114 $thisd = 1; 335 115 break; 336 116 } 337 else 338 { 117 if($GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]=='True') { 118 $thisd = 1; 119 break; 120 } 121 else { 339 122 $_thisd = (int)$GLOBALS['phpgw_info']['user']['preferences'][$appname][$varcheck]; 340 if($_thisd>0) 341 { 342 //echo "Found $appname=$_thisd through $varcheck<br>"; 123 if($_thisd > 0) { 343 124 $thisd = $_thisd; 344 125 break; … … 346 127 } 347 128 } 348 //echo "$appname: $thisd<br>"; 349 if($thisd >0)129 130 if($thisd > 0) 350 131 { 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 132 if($tmp) { 366 133 $appname = $tmp; 367 134 $tmp = ''; 368 135 } 369 $result = $GLOBALS['phpgw']->hooks->single('home',$appname); 136 if($idx == 0) { 137 print '<tr>'; 138 } 139 print '<td style="vertical-align:top;" width="45%">'; 140 $GLOBALS['phpgw']->hooks->single('home',$appname); 370 141 print '</td>'; 371 if(($thisd!=2 || ($thisd==2&&$lastd==2)) && $tropen) 372 { 142 143 if($idx == 2){ 144 $idx = 0; 373 145 print '</tr>'; 374 $tropen = 0; 375 $lastd = 0; 376 $curcol = 1; 377 } 378 else 379 { 380 $lastd = $thisd; 381 } 146 } 147 $idx++; 382 148 $neworder[] = $appname; 383 149 } … … 385 151 } 386 152 print '</table>'; 387 388 // Update stored value of order389 //_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 153 $GLOBALS['phpgw']->common->phpgw_footer(); 407 154 ?>
Note: See TracChangeset
for help on using the changeset viewer.