EGroupware /
egroupware
| 1 | <?php |
||
| 2 | /**************************************************************************\ |
||
| 3 | * EGroupware - Setup - Developer tools * |
||
| 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$ */ |
||
| 13 | |||
| 14 | $GLOBALS['DEBUG'] = True; |
||
| 15 | |||
| 16 | $GLOBALS['egw_info'] = array( |
||
| 17 | 'flags' => array( |
||
| 18 | 'noheader' => True, |
||
| 19 | 'nonavbar' => True, |
||
| 20 | 'currentapp' => 'home', |
||
| 21 | 'noapi' => True |
||
| 22 | )); |
||
| 23 | include('./inc/functions.inc.php'); |
||
| 24 | |||
| 25 | // Check header and authentication |
||
| 26 | if(!$GLOBALS['egw_setup']->auth('Config')) |
||
| 27 | { |
||
| 28 | Header('Location: index.php'); |
||
| 29 | exit; |
||
| 30 | } |
||
| 31 | // Does not return unless user is authorized |
||
| 32 | |||
| 33 | $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); |
||
| 34 | $GLOBALS['setup_tpl'] = CreateObject('phpgwapi.Template',$tpl_root); |
||
|
0 ignored issues
–
show
|
|||
| 35 | $GLOBALS['setup_tpl']->set_file(array( |
||
| 36 | 'T_head' => 'head.tpl', |
||
| 37 | 'T_footer' => 'footer.tpl', |
||
| 38 | 'T_alert_msg' => 'msg_alert_msg.tpl', |
||
| 39 | 'T_login_main' => 'login_main.tpl', |
||
| 40 | 'T_login_stage_header' => 'login_stage_header.tpl', |
||
| 41 | 'T_setup_main' => 'schema.tpl' |
||
| 42 | )); |
||
| 43 | |||
| 44 | $GLOBALS['setup_tpl']->set_block('T_login_stage_header','B_multi_domain','V_multi_domain'); |
||
| 45 | $GLOBALS['setup_tpl']->set_block('T_login_stage_header','B_single_domain','V_single_domain'); |
||
| 46 | $GLOBALS['setup_tpl']->set_block('T_setup_main','header','header'); |
||
| 47 | $GLOBALS['setup_tpl']->set_block('T_setup_main','app_header','app_header'); |
||
| 48 | $GLOBALS['setup_tpl']->set_block('T_setup_main','apps','apps'); |
||
| 49 | $GLOBALS['setup_tpl']->set_block('T_setup_main','detail','detail'); |
||
| 50 | $GLOBALS['setup_tpl']->set_block('T_setup_main','table','table'); |
||
| 51 | $GLOBALS['setup_tpl']->set_block('T_setup_main','hook','hook'); |
||
| 52 | $GLOBALS['setup_tpl']->set_block('T_setup_main','dep','dep'); |
||
| 53 | $GLOBALS['setup_tpl']->set_block('T_setup_main','app_footer','app_footer'); |
||
| 54 | $GLOBALS['setup_tpl']->set_block('T_setup_main','submit','submit'); |
||
| 55 | $GLOBALS['setup_tpl']->set_block('T_setup_main','footer','footer'); |
||
| 56 | |||
| 57 | $bgcolor = array('DDDDDD','EEEEEE'); |
||
| 58 | |||
| 59 | function parsedep($depends,$main=True) |
||
| 60 | { |
||
| 61 | $depstring = '('; |
||
| 62 | foreach($depends as $a => $b) |
||
| 63 | { |
||
| 64 | foreach($b as $c => $d) |
||
| 65 | { |
||
| 66 | if(is_array($d)) |
||
| 67 | { |
||
| 68 | $depstring .= $c . ': ' .implode(',',$d) . '; '; |
||
| 69 | $depver[] = $d; |
||
| 70 | } |
||
| 71 | else |
||
| 72 | { |
||
| 73 | $depstring .= $c . ': ' . $d . '; '; |
||
| 74 | $depapp[] = $d; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | } |
||
| 78 | $depstring .= ')'; |
||
| 79 | if($main) |
||
| 80 | { |
||
| 81 | return $depstring; |
||
| 82 | } |
||
| 83 | else |
||
| 84 | { |
||
| 85 | return array($depapp,$depver); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | $GLOBALS['egw_setup']->loaddb(); |
||
| 90 | $GLOBALS['egw_info']['setup']['stage']['db'] = $GLOBALS['egw_setup']->detection->check_db(); |
||
| 91 | |||
| 92 | $GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->get_versions(); |
||
| 93 | //var_dump($GLOBALS['setup_info']);exit; |
||
| 94 | $GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->get_db_versions($GLOBALS['setup_info']); |
||
| 95 | //var_dump($GLOBALS['setup_info']);exit; |
||
| 96 | $GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->compare_versions($GLOBALS['setup_info']); |
||
| 97 | //var_dump($GLOBALS['setup_info']);exit; |
||
| 98 | $GLOBALS['setup_info'] = $GLOBALS['egw_setup']->detection->check_depends($GLOBALS['setup_info']); |
||
| 99 | //var_dump($GLOBALS['setup_info']);exit; |
||
| 100 | @ksort($GLOBALS['setup_info']); |
||
| 101 | |||
| 102 | if($_POST['cancel']) |
||
| 103 | { |
||
| 104 | Header('Location: index.php'); |
||
| 105 | exit; |
||
| 106 | } |
||
| 107 | |||
| 108 | $GLOBALS['egw_setup']->html->show_header(lang("Developers' Table Schema Toy"),False,'config',$GLOBALS['egw_setup']->ConfigDomain); |
||
| 109 | |||
| 110 | if($_POST['submit']) |
||
| 111 | { |
||
| 112 | $GLOBALS['setup_tpl']->set_var('description',lang('App process') . ':'); |
||
| 113 | $GLOBALS['setup_tpl']->pparse('out','header'); |
||
| 114 | |||
| 115 | $appname = $_POST['appname']; |
||
| 116 | $install = $_POST['install']; |
||
| 117 | $version = $_POST['version']; |
||
| 118 | |||
| 119 | foreach($install as $appname => $key) |
||
| 120 | { |
||
| 121 | $terror = array(); |
||
| 122 | $terror[$appname]['name'] = $appname; |
||
| 123 | $terror[$appname]['version'] = $version[$appname]; |
||
| 124 | $terror[$appname]['status'] = 'U'; |
||
| 125 | |||
| 126 | $appdir = EGW_SERVER_ROOT . '/' . $appname . '/setup/'; |
||
| 127 | |||
| 128 | // Drop newest tables |
||
| 129 | $terror[$appname]['tables'] = $GLOBALS['setup_info'][$appname]['tables']; |
||
| 130 | $GLOBALS['egw_setup']->process->droptables($terror,$GLOBALS['DEBUG']); |
||
| 131 | $terror[$appname]['tables'] = array(); |
||
| 132 | |||
| 133 | // Reset tables field to baseline table names |
||
| 134 | if(file_exists($appdir.'tables_baseline.inc.php')) |
||
| 135 | { |
||
| 136 | include($appdir.'tables_baseline.inc.php'); |
||
| 137 | foreach($phpgw_baseline as $table => $null) |
||
| 138 | { |
||
| 139 | $terror[$appname]['tables'][] = $table; |
||
| 140 | echo '<br />Adding app table: ' . $table; |
||
| 141 | } |
||
| 142 | } |
||
| 143 | |||
| 144 | if($version[$appname]) |
||
| 145 | { |
||
| 146 | echo '<br />Processing ' . $terror[$appname]['name'] . ' to ' . $version[$appname]; |
||
| 147 | |||
| 148 | $terror = $GLOBALS['egw_setup']->process->droptables($terror,$GLOBALS['DEBUG']); |
||
| 149 | $GLOBALS['egw_setup']->deregister_app($terror[$appname]['name']); |
||
| 150 | |||
| 151 | $terror = $GLOBALS['egw_setup']->process->baseline($terror,$GLOBALS['DEBUG']); |
||
| 152 | $terror = $GLOBALS['egw_setup']->process->test_data($terror,$GLOBALS['DEBUG']); |
||
| 153 | |||
| 154 | $terror = $GLOBALS['egw_setup']->process->upgrade($terror,$GLOBALS['DEBUG']); |
||
| 155 | $terror[$appname]['version'] = $version[$appname]; |
||
| 156 | } |
||
| 157 | else |
||
| 158 | { |
||
| 159 | echo '<br />Baseline-only completed for ' . $terror[$appname]['name']; |
||
| 160 | } |
||
| 161 | echo '<br />' . $GLOBALS['setup_info'][$appname]['title'] . ' ' |
||
| 162 | . lang('tables installed, unless there are errors printed above') . '.'; |
||
| 163 | |||
| 164 | $GLOBALS['setup_info'][$appname]['version'] = $terror[$appname]['version']; |
||
| 165 | $GLOBALS['egw_setup']->register_app($appname); |
||
| 166 | echo '<br />' . $terror[$appname]['title'] . ' ' . lang('registered') . '.'; |
||
| 167 | } |
||
| 168 | |||
| 169 | echo '<br /><a href="schematoy.php">' . lang('Go back') . '</a>'; |
||
| 170 | $GLOBALS['setup_tpl']->pparse('out','footer'); |
||
| 171 | exit; |
||
| 172 | } |
||
| 173 | $detail = $_REQUEST['detail']; |
||
| 174 | if($detail) |
||
| 175 | { |
||
| 176 | @ksort($GLOBALS['setup_info'][$detail]); |
||
| 177 | @reset($GLOBALS['setup_info'][$detail]); |
||
| 178 | $GLOBALS['setup_tpl']->set_var('description',lang('App details') . ':'); |
||
| 179 | $GLOBALS['setup_tpl']->pparse('out','header'); |
||
| 180 | |||
| 181 | foreach($GLOBALS['setup_info'][$detail] as $key => $val) |
||
| 182 | { |
||
| 183 | $i = $i ? 0 : 1; |
||
| 184 | |||
| 185 | //if(!$val) { $val = 'none'; } |
||
| 186 | |||
| 187 | if($key == 'tables') |
||
| 188 | { |
||
| 189 | if(is_array($val)) |
||
| 190 | { |
||
| 191 | $key = '<a href="sqltoarray.php?appname=' . $detail . '&submit=True">' . $key . '</a>' . "\n"; |
||
| 192 | $val = implode(',',$val); |
||
| 193 | } |
||
| 194 | } |
||
| 195 | if($key == 'hooks') |
||
| 196 | { |
||
| 197 | $val = implode(',',$val); |
||
| 198 | } |
||
| 199 | if($key == 'depends') |
||
| 200 | { |
||
| 201 | $val = parsedep($val); |
||
| 202 | } |
||
| 203 | if(is_array($val)) |
||
| 204 | { |
||
| 205 | $val = implode(',',$val); |
||
| 206 | } |
||
| 207 | |||
| 208 | $GLOBALS['setup_tpl']->set_var('bg_color',$bgcolor[$i]); |
||
| 209 | $GLOBALS['setup_tpl']->set_var('name',$key); |
||
| 210 | $GLOBALS['setup_tpl']->set_var('details',$val); |
||
| 211 | $GLOBALS['setup_tpl']->pparse('out','detail'); |
||
| 212 | } |
||
| 213 | |||
| 214 | echo '<br /><a href="schematoy.php">' . lang('Go back') . '</a>'; |
||
| 215 | $GLOBALS['setup_tpl']->pparse('out','footer'); |
||
| 216 | exit; |
||
| 217 | } |
||
| 218 | else |
||
| 219 | { |
||
| 220 | $GLOBALS['setup_tpl']->set_var('description',lang("Select an app, enter a target version, then submit to process to that version.<br />If you do not enter a version, only the baseline tables will be installed for the app.<br /><blink>THIS WILL DROP ALL OF THE APPS' TABLES FIRST!</blink>")); |
||
| 221 | $GLOBALS['setup_tpl']->pparse('out','header'); |
||
| 222 | |||
| 223 | $GLOBALS['setup_tpl']->set_var('appdata',lang('Application Data')); |
||
| 224 | $GLOBALS['setup_tpl']->set_var('actions',lang('Actions')); |
||
| 225 | $GLOBALS['setup_tpl']->set_var('action_url','schematoy.php'); |
||
| 226 | $GLOBALS['setup_tpl']->set_var('app_info',lang('Application Name and Status')); |
||
| 227 | $GLOBALS['setup_tpl']->set_var('app_title',lang('Application Title')); |
||
| 228 | $GLOBALS['setup_tpl']->set_var('app_version',lang('Target Version')); |
||
| 229 | $GLOBALS['setup_tpl']->set_var('app_install',lang('Process')); |
||
| 230 | $GLOBALS['setup_tpl']->pparse('out','app_header'); |
||
| 231 | |||
| 232 | foreach($GLOBALS['setup_info'] as $key => $value) |
||
| 233 | { |
||
| 234 | unset($test); |
||
| 235 | if(file_exists(EGW_SERVER_ROOT . '/' . $value['name'] . '/setup/tables_update.inc.php')) |
||
| 236 | { |
||
| 237 | include(EGW_SERVER_ROOT . '/' . $value['name'] . '/setup/tables_update.inc.php'); |
||
| 238 | |||
| 239 | if(is_array($test)) |
||
| 240 | { |
||
| 241 | reset($test); |
||
| 242 | } |
||
| 243 | |||
| 244 | $s = '<option value=""> </option>'; |
||
| 245 | if(is_array($test)) |
||
| 246 | { |
||
| 247 | foreach($test as $versionnumber) |
||
| 248 | { |
||
| 249 | $s .= '<option value="' . $versionnumber . '">' . $versionnumber . '</option>'; |
||
| 250 | } |
||
| 251 | } |
||
| 252 | $GLOBALS['setup_tpl']->set_var('select_version',$s); |
||
| 253 | |||
| 254 | if($value['name']) |
||
| 255 | { |
||
| 256 | $i = $i ? 0 : 1; |
||
| 257 | $GLOBALS['setup_tpl']->set_var('apptitle',$value['title']); |
||
| 258 | $GLOBALS['setup_tpl']->set_var('currentver',$value['currentver']); |
||
| 259 | $GLOBALS['setup_tpl']->set_var('bg_color',$bgcolor[$i]); |
||
| 260 | |||
| 261 | $GLOBALS['setup_tpl']->set_var('instimg','completed.png'); |
||
| 262 | $GLOBALS['setup_tpl']->set_var('instalt',lang('Completed')); |
||
| 263 | $GLOBALS['setup_tpl']->set_var('install','<input type="checkbox" name="install[' . $value['name'] . ']" />'); |
||
| 264 | $status = lang('OK') . ' - ' . $value['status']; |
||
| 265 | |||
| 266 | $GLOBALS['setup_tpl']->set_var('appinfo',$value['name'] . '-' . $status); |
||
| 267 | $GLOBALS['setup_tpl']->set_var('appname',$value['name']); |
||
| 268 | |||
| 269 | $GLOBALS['setup_tpl']->pparse('out','apps',True); |
||
| 270 | } |
||
| 271 | } |
||
| 272 | } |
||
| 273 | } |
||
| 274 | $GLOBALS['setup_tpl']->set_var('submit',lang('Save')); |
||
| 275 | $GLOBALS['setup_tpl']->set_var('cancel',lang('Cancel')); |
||
| 276 | $GLOBALS['setup_tpl']->pparse('out','app_footer'); |
||
| 277 | $GLOBALS['setup_tpl']->pparse('out','footer'); |
||
| 278 | $GLOBALS['egw_setup']->html->show_footer(); |
||
| 279 | ?> |
||
| 280 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.