| [ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /**************************************************************************\ 3 * eGroupWare - Setup * 4 * http://www.egroupware.org * 5 * -------------------------------------------- * 6 * This program is free software; you can redistribute it and/or modify it * 7 * under the terms of the GNU General Public License as published by the * 8 * Free Software Foundation; either version 2 of the License, or (at your * 9 * option) any later version. * 10 \**************************************************************************/ 11 12 /* $Id: applications.php 20295 2006-02-15 12:31:25Z $ */ 13 14 $DEBUG = @$_POST['debug'] || @$_GET['debug']; 15 /* 16 TODO: We allow a user to hose their setup here, need to make use 17 of dependencies so they are warned that they are pulling the rug 18 out from under other apps. e.g. if they select to uninstall the api 19 this will happen without further warning. 20 */ 21 22 $GLOBALS['egw_info'] = array( 23 'flags' => array( 24 'noheader' => True, 25 'nonavbar' => True, 26 'currentapp' => 'home', 27 'noapi' => True 28 )); 29 include ('./inc/functions.inc.php'); 30 31 @set_time_limit(0); 32 33 // Check header and authentication 34 if (!$GLOBALS['egw_setup']->auth('Config')) 35 { 36 Header('Location: index.php'); 37 exit; 38 } 39 // Does not return unless user is authorized 40 41 $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); 42 $setup_tpl = CreateObject('setup.Template',$tpl_root); 43 $setup_tpl->set_file(array( 44 'T_head' => 'head.tpl', 45 'T_footer' => 'footer.tpl', 46 'T_alert_msg' => 'msg_alert_msg.tpl', 47 'T_login_main' => 'login_main.tpl', 48 'T_login_stage_header' => 'login_stage_header.tpl', 49 'T_setup_main' => 'applications.tpl' 50 )); 51 52 $setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain'); 53 $setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain'); 54 $setup_tpl->set_block('T_setup_main','header','header'); 55 $setup_tpl->set_block('T_setup_main','app_header','app_header'); 56 $setup_tpl->set_block('T_setup_main','apps','apps'); 57 $setup_tpl->set_block('T_setup_main','detail','detail'); 58 $setup_tpl->set_block('T_setup_main','table','table'); 59 $setup_tpl->set_block('T_setup_main','hook','hook'); 60 $setup_tpl->set_block('T_setup_main','dep','dep'); 61 $setup_tpl->set_block('T_setup_main','app_footer','app_footer'); 62 $setup_tpl->set_block('T_setup_main','submit','submit'); 63 $setup_tpl->set_block('T_setup_main','footer','footer'); 64 65 $bgcolor = array('#DDDDDD','#EEEEEE'); 66 67 function parsedep($depends,$main=True) 68 { 69 $depstring = '('; 70 foreach($depends as $a => $b) 71 { 72 foreach($b as $c => $d) 73 { 74 if (is_array($d)) 75 { 76 $depstring .= $c . ': ' .implode(',',$d) . '; '; 77 $depver[] = $d; 78 } 79 else 80 { 81 $depstring .= $c . ': ' . $d . '; '; 82 $depapp[] = $d; 83 } 84 } 85 } 86 $depstring .= ')'; 87 if ($main) 88 { 89 return $depstring; 90 } 91 else 92 { 93 return array($depapp,$depver); 94 } 95 } 96 97 $GLOBALS['egw_setup']->loaddb(); 98 $GLOBALS['egw_info']['setup']['stage']['db'] = $GLOBALS['egw_setup']->detection->check_db(); 99 100 $setup_info = $GLOBALS['egw_setup']->detection->get_versions(); 101 //var_dump($setup_info);exit; 102 $setup_info = $GLOBALS['egw_setup']->detection->get_db_versions($setup_info); 103 //var_dump($setup_info);exit; 104 $setup_info = $GLOBALS['egw_setup']->detection->compare_versions($setup_info); 105 //var_dump($setup_info);exit; 106 $setup_info = $GLOBALS['egw_setup']->detection->check_depends($setup_info); 107 //var_dump($setup_info);exit; 108 @ksort($setup_info); 109 110 if(@get_var('cancel',Array('POST'))) 111 { 112 Header("Location: index.php"); 113 exit; 114 } 115 116 if(@get_var('submit',Array('POST'))) 117 { 118 $GLOBALS['egw_setup']->html->show_header(lang('Application Management'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); 119 $setup_tpl->set_var('description',lang('App install/remove/upgrade') . ':'); 120 $setup_tpl->pparse('out','header'); 121 122 $appname = get_var('appname',Array('POST')); 123 $remove = get_var('remove',Array('POST')); 124 $install = get_var('install',Array('POST')); 125 $upgrade = get_var('upgrade',Array('POST')); 126 127 $do_langs = false; 128 129 if(!empty($remove) && is_array($remove)) 130 { 131 $historylog = CreateObject('phpgwapi.historylog'); 132 $historylog->db = $GLOBALS['egw_setup']->db; 133 134 foreach($remove as $appname => $key) 135 { 136 $app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name']; 137 $terror = array(); 138 $terror[] = $setup_info[$appname]; 139 140 if ($setup_info[$appname]['tables']) 141 { 142 $GLOBALS['egw_setup']->process->droptables($terror,$DEBUG); 143 echo '<br />' . $app_title . ' ' . lang('tables dropped') . '.'; 144 } 145 146 $GLOBALS['egw_setup']->deregister_app($setup_info[$appname]['name']); 147 echo '<br />' . $app_title . ' ' . lang('deregistered') . '.'; 148 149 if ($setup_info[$appname]['hooks']) 150 { 151 $GLOBALS['egw_setup']->deregister_hooks($setup_info[$appname]['name']); 152 echo '<br />' . $app_title . ' ' . lang('hooks deregistered') . '.'; 153 } 154 $do_langs = true; 155 156 if ($historylog->delete($appname)) 157 { 158 echo '<br />' . $app_title . ' ' . lang('Historylog removed') . '.'; 159 } 160 161 // delete all application categories and ACL 162 $GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->cats_table,array('cat_appname' => $appname),__LINE__,__FILE__); 163 $GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->acl_table,array('acl_appname' => $appname),__LINE__,__FILE__); 164 } 165 } 166 167 if(!empty($install) && is_array($install)) 168 { 169 foreach($install as $appname => $key) 170 { 171 $app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name']; 172 $terror = array(); 173 $terror[] = $setup_info[$appname]; 174 175 if ($setup_info[$appname]['tables']) 176 { 177 $terror = $GLOBALS['egw_setup']->process->current($terror,$DEBUG); 178 $terror = $GLOBALS['egw_setup']->process->default_records($terror,$DEBUG); 179 echo '<br />' . $app_title . ' ' 180 . lang('tables installed, unless there are errors printed above') . '.'; 181 } 182 else 183 { 184 if ($GLOBALS['egw_setup']->app_registered($setup_info[$appname]['name'])) 185 { 186 $GLOBALS['egw_setup']->update_app($setup_info[$appname]['name']); 187 } 188 else 189 { 190 $GLOBALS['egw_setup']->register_app($setup_info[$appname]['name']); 191 } 192 echo '<br />' . $app_title . ' ' . lang('registered') . '.'; 193 194 if ($setup_info[$appname]['hooks']) 195 { 196 $GLOBALS['egw_setup']->register_hooks($setup_info[$appname]['name']); 197 echo '<br />' . $app_title . ' ' . lang('hooks registered') . '.'; 198 } 199 } 200 $do_langs = true; 201 } 202 } 203 204 if(!empty($upgrade) && is_array($upgrade)) 205 { 206 foreach($upgrade as $appname => $key) 207 { 208 $app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name']; 209 $terror = array(); 210 $terror[] = $setup_info[$appname]; 211 212 $GLOBALS['egw_setup']->process->upgrade($terror,$DEBUG); 213 if ($setup_info[$appname]['tables']) 214 { 215 echo '<br />' . $app_title . ' ' . lang('tables upgraded') . '.'; 216 // The process_upgrade() function also handles registration 217 } 218 else 219 { 220 echo '<br />' . $app_title . ' ' . lang('upgraded') . '.'; 221 } 222 $do_langs = true; 223 } 224 } 225 if ($do_langs) 226 { 227 $GLOBALS['egw_setup']->process->translation->drop_add_all_langs(); 228 } 229 //$setup_tpl->set_var('goback', 230 echo '<br /><a href="applications.php?debug='.$DEBUG.'">' . lang('Go back') . '</a>'; 231 //$setup_tpl->pparse('out','submit'); 232 $setup_tpl->pparse('out','footer'); 233 exit; 234 } 235 else 236 { 237 $GLOBALS['egw_setup']->html->show_header(lang('Application Management'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); 238 } 239 240 $detail = get_var('detail',Array('GET')); 241 $resolve = get_var('resolve',Array('GET')); 242 if(@$detail) 243 { 244 @ksort($setup_info[$detail]); 245 $setup_tpl->set_var('description',lang('App details') . ':'); 246 $setup_tpl->pparse('out','header'); 247 248 $setup_tpl->set_var('name','application'); 249 $setup_tpl->set_var('details', lang($setup_info[$detail]['title'])); 250 $setup_tpl->pparse('out','detail'); 251 252 foreach($setup_info[$detail] as $key => $val) 253 { 254 if($key != 'title') 255 { 256 $i = ($i ? 0 : 1); 257 258 if ($key == 'tables') 259 { 260 $tblcnt = count($setup_info[$detail][$key]); 261 if(is_array($val)) 262 { 263 $key = '<a href="sqltoarray.php?appname=' . $detail . '&submit=True&apps=True">' . $key . '(' . $tblcnt . ')</a>' . "\n"; 264 $val = implode(',' . "\n",$val); 265 } 266 } 267 if ($key == 'hooks') { $val = implode(',',$val); } 268 if ($key == 'depends') { $val = parsedep($val); } 269 if (is_array($val)) { $val = implode(',',$val); } 270 271 $setup_tpl->set_var('bg_color',$bgcolor[$i]); 272 $setup_tpl->set_var('name',$key); 273 $setup_tpl->set_var('details',$val); 274 $setup_tpl->pparse('out','detail'); 275 } 276 } 277 278 echo '<br /><a href="applications.php?debug='.$DEBUG.'">' . lang('Go back') . '</a>'; 279 $setup_tpl->pparse('out','footer'); 280 exit; 281 } 282 elseif (@$resolve) 283 { 284 $version = get_var('version',Array('GET')); 285 $notables = get_var('notables',Array('GET')); 286 $setup_tpl->set_var('description',lang('Problem resolution'). ':'); 287 $setup_tpl->pparse('out','header'); 288 $app_title = $setup_info[$resolve]['title'] ? $setup_info[$resolve]['title'] : $setup_info[$resolve]['name']; 289 290 if(get_var('post',Array('GET'))) 291 { 292 echo '"' . $app_title . '" ' . lang('may be broken') . ' '; 293 echo lang('because an application it depends upon was upgraded'); 294 echo '<br />'; 295 echo lang('to a version it does not know about') . '.'; 296 echo '<br />'; 297 echo lang('However, the application may still work') . '.'; 298 } 299 elseif(get_var('badinstall',Array('GET'))) 300 { 301 echo '"' . $app_title . '" ' . lang('is broken') . ' '; 302 echo lang('because of a failed upgrade or install') . '.'; 303 echo '<br />'; 304 echo lang('Some or all of its tables are missing') . '.'; 305 echo '<br />'; 306 echo lang('You should either uninstall and then reinstall it, or attempt manual repairs') . '.'; 307 } 308 elseif (!$version) 309 { 310 if($setup_info[$resolve]['enabled']) 311 { 312 echo '"' . $app_title . '" ' . lang('is broken') . ' '; 313 } 314 else 315 { 316 echo '"' . $app_title . '" ' . lang('is disabled') . ' '; 317 } 318 319 if (!$notables) 320 { 321 if($setup_info[$resolve]['status'] == 'D') 322 { 323 echo lang('because it depends upon') . ':<br />' . "\n"; 324 list($depapp,$depver) = parsedep($setup_info[$resolve]['depends'],False); 325 $depapp_count = count($depapp); 326 for ($i=0; $i<$depapp_count; $i++) 327 { 328 echo '<br />' . $depapp[$i] . ': '; 329 $list = ''; 330 foreach($depver[$i] as $x => $y) 331 { 332 $list .= $y . ', '; 333 } 334 $list = substr($list,0,-2); 335 echo "$list\n"; 336 } 337 echo '<br /><br />' . lang('The table definition was correct, and the tables were installed') . '.'; 338 } 339 else 340 { 341 echo lang('because it was manually disabled') . '.'; 342 } 343 } 344 elseif($setup_info[$resolve]['enable'] == 2) 345 { 346 echo lang('because it is not a user application, or access is controlled via acl') . '.'; 347 } 348 elseif($setup_info[$resolve]['enable'] == 0) 349 { 350 echo lang('because the enable flag for this app is set to 0, or is undefined') . '.'; 351 } 352 else 353 { 354 echo lang('because it requires manual table installation, <br />or the table definition was incorrect') . ".\n" 355 . lang("Please check for sql scripts within the application's directory") . '.'; 356 } 357 echo '<br />' . lang('However, the application is otherwise installed') . '.'; 358 } 359 else 360 { 361 echo $app_title . ' ' . lang('has a version mismatch') . ' '; 362 echo lang('because of a failed upgrade, or the database is newer than the installed version of this app') . '.'; 363 echo '<br />'; 364 echo lang('If the application has no defined tables, selecting upgrade should remedy the problem') . '.'; 365 echo '<br />' . lang('However, the application is otherwise installed') . '.'; 366 } 367 368 echo '<br /><a href="applications.php?debug='.$DEBUG.'">' . lang('Go back') . '</a>'; 369 $setup_tpl->pparse('out','footer'); 370 exit; 371 } 372 else 373 { 374 $setup_tpl->set_var('description',lang('Select the desired action(s) from the available choices')); 375 $setup_tpl->set_var('action_url','applications.php'); 376 $setup_tpl->pparse('out','header'); 377 378 $setup_tpl->set_var('appdata',lang('Application Data')); 379 $setup_tpl->set_var('actions',lang('Actions')); 380 $setup_tpl->set_var('app_info',lang('Application Name and Status Information')); 381 $setup_tpl->set_var('app_title',lang('Application Title')); 382 $setup_tpl->set_var('app_currentver',lang('Current Version')); 383 $setup_tpl->set_var('app_version',lang('Available Version')); 384 $setup_tpl->set_var('app_install',lang('Install')); 385 $setup_tpl->set_var('app_remove',lang('Remove')); 386 $setup_tpl->set_var('app_upgrade',lang('Upgrade')); 387 $setup_tpl->set_var('app_resolve',lang('Resolve')); 388 $setup_tpl->set_var('check','check.png'); 389 $setup_tpl->set_var('install_all',lang('Install All')); 390 $setup_tpl->set_var('upgrade_all',lang('Upgrade All')); 391 $setup_tpl->set_var('remove_all',lang('Remove All')); 392 $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); 393 $setup_tpl->set_var('debug','<input type="checkbox" name="debug" value="True"' .($DEBUG ? ' checked="checked"' : '') . ' />'); 394 $setup_tpl->set_var('bg_color',$bgcolor[0]); 395 396 $setup_tpl->pparse('out','app_header'); 397 398 $i = 0; 399 foreach($setup_info as $key => $value) 400 { 401 if(@$value['name']) 402 { 403 $i = ($i ? 0 : 1); 404 $setup_tpl->set_var('apptitle',$value['title']?$value['title']:lang($value['name'])); 405 $setup_tpl->set_var('currentver',@$value['currentver']); 406 $setup_tpl->set_var('version',$value['version']); 407 $setup_tpl->set_var('bg_color',$bgcolor[$i]); 408 409 switch($value['status']) 410 { 411 case 'C': 412 $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); 413 $setup_tpl->set_var('upgrade',' '); 414 if (!$GLOBALS['egw_setup']->detection->check_app_tables($value['name'])) 415 { 416 // App installed and enabled, but some tables are missing 417 $setup_tpl->set_var('instimg','table.png'); 418 $setup_tpl->set_var('bg_color','FFCCAA'); 419 $setup_tpl->set_var('instalt',lang('Not Completed')); 420 $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&badinstall=True">' . lang('Potential Problem') . '</a>'); 421 $status = lang('Requires reinstall or manual repair') . ' - ' . $value['status']; 422 } 423 else 424 { 425 $setup_tpl->set_var('instimg','completed.png'); 426 $setup_tpl->set_var('instalt',lang('Completed')); 427 $setup_tpl->set_var('install',' '); 428 if($value['enabled']) 429 { 430 $setup_tpl->set_var('resolution',''); 431 $status = lang('OK') . ' - ' . $value['status']; 432 } 433 else 434 { 435 if ($value['tables'][0] != '') 436 { 437 $notables = '¬ables=True'; 438 } 439 $setup_tpl->set_var('bg_color','CCCCFF'); 440 $setup_tpl->set_var('resolution', 441 '<a href="applications.php?resolve=' . $value['name'] . $notables . '">' . lang('Possible Reasons') . '</a>' 442 ); 443 $status = lang('Disabled') . ' - ' . $value['status']; 444 } 445 } 446 break; 447 case 'U': 448 $setup_tpl->set_var('instimg','incomplete.png'); 449 $setup_tpl->set_var('instalt',lang('Not Completed')); 450 if (!@$value['currentver']) 451 { 452 if ($value['tables'] && $GLOBALS['egw_setup']->detection->check_app_tables($value['name'],True)) 453 { 454 // Some tables missing 455 $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); 456 $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&badinstall=True">' . lang('Potential Problem') . '</a>'); 457 $status = lang('Requires reinstall or manual repair') . ' - ' . $value['status']; 458 } 459 else 460 { 461 $setup_tpl->set_var('remove',' '); 462 $setup_tpl->set_var('resolution',''); 463 $status = lang('Requires upgrade') . ' - ' . $value['status']; 464 } 465 // show not installed apps without icon 466 $setup_tpl->set_var('instimg','spacer.png'); 467 $setup_tpl->set_var('instalt',''); 468 $setup_tpl->set_var('bg_color','CCFFCC'); 469 $setup_tpl->set_var('install','<input type="checkbox" name="install[' . $value['name'] . ']" />'); 470 $setup_tpl->set_var('upgrade',' '); 471 $status = lang('Please install') . ' - ' . $value['status']; 472 } 473 else 474 { 475 $setup_tpl->set_var('bg_color','CCCCFF'); 476 $setup_tpl->set_var('install',' '); 477 // TODO display some info about breakage if you mess with this app 478 $setup_tpl->set_var('upgrade','<input type="checkbox" name="upgrade[' . $value['name'] . ']" />'); 479 $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); 480 $setup_tpl->set_var('resolution',''); 481 $status = lang('Requires upgrade') . ' - ' . $value['status']; 482 } 483 break; 484 case 'V': 485 $setup_tpl->set_var('instimg','incomplete.png'); 486 $setup_tpl->set_var('instalt',lang('Not Completed')); 487 $setup_tpl->set_var('install',' '); 488 $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); 489 $setup_tpl->set_var('upgrade','<input type="checkbox" name="upgrade[' . $value['name'] . ']" />'); 490 $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&version=True">' . lang('Possible Solutions') . '</a>'); 491 $status = lang('Version Mismatch') . ' - ' . $value['status']; 492 break; 493 case 'D': 494 $setup_tpl->set_var('bg_color','FFCCCC'); 495 $depstring = parsedep($value['depends']); 496 $depstring .= ')'; 497 $setup_tpl->set_var('instimg','dep.png'); 498 $setup_tpl->set_var('instalt',lang('Dependency Failure')); 499 $setup_tpl->set_var('install',' '); 500 $setup_tpl->set_var('remove',' '); 501 $setup_tpl->set_var('upgrade',' '); 502 $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '">' . lang('Possible Solutions') . '</a>'); 503 $status = lang('Dependency Failure') . ':' . $depstring . $value['status']; 504 break; 505 case 'P': 506 $setup_tpl->set_var('bg_color','FFCCFF'); 507 $depstring = parsedep($value['depends']); 508 $depstring .= ')'; 509 $setup_tpl->set_var('instimg','dep.png'); 510 $setup_tpl->set_var('instalt',lang('Post-install Dependency Failure')); 511 $setup_tpl->set_var('install',' '); 512 $setup_tpl->set_var('remove',' '); 513 $setup_tpl->set_var('upgrade',' '); 514 $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&post=True">' . lang('Possible Solutions') . '</a>'); 515 $status = lang('Post-install Dependency Failure') . ':' . $depstring . $value['status']; 516 break; 517 default: 518 $setup_tpl->set_var('instimg','incomplete.png'); 519 $setup_tpl->set_var('instalt',lang('Not Completed')); 520 $setup_tpl->set_var('install',' '); 521 $setup_tpl->set_var('remove',' '); 522 $setup_tpl->set_var('upgrade',' '); 523 $setup_tpl->set_var('resolution',''); 524 $status = ''; 525 break; 526 } 527 //$setup_tpl->set_var('appname',$value['name'] . '-' . $status . ',' . $value['filename']); 528 $setup_tpl->set_var('appinfo',$value['name'] . '-' . $status); 529 $setup_tpl->set_var('appname',$value['name']); 530 531 $setup_tpl->pparse('out','apps',True); 532 } 533 } 534 535 $setup_tpl->set_var('submit',lang('Save')); 536 $setup_tpl->set_var('cancel',lang('Cancel')); 537 $setup_tpl->pparse('out','app_footer'); 538 $setup_tpl->pparse('out','footer'); 539 $GLOBALS['egw_setup']->html->show_footer(); 540 } 541 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |