[763] | 1 | <?php |
---|
| 2 | /**************************************************************************\ |
---|
| 3 | * eGroupWare * |
---|
| 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 | $GLOBALS['DEBUG'] = False; |
---|
| 13 | $phpgw_info = array(); |
---|
| 14 | $GLOBALS['phpgw_info']['flags'] = array |
---|
| 15 | ( |
---|
| 16 | 'noheader' => True, |
---|
| 17 | 'nonavbar' => True, |
---|
| 18 | 'currentapp' => 'home', |
---|
| 19 | 'noapi' => True, |
---|
| 20 | 'nocachecontrol' => True |
---|
| 21 | ); |
---|
| 22 | include('./inc/functions.inc.php'); |
---|
| 23 | |
---|
| 24 | @set_time_limit(0); |
---|
| 25 | |
---|
| 26 | $tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup'); |
---|
| 27 | $setup_tpl = CreateObject('setup.Template',$tpl_root); |
---|
| 28 | $setup_tpl->set_file(array |
---|
| 29 | ( |
---|
| 30 | 'T_head' => 'head.tpl', |
---|
| 31 | 'T_footer' => 'footer.tpl', |
---|
| 32 | 'T_alert_msg' => 'msg_alert_msg.tpl', |
---|
| 33 | 'T_login_main' => 'login_main.tpl', |
---|
| 34 | 'T_login_stage_header' => 'login_stage_header.tpl', |
---|
| 35 | 'T_setup_main' => 'setup_main.tpl', |
---|
| 36 | 'T_setup_db_blocks' => 'setup_db_blocks.tpl' |
---|
| 37 | )); |
---|
| 38 | |
---|
| 39 | $setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain'); |
---|
| 40 | $setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain'); |
---|
| 41 | |
---|
| 42 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_1','V_db_stage_1'); |
---|
| 43 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_2','V_db_stage_2'); |
---|
| 44 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_3','V_db_stage_3'); |
---|
| 45 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_4','V_db_stage_4'); |
---|
| 46 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_5','V_db_stage_5'); |
---|
| 47 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_6_pre','V_db_stage_6_pre'); |
---|
| 48 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_6_post','V_db_stage_6_post'); |
---|
| 49 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_10','V_db_stage_10'); |
---|
| 50 | $setup_tpl->set_block('T_setup_db_blocks','B_db_stage_default','V_db_stage_default'); |
---|
| 51 | |
---|
| 52 | // Check header and authentication |
---|
| 53 | $GLOBALS['phpgw_info']['setup']['stage']['header'] = $GLOBALS['phpgw_setup']->detection->check_header(); |
---|
| 54 | if ($GLOBALS['phpgw_info']['setup']['stage']['header'] != '10') |
---|
| 55 | { |
---|
| 56 | if ($GLOBALS['phpgw_info']['setup']['stage']['header'] == 4) // header needs update, go there direct |
---|
| 57 | { |
---|
| 58 | Header('Location: manageheader.php'); |
---|
| 59 | } |
---|
| 60 | else // run check-install first |
---|
| 61 | { |
---|
| 62 | Header('Location: check_install.php?intro=1'); |
---|
| 63 | } |
---|
| 64 | exit; |
---|
| 65 | } |
---|
| 66 | elseif(!$GLOBALS['phpgw_setup']->auth('Config')) |
---|
| 67 | { |
---|
| 68 | $GLOBALS['phpgw_setup']->html->show_header(lang('Please login'),True); |
---|
| 69 | $GLOBALS['phpgw_setup']->html->login_form(); |
---|
| 70 | $GLOBALS['phpgw_setup']->html->show_footer(); |
---|
| 71 | exit; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | $GLOBALS['phpgw_setup']->loaddb(); |
---|
| 75 | |
---|
| 76 | /* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */ |
---|
| 77 | /* $GLOBALS['phpgw_setup']->clear_session_cache(); */ |
---|
| 78 | |
---|
| 79 | // Database actions |
---|
| 80 | $setup_info = $GLOBALS['phpgw_setup']->detection->get_versions(); |
---|
| 81 | $GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db($setup_info); |
---|
| 82 | if ($GLOBALS['phpgw_info']['setup']['stage']['db'] != 1) |
---|
| 83 | { |
---|
| 84 | $setup_info = $GLOBALS['phpgw_setup']->detection->get_versions(); |
---|
| 85 | $setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions($setup_info); |
---|
| 86 | $GLOBALS['phpgw_info']['setup']['stage']['db'] = $GLOBALS['phpgw_setup']->detection->check_db($setup_info); |
---|
| 87 | if($GLOBALS['DEBUG']) |
---|
| 88 | { |
---|
| 89 | _debug_array($setup_info); |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | if ($GLOBALS['DEBUG']) { echo 'Stage: ' . $GLOBALS['phpgw_info']['setup']['stage']['db']; } |
---|
| 94 | // begin DEBUG code |
---|
| 95 | //$GLOBALS['phpgw_info']['setup']['stage']['db'] = 0; |
---|
| 96 | //$action = 'Upgrade'; |
---|
| 97 | // end DEBUG code |
---|
| 98 | |
---|
| 99 | switch(@get_var('action',Array('POST'))) |
---|
| 100 | { |
---|
| 101 | case 'Uninstall all applications': |
---|
| 102 | $subtitle = lang('Deleting Tables'); |
---|
| 103 | $submsg = lang('Are you sure you want to delete your existing tables and data?') . '.'; |
---|
| 104 | $subaction = lang('uninstall'); |
---|
| 105 | $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'predrop'; |
---|
| 106 | $GLOBALS['phpgw_info']['setup']['stage']['db'] = 5; |
---|
| 107 | break; |
---|
| 108 | case 'Create Database': |
---|
| 109 | $subtitle = lang('Create Database'); |
---|
| 110 | $submsg = lang('At your request, this script is going to attempt to create the database and assign the db user rights to it'); |
---|
| 111 | $subaction = lang('created'); |
---|
| 112 | $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'dbcreate'; |
---|
| 113 | $GLOBALS['phpgw_info']['setup']['stage']['db'] = 6; |
---|
| 114 | break; |
---|
| 115 | case 'REALLY Uninstall all applications': |
---|
| 116 | $subtitle = lang('Deleting Tables'); |
---|
| 117 | $submsg = lang('At your request, this script is going to take the evil action of uninstalling all your apps, which deletes your existing tables and data') . '.'; |
---|
| 118 | $subaction = lang('uninstalled'); |
---|
| 119 | $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'drop'; |
---|
| 120 | $GLOBALS['phpgw_info']['setup']['stage']['db'] = 6; |
---|
| 121 | break; |
---|
| 122 | case 'Upgrade': |
---|
| 123 | $subtitle = lang('Upgrading Tables'); |
---|
| 124 | $submsg = lang('At your request, this script is going to attempt to upgrade your old applications to the current versions').'.'; |
---|
| 125 | $subaction = lang('upgraded'); |
---|
| 126 | $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
---|
| 127 | $GLOBALS['phpgw_info']['setup']['stage']['db'] = 6; |
---|
| 128 | break; |
---|
| 129 | case 'Install': |
---|
| 130 | $subtitle = lang('Creating Tables'); |
---|
| 131 | $submsg = lang('At your request, this script is going to attempt to install the core tables and the admin and preferences applications for you').'.'; |
---|
| 132 | $subaction = lang('installed'); |
---|
| 133 | $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'new'; |
---|
| 134 | $GLOBALS['phpgw_info']['setup']['stage']['db'] = 6; |
---|
| 135 | break; |
---|
| 136 | } |
---|
| 137 | $setup_tpl->set_var('subtitle',@$subtitle); |
---|
| 138 | $setup_tpl->set_var('submsg',@$submsg); |
---|
| 139 | $setup_tpl->set_var('subaction',@$subaction); |
---|
| 140 | |
---|
| 141 | // Old PHP |
---|
| 142 | if (!function_exists('version_compare'))//version_compare() is only available in PHP4.1+ |
---|
| 143 | { |
---|
| 144 | $GLOBALS['phpgw_setup']->html->show_header($GLOBALS['phpgw_info']['setup']['header_msg'],True); |
---|
| 145 | $GLOBALS['phpgw_setup']->html->show_alert_msg('Error', |
---|
| 146 | lang('You appear to be running an old version of PHP <br>It its recommend that you upgrade to a new version. <br>Older version of PHP might not run eGroupWare correctly, if at all. <br><br>Please upgrade to at least version %1','4.1')); |
---|
| 147 | $GLOBALS['phpgw_setup']->html->show_footer(); |
---|
| 148 | exit; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | // BEGIN setup page |
---|
| 152 | |
---|
| 153 | //$GLOBALS['phpgw_setup']->app_status(); |
---|
| 154 | $GLOBALS['phpgw_info']['server']['app_images'] = 'templates/default/images'; |
---|
| 155 | $incomplete = $GLOBALS['phpgw_info']['server']['app_images'] . '/incomplete.png'; |
---|
| 156 | $completed = $GLOBALS['phpgw_info']['server']['app_images'] . '/completed.png'; |
---|
| 157 | |
---|
| 158 | $setup_tpl->set_var('img_incomplete',$incomplete); |
---|
| 159 | $setup_tpl->set_var('img_completed',$completed); |
---|
| 160 | |
---|
| 161 | $setup_tpl->set_var('db_step_text',lang('Step %1 - Simple Application Management',1)); |
---|
| 162 | |
---|
| 163 | switch($GLOBALS['phpgw_info']['setup']['stage']['db']) |
---|
| 164 | { |
---|
| 165 | case 1: |
---|
| 166 | $setup_tpl->set_var('dbnotexist',lang('Your Database is not working!')); |
---|
| 167 | $setup_tpl->set_var('makesure',lang('makesure')); |
---|
| 168 | $setup_tpl->set_var('notcomplete',lang('not complete')); |
---|
| 169 | $setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly')); |
---|
| 170 | $setup_tpl->set_var('createdb',lang('Or we can attempt to create the database for you:')); |
---|
| 171 | $setup_tpl->set_var('create_database',lang('Create database')); |
---|
| 172 | $info = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_setup']->ConfigDomain]; |
---|
| 173 | switch ($info['db_type']) |
---|
| 174 | { |
---|
| 175 | case 'mysql': |
---|
| 176 | $setup_tpl->set_var('instr', |
---|
| 177 | lang("Instructions for creating the database in %1:",'MySql') |
---|
| 178 | . '<br>'.lang('Login to mysql -') |
---|
| 179 | . '<br><i>[user@server user]# mysql -u root -p</i><br>' |
---|
| 180 | . lang('Create the empty database and grant user permissions -') |
---|
| 181 | . "<br><i>mysql> create database $info[db_name];</i>" |
---|
| 182 | . "<br><i>mysql> grant all on " . $info['db_name'] |
---|
| 183 | . ".* to " . $info['db_user'] . "@localhost identified by '" . $info['db_pass'] . "';</i>"); |
---|
| 184 | break; |
---|
| 185 | case 'pgsql': |
---|
| 186 | $setup_tpl->set_var('instr', |
---|
| 187 | lang('Instructions for creating the database in %1:','PostgreSQL') |
---|
| 188 | . '<br>'.lang('Start the postmaster') |
---|
| 189 | . "<br><i>[user@server user]# postmaster -i -D /home/[username]/[dataDir]</i><br>" |
---|
| 190 | . lang('Create the empty database -') |
---|
| 191 | . "<br><i>[user@server user]# createdb " . $info['db_name'] . "</i>"); |
---|
| 192 | break; |
---|
| 193 | default: |
---|
| 194 | $setup_tpl->set_var('instr',''); |
---|
| 195 | } |
---|
| 196 | $setup_tpl->parse('V_db_stage_1','B_db_stage_1'); |
---|
| 197 | $db_filled_block = $setup_tpl->get_var('V_db_stage_1'); |
---|
| 198 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 199 | break; |
---|
| 200 | case 2: |
---|
| 201 | $setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br>These versions are no longer supported, and there is no upgrade path for them in setup.<br> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br>and then upgrade from there with the current version.')); |
---|
| 202 | $setup_tpl->set_var('notcomplete',lang('not complete')); |
---|
| 203 | $setup_tpl->parse('V_db_stage_2','B_db_stage_2'); |
---|
| 204 | $db_filled_block = $setup_tpl->get_var('V_db_stage_2'); |
---|
| 205 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 206 | break; |
---|
| 207 | case 3: |
---|
| 208 | $setup_tpl->set_var('dbexists',lang('Your database is working, but you dont have any applications installed')); |
---|
| 209 | $setup_tpl->set_var('install',lang('Install')); |
---|
| 210 | $setup_tpl->set_var('proceed',lang('We can proceed')); |
---|
| 211 | $setup_tpl->set_var('coreapps',lang('all applications')); |
---|
| 212 | $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
---|
| 213 | $setup_tpl->parse('V_db_stage_3','B_db_stage_3'); |
---|
| 214 | $db_filled_block = $setup_tpl->get_var('V_db_stage_3'); |
---|
| 215 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 216 | break; |
---|
| 217 | case 4: |
---|
| 218 | $setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',$setup_info['phpgwapi']['currentver'])); |
---|
| 219 | $setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['phpgwapi']['version'])); |
---|
| 220 | $setup_tpl->set_var('backupwarn',lang('backupwarn')); |
---|
| 221 | $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
---|
| 222 | $setup_tpl->set_var('upgrade',lang('Upgrade')); |
---|
| 223 | $setup_tpl->set_var('goto',lang('Go to')); |
---|
| 224 | $setup_tpl->set_var('configuration',lang('configuration')); |
---|
| 225 | $setup_tpl->set_var('admin_account',lang('Create admin account')); |
---|
| 226 | $setup_tpl->set_var('applications',lang('Manage Applications')); |
---|
| 227 | $setup_tpl->set_var('language_management',lang('Manage Languages')); |
---|
| 228 | $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
---|
| 229 | $setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data')); |
---|
| 230 | $setup_tpl->set_var('dropwarn',lang('Your tables may be altered and you may lose data')); |
---|
| 231 | |
---|
| 232 | $setup_tpl->parse('V_db_stage_4','B_db_stage_4'); |
---|
| 233 | $db_filled_block = $setup_tpl->get_var('V_db_stage_4'); |
---|
| 234 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 235 | break; |
---|
| 236 | case 5: |
---|
| 237 | $setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?')); |
---|
| 238 | $setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications')); |
---|
| 239 | $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
---|
| 240 | $setup_tpl->set_var('cancel',lang('cancel')); |
---|
| 241 | $setup_tpl->parse('V_db_stage_5','B_db_stage_5'); |
---|
| 242 | $db_filled_block = $setup_tpl->get_var('V_db_stage_5'); |
---|
| 243 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 244 | break; |
---|
| 245 | case 6: |
---|
| 246 | $setup_tpl->set_var('status',lang('Status')); |
---|
| 247 | $setup_tpl->set_var('notcomplete',lang('not complete')); |
---|
| 248 | $setup_tpl->set_var('tblchange',lang('Table Change Messages')); |
---|
| 249 | $setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre'); |
---|
| 250 | $db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre'); |
---|
| 251 | |
---|
| 252 | // FIXME : CAPTURE THIS OUTPUT |
---|
| 253 | $GLOBALS['phpgw_setup']->db->Halt_On_Error = 'report'; |
---|
| 254 | |
---|
| 255 | switch ($GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi']) |
---|
| 256 | { |
---|
| 257 | case 'dbcreate': |
---|
| 258 | $GLOBALS['phpgw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass']); |
---|
| 259 | break; |
---|
| 260 | case 'drop': |
---|
| 261 | $setup_info = $GLOBALS['phpgw_setup']->detection->get_versions($setup_info); |
---|
| 262 | $setup_info = $GLOBALS['phpgw_setup']->process->droptables($setup_info); |
---|
| 263 | break; |
---|
| 264 | case 'new': |
---|
| 265 | /* process all apps and langs(last param True), excluding apps with the no_mass_update flag set. */ |
---|
| 266 | $setup_info = $GLOBALS['phpgw_setup']->detection->upgrade_exclude($setup_info); |
---|
| 267 | $setup_info = $GLOBALS['phpgw_setup']->process->pass($setup_info,'new',$_REQUEST['debug'],True); |
---|
| 268 | $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
---|
| 269 | break; |
---|
| 270 | case 'oldversion': |
---|
| 271 | $setup_info = $GLOBALS['phpgw_setup']->process->pass($setup_info,'upgrade',$_REQUEST['debug']); |
---|
| 272 | $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
---|
| 273 | break; |
---|
| 274 | } |
---|
| 275 | |
---|
| 276 | $GLOBALS['phpgw_setup']->db->Halt_On_Error = 'no'; |
---|
| 277 | |
---|
| 278 | $setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been')); |
---|
| 279 | $setup_tpl->set_var('re-check_my_installation',lang('Re-Check My Installation')); |
---|
| 280 | $setup_tpl->parse('V_db_stage_6_post','B_db_stage_6_post'); |
---|
| 281 | $db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post'); |
---|
| 282 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 283 | break; |
---|
| 284 | case 10: |
---|
| 285 | $setup_tpl->set_var('tablescurrent',lang('Your applications are current')); |
---|
| 286 | $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
---|
| 287 | $setup_tpl->set_var('insanity',lang('Insanity')); |
---|
| 288 | $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
---|
| 289 | $setup_tpl->set_var('deletetables',lang('Uninstall all applications')); |
---|
| 290 | $setup_tpl->parse('V_db_stage_10','B_db_stage_10'); |
---|
| 291 | $db_filled_block = $setup_tpl->get_var('V_db_stage_10'); |
---|
| 292 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 293 | break; |
---|
| 294 | default: |
---|
| 295 | $setup_tpl->set_var('dbnotexist',lang('Your database does not exist')); |
---|
| 296 | $setup_tpl->parse('V_db_stage_default','B_db_stage_default'); |
---|
| 297 | $db_filled_block = $setup_tpl->get_var('V_db_stage_default'); |
---|
| 298 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
---|
| 299 | break; |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | // Config Section |
---|
| 303 | $setup_tpl->set_var('config_step_text',lang('Step %1 - Configuration',2)); |
---|
| 304 | $GLOBALS['phpgw_info']['setup']['stage']['config'] = $GLOBALS['phpgw_setup']->detection->check_config(); |
---|
| 305 | |
---|
| 306 | // begin DEBUG code |
---|
| 307 | //$GLOBALS['phpgw_info']['setup']['stage']['config'] = 10; |
---|
| 308 | // end DEBUG code |
---|
| 309 | |
---|
| 310 | switch($GLOBALS['phpgw_info']['setup']['stage']['config']) |
---|
| 311 | { |
---|
| 312 | case 1: |
---|
| 313 | $setup_tpl->set_var('config_status_img',$incomplete); |
---|
| 314 | $setup_tpl->set_var('config_status_alt',lang('not completed')); |
---|
| 315 | $btn_config_now = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple( |
---|
| 316 | lang('Please configure eGroupWare for your environment'), |
---|
| 317 | 'POST','config.php', |
---|
| 318 | 'submit',lang('Configure Now'), |
---|
| 319 | ''); |
---|
| 320 | $setup_tpl->set_var('config_table_data',$btn_config_now); |
---|
| 321 | $setup_tpl->set_var('ldap_table_data',' '); |
---|
| 322 | break; |
---|
| 323 | case 10: |
---|
| 324 | $setup_tpl->set_var('config_status_img',$completed); |
---|
| 325 | $setup_tpl->set_var('config_status_alt',lang('completed')); |
---|
| 326 | $btn_edit_config = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple( |
---|
| 327 | lang('Configuration completed'), |
---|
| 328 | 'POST','config.php', |
---|
| 329 | 'submit',lang('Edit Current Configuration'), |
---|
| 330 | '' |
---|
| 331 | ); |
---|
| 332 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type' and config_app='phpgwapi'"); |
---|
| 333 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 334 | if ($GLOBALS['phpgw_setup']->db->f(0) == 'ldap') |
---|
| 335 | { |
---|
| 336 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host' and config_app='phpgwapi'"); |
---|
| 337 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 338 | if ($GLOBALS['phpgw_setup']->db->f(0) != '') |
---|
| 339 | { |
---|
| 340 | $btn_config_ldap = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple( |
---|
| 341 | lang('LDAP account import/export'), |
---|
| 342 | 'POST','ldap.php', |
---|
| 343 | 'submit',lang('Configure Now'), |
---|
| 344 | '' |
---|
| 345 | ); |
---|
| 346 | } |
---|
| 347 | else |
---|
| 348 | { |
---|
| 349 | $btn_config_ldap = ''; |
---|
| 350 | } |
---|
| 351 | /* |
---|
| 352 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='webserver_url'"); |
---|
| 353 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 354 | if ($GLOBALS['phpgw_setup']->db->f(0)) |
---|
| 355 | { |
---|
| 356 | $link_make_accts = $GLOBALS['phpgw_setup']->html->make_href_link_simple( |
---|
| 357 | '<br>', |
---|
| 358 | 'setup_demo.php', |
---|
| 359 | lang('Click Here'), |
---|
| 360 | '<b>'.lang('to setup 1 admin account and 3 demo accounts.').'</b>' |
---|
| 361 | ); |
---|
| 362 | } |
---|
| 363 | else |
---|
| 364 | { |
---|
| 365 | $link_make_accts = ' '; |
---|
| 366 | } |
---|
| 367 | } |
---|
| 368 | else |
---|
| 369 | { |
---|
| 370 | $btn_config_ldap = ''; |
---|
| 371 | $link_make_accts = $GLOBALS['phpgw_setup']->html->make_href_link_simple( |
---|
| 372 | '<br>', |
---|
| 373 | 'setup_demo.php', |
---|
| 374 | lang('Click Here'), |
---|
| 375 | '<b>'.lang('to setup 1 admin account and 3 demo accounts.').'</b>' |
---|
| 376 | ); |
---|
| 377 | } |
---|
| 378 | $config_td = "$btn_edit_config"."$link_make_accts"; |
---|
| 379 | */ |
---|
| 380 | } |
---|
| 381 | $setup_tpl->set_var('config_table_data',$btn_edit_config); |
---|
| 382 | $setup_tpl->set_var('ldap_table_data',$btn_config_ldap); |
---|
| 383 | break; |
---|
| 384 | default: |
---|
| 385 | $setup_tpl->set_var('config_status_img',$incomplete); |
---|
| 386 | $setup_tpl->set_var('config_status_alt',lang('not completed')); |
---|
| 387 | $setup_tpl->set_var('config_table_data',lang('Not ready for this stage yet')); |
---|
| 388 | $setup_tpl->set_var('ldap_table_data',' '); |
---|
| 389 | break; |
---|
| 390 | } |
---|
| 391 | // Admin Account Section |
---|
| 392 | $setup_tpl->set_var('admin_step_text',lang('Step %1 - Admin Account',3)); |
---|
| 393 | switch($GLOBALS['phpgw_info']['setup']['stage']['config']) |
---|
| 394 | { |
---|
| 395 | case 10: |
---|
| 396 | // check if there is already a user account (not the anonymous account of sitemgr or a group) |
---|
| 397 | // Note: this does not check the availiblitly of accounts via other auth-methods then sql and ldap!! |
---|
| 398 | |
---|
| 399 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type' and config_app='phpgwapi'"); |
---|
| 400 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 401 | if ($GLOBALS['phpgw_setup']->db->f(0) == 'ldap') |
---|
| 402 | { |
---|
| 403 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host' and config_app='phpgwapi'"); |
---|
| 404 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 405 | $ldap_host = $GLOBALS['phpgw_setup']->db->f(0); |
---|
| 406 | |
---|
| 407 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_context' and config_app='phpgwapi'"); |
---|
| 408 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 409 | $ldap_context = $GLOBALS['phpgw_setup']->db->f(0); |
---|
| 410 | |
---|
| 411 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_root_dn' and config_app='phpgwapi'"); |
---|
| 412 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 413 | $ldap_root_dn = $GLOBALS['phpgw_setup']->db->f(0); |
---|
| 414 | |
---|
| 415 | $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_root_pw' and config_app='phpgwapi'"); |
---|
| 416 | $GLOBALS['phpgw_setup']->db->next_record(); |
---|
| 417 | $ldap_root_pw = $GLOBALS['phpgw_setup']->db->f(0); |
---|
| 418 | |
---|
| 419 | $ldap_connection = ldap_connect($ldap_host); |
---|
| 420 | ldap_set_option($ldap_connection,LDAP_OPT_PROTOCOL_VERSION,3); |
---|
| 421 | ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0); |
---|
| 422 | $ldap_bind = ldap_bind($ldap_connection, $ldap_root_dn, $ldap_root_pw); |
---|
| 423 | |
---|
| 424 | $filter="(&(phpgwaccounttype=u)(uid=expresso-admin))"; |
---|
| 425 | $justthese = array("uidnumber"); |
---|
| 426 | $sr=ldap_search($ldap_connection, $ldap_context, $filter, $justthese); |
---|
| 427 | $info = ldap_get_entries($ldap_connection, $sr); |
---|
| 428 | $no_accounts = !$info['count']; |
---|
| 429 | } |
---|
| 430 | else |
---|
| 431 | { |
---|
| 432 | $GLOBALS['phpgw_setup']->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u' AND account_lid!='anonymous'",__LINE__,__FILE__); |
---|
| 433 | $no_accounts = !$GLOBALS['phpgw_setup']->db->next_record() || !$GLOBALS['phpgw_setup']->db->f(0); |
---|
| 434 | } |
---|
| 435 | $setup_tpl->set_var('admin_status_img',$no_accounts ? $incomplete : $completed); |
---|
| 436 | $setup_tpl->set_var('admin_status_alt',$no_accounts ? lang('not completed') : lang('completed')); |
---|
| 437 | $setup_tpl->set_var('admin_table_data',$GLOBALS['phpgw_setup']->html->make_frm_btn_simple( |
---|
| 438 | $no_accounts ? 'Nenhuma conta <font color=red>expresso-admin</font> existe no ldap.' : 'A conta expresso-admin já existe.', |
---|
| 439 | 'POST','setup_demo.php', |
---|
| 440 | 'submit',lang('Create admin account'), |
---|
| 441 | '')); |
---|
| 442 | break; |
---|
| 443 | default: |
---|
| 444 | $setup_tpl->set_var('admin_status_img',$incomplete); |
---|
| 445 | $setup_tpl->set_var('admin_status_alt',lang('not completed')); |
---|
| 446 | $setup_tpl->set_var('admin_table_data',lang('Not ready for this stage yet')); |
---|
| 447 | break; |
---|
| 448 | } |
---|
| 449 | |
---|
| 450 | // Lang Section |
---|
| 451 | $setup_tpl->set_var('lang_step_text',lang('Step %1 - Language Management',4)); |
---|
| 452 | $GLOBALS['phpgw_info']['setup']['stage']['lang'] = $GLOBALS['phpgw_setup']->detection->check_lang(); |
---|
| 453 | |
---|
| 454 | // begin DEBUG code |
---|
| 455 | //$GLOBALS['phpgw_info']['setup']['stage']['lang'] = 0; |
---|
| 456 | // end DEBUG code |
---|
| 457 | |
---|
| 458 | switch($GLOBALS['phpgw_info']['setup']['stage']['lang']) |
---|
| 459 | { |
---|
| 460 | case 1: |
---|
| 461 | $setup_tpl->set_var('lang_status_img',$incomplete); |
---|
| 462 | $setup_tpl->set_var('lang_status_alt','not completed'); |
---|
| 463 | $btn_install_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple( |
---|
| 464 | lang('You do not have any languages installed. Please install one now <br>'), |
---|
| 465 | 'POST','lang.php', |
---|
| 466 | 'submit',lang('Install Language'), |
---|
| 467 | ''); |
---|
| 468 | $setup_tpl->set_var('lang_table_data',$btn_install_lang); |
---|
| 469 | break; |
---|
| 470 | case 10: |
---|
| 471 | $langs_list = array(); |
---|
| 472 | $languages = get_langs(); |
---|
| 473 | foreach ($GLOBALS['phpgw_info']['setup']['installed_langs'] as $key => $value) |
---|
| 474 | { |
---|
| 475 | $langs_list[] = isset($languages[$key]) ? $languages[$key]['descr'] : $value; |
---|
| 476 | } |
---|
| 477 | $setup_tpl->set_var('lang_status_img',$completed); |
---|
| 478 | $setup_tpl->set_var('lang_status_alt','completed'); |
---|
| 479 | $btn_manage_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple( |
---|
| 480 | lang('This stage is completed<br>') . lang('Currently installed languages: %1 <br>',implode(', ',$langs_list)), |
---|
| 481 | 'POST','lang.php', |
---|
| 482 | 'submit',lang('Manage Languages'), |
---|
| 483 | ''); |
---|
| 484 | // show system-charset and offer conversation |
---|
| 485 | include_once(PHPGW_API_INC.'/class.translation_sql.inc.php'); |
---|
| 486 | $translation = new translation; |
---|
| 487 | $btn_manage_lang .= lang('Current system-charset is %1, click %2here%3 to change it.', |
---|
| 488 | $translation->system_charset ? "'$translation->system_charset'" : lang('not set'), |
---|
| 489 | '<a href="system_charset.php">','</a>'); |
---|
| 490 | $setup_tpl->set_var('lang_table_data',$btn_manage_lang); |
---|
| 491 | break; |
---|
| 492 | default: |
---|
| 493 | $setup_tpl->set_var('lang_status_img',$incomplete); |
---|
| 494 | $setup_tpl->set_var('lang_status_alt',lang('not completed')); |
---|
| 495 | $setup_tpl->set_var('lang_table_data',lang('Not ready for this stage yet')); |
---|
| 496 | break; |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | $setup_tpl->set_var('apps_step_text',lang('Step %1 - Advanced Application Management',5)); |
---|
| 500 | // $GLOBALS['phpgw_info']['setup']['stage']['apps'] = $GLOBALS['phpgw_setup']->check_apps(); |
---|
| 501 | switch($GLOBALS['phpgw_info']['setup']['stage']['db']) |
---|
| 502 | { |
---|
| 503 | case 10: |
---|
| 504 | $setup_tpl->set_var('apps_status_img',$completed); |
---|
| 505 | $setup_tpl->set_var('apps_status_alt',lang('completed')); |
---|
| 506 | // check if we have apps to upgrade |
---|
| 507 | $to_upgrade = array(); |
---|
| 508 | foreach($setup_info as $app => $data) |
---|
| 509 | { |
---|
| 510 | if ($data['currentver'] && $data['version'] && $data['version'] != $data['currentver']) |
---|
| 511 | { |
---|
| 512 | $to_upgrade[] = $app; |
---|
| 513 | } |
---|
| 514 | } |
---|
| 515 | $btn_manage_apps = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple( |
---|
| 516 | count($to_upgrade) ? '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade) : |
---|
| 517 | lang('This stage is completed<br>'), |
---|
| 518 | '','applications.php', |
---|
| 519 | 'submit',lang('Manage Applications'), |
---|
| 520 | ''); |
---|
| 521 | $setup_tpl->set_var('apps_table_data',$btn_manage_apps); |
---|
| 522 | break; |
---|
| 523 | default: |
---|
| 524 | $setup_tpl->set_var('apps_status_img',$incomplete); |
---|
| 525 | $setup_tpl->set_var('apps_status_alt',lang('not completed')); |
---|
| 526 | $setup_tpl->set_var('apps_table_data',lang('Not ready for this stage yet')); |
---|
| 527 | break; |
---|
| 528 | } |
---|
| 529 | |
---|
| 530 | $GLOBALS['phpgw_setup']->html->show_header( |
---|
| 531 | $GLOBALS['phpgw_info']['setup']['header_msg'], |
---|
| 532 | False, |
---|
| 533 | 'config', |
---|
| 534 | $GLOBALS['phpgw_setup']->ConfigDomain . '(' . $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_setup']->ConfigDomain]['db_type'] . ')' |
---|
| 535 | ); |
---|
| 536 | $setup_tpl->pparse('out','T_setup_main'); |
---|
| 537 | $GLOBALS['phpgw_setup']->html->show_footer(); |
---|
| 538 | ?> |
---|