source: trunk/setup/index.php @ 3627

Revision 3627, 24.4 KB checked in by amuller, 13 years ago (diff)

Ticket #427 - Resolvendo problemas de instalação sem o dump

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
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                        /* Hack to fix database inconsistency */
284                        $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_access_log ADD COLUMN browser varchar(200);");
285                        $GLOBALS['phpgw_setup']->db->query("CREATE TABLE phpgw_async (
286                                id character varying(255) NOT NULL,
287                                next integer NOT NULL,
288                                times character varying(255) NOT NULL,
289                                method character varying(80) NOT NULL,
290                                data text NOT NULL,
291                                account_id integer DEFAULT 0 NOT NULL);");     
292
293                        break;
294                case 10:
295                        $setup_tpl->set_var('tablescurrent',lang('Your applications are current'));
296                        $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications'));
297                        $setup_tpl->set_var('insanity',lang('Insanity'));
298                        $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
299                        $setup_tpl->set_var('deletetables',lang('Uninstall all applications'));
300                        $setup_tpl->parse('V_db_stage_10','B_db_stage_10');
301                        $db_filled_block = $setup_tpl->get_var('V_db_stage_10');
302                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
303                        break;
304                default:
305                        $setup_tpl->set_var('dbnotexist',lang('Your database does not exist'));
306                        $setup_tpl->parse('V_db_stage_default','B_db_stage_default');
307                        $db_filled_block = $setup_tpl->get_var('V_db_stage_default');
308                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
309                        break;
310        }
311
312        // Config Section
313        $setup_tpl->set_var('config_step_text',lang('Step %1 - Configuration',2));
314        $GLOBALS['phpgw_info']['setup']['stage']['config'] = $GLOBALS['phpgw_setup']->detection->check_config();
315
316        // begin DEBUG code
317        //$GLOBALS['phpgw_info']['setup']['stage']['config'] = 10;
318        // end DEBUG code
319
320        switch($GLOBALS['phpgw_info']['setup']['stage']['config'])
321        {
322                case 1:
323                        $setup_tpl->set_var('config_status_img',$incomplete);
324                        $setup_tpl->set_var('config_status_alt',lang('not completed'));
325                        $btn_config_now = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
326                                lang('Please configure eGroupWare for your environment'),
327                                'POST','config.php',
328                                'submit',lang('Configure Now'),
329                                '');
330                        $setup_tpl->set_var('config_table_data',$btn_config_now);
331                        $setup_tpl->set_var('ldap_table_data','&nbsp;');
332                        break;
333                case 10:
334                        $setup_tpl->set_var('config_status_img',$completed);
335                        $setup_tpl->set_var('config_status_alt',lang('completed'));
336                        $btn_edit_config = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
337                                lang('Configuration completed'),
338                                'POST','config.php',
339                                'submit',lang('Edit Current Configuration'),
340                                ''
341                        );
342                        $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type' and config_app='phpgwapi'");
343                        $GLOBALS['phpgw_setup']->db->next_record();
344                        if ($GLOBALS['phpgw_setup']->db->f(0) == 'ldap')
345                        {
346                                $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host' and config_app='phpgwapi'");
347                                $GLOBALS['phpgw_setup']->db->next_record();
348                                if ($GLOBALS['phpgw_setup']->db->f(0) != '')
349                                {
350                                        $btn_config_ldap = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
351                                                lang('LDAP account import/export'),
352                                                'POST','ldap.php',
353                                                'submit',lang('Configure Now'),
354                                                ''
355                                        );
356                                }
357                                else
358                                {
359                                        $btn_config_ldap = '';
360                                }
361/*
362                                $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='webserver_url'");
363                                $GLOBALS['phpgw_setup']->db->next_record();
364                                if ($GLOBALS['phpgw_setup']->db->f(0))
365                                {
366                                        $link_make_accts = $GLOBALS['phpgw_setup']->html->make_href_link_simple(
367                                                '<br>',
368                                                'setup_demo.php',
369                                                lang('Click Here'),
370                                                '<b>'.lang('to setup 1 admin account and 3 demo accounts.').'</b>'
371                                        );
372                                }
373                                else
374                                {
375                                        $link_make_accts = '&nbsp;';
376                                }
377                        }
378                        else
379                        {
380                                $btn_config_ldap = '';
381                                $link_make_accts = $GLOBALS['phpgw_setup']->html->make_href_link_simple(
382                                        '<br>',
383                                        'setup_demo.php',
384                                        lang('Click Here'),
385                                        '<b>'.lang('to setup 1 admin account and 3 demo accounts.').'</b>'
386                                );
387                        }
388                        $config_td = "$btn_edit_config"."$link_make_accts";
389*/
390                        }
391                        $setup_tpl->set_var('config_table_data',$btn_edit_config);
392                        $setup_tpl->set_var('ldap_table_data',$btn_config_ldap);
393                        break;
394                default:
395                        $setup_tpl->set_var('config_status_img',$incomplete);
396                        $setup_tpl->set_var('config_status_alt',lang('not completed'));
397                        $setup_tpl->set_var('config_table_data',lang('Not ready for this stage yet'));
398                        $setup_tpl->set_var('ldap_table_data','&nbsp;');
399                        break;
400        }
401        // Admin Account Section
402        $setup_tpl->set_var('admin_step_text',lang('Step %1 - Admin Account',3));
403        switch($GLOBALS['phpgw_info']['setup']['stage']['config'])
404        {
405                case 10:
406                        // check if there is already a user account (not the anonymous account of sitemgr or a group)
407                        // Note: this does not check the availiblitly of accounts via other auth-methods then sql and ldap!!
408
409                        $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type' and config_app='phpgwapi'");
410                        $GLOBALS['phpgw_setup']->db->next_record();
411                        if ($GLOBALS['phpgw_setup']->db->f(0) == 'ldap')
412                        {
413                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host' and config_app='phpgwapi'");
414                          $GLOBALS['phpgw_setup']->db->next_record();
415                          $ldap_host = $GLOBALS['phpgw_setup']->db->f(0);
416                         
417                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_context' and config_app='phpgwapi'");
418                          $GLOBALS['phpgw_setup']->db->next_record();
419                          $ldap_context = $GLOBALS['phpgw_setup']->db->f(0);
420
421                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_root_dn' and config_app='phpgwapi'");
422                          $GLOBALS['phpgw_setup']->db->next_record();
423                          $ldap_root_dn = $GLOBALS['phpgw_setup']->db->f(0);
424
425                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_root_pw' and config_app='phpgwapi'");
426                          $GLOBALS['phpgw_setup']->db->next_record();
427                          $ldap_root_pw = $GLOBALS['phpgw_setup']->db->f(0);
428                         
429                          $ldap_connection = ldap_connect($ldap_host);                   
430                          ldap_set_option($ldap_connection,LDAP_OPT_PROTOCOL_VERSION,3);
431                          ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
432                          $ldap_bind = ldap_bind($ldap_connection, $ldap_root_dn, $ldap_root_pw);
433
434                          $filter="(&(phpgwaccounttype=u)(uid=expresso-admin))";
435                          $justthese = array("uidnumber");
436                          $sr=ldap_search($ldap_connection, $ldap_context, $filter, $justthese);
437                          $info = ldap_get_entries($ldap_connection, $sr);
438                          $no_accounts = !$info['count'];
439                        }
440                        else
441                        {
442                                $GLOBALS['phpgw_setup']->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u' AND account_lid!='anonymous'",__LINE__,__FILE__);
443                                $no_accounts = !$GLOBALS['phpgw_setup']->db->next_record() || !$GLOBALS['phpgw_setup']->db->f(0);
444                        }
445                        $setup_tpl->set_var('admin_status_img',$no_accounts ? $incomplete : $completed);
446                        $setup_tpl->set_var('admin_status_alt',$no_accounts ? lang('not completed') : lang('completed'));
447                        $setup_tpl->set_var('admin_table_data',$GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
448                        $no_accounts ? 'Nenhuma conta <font color=red>expresso-admin</font> existe no ldap.' : 'A conta expresso-admin já existe.',
449                                            'POST','setup_demo.php',
450                                            'submit',lang('Create admin account'),
451                                            ''));
452                        break;
453                default:
454                        $setup_tpl->set_var('admin_status_img',$incomplete);
455                        $setup_tpl->set_var('admin_status_alt',lang('not completed'));
456                        $setup_tpl->set_var('admin_table_data',lang('Not ready for this stage yet'));
457                        break;
458        }
459
460        // Lang Section
461        $setup_tpl->set_var('lang_step_text',lang('Step %1 - Language Management',4));
462        $GLOBALS['phpgw_info']['setup']['stage']['lang'] = $GLOBALS['phpgw_setup']->detection->check_lang();
463
464        // begin DEBUG code
465        //$GLOBALS['phpgw_info']['setup']['stage']['lang'] = 0;
466        // end DEBUG code
467
468        switch($GLOBALS['phpgw_info']['setup']['stage']['lang'])
469        {
470                case 1:
471                        $setup_tpl->set_var('lang_status_img',$incomplete);
472                        $setup_tpl->set_var('lang_status_alt','not completed');
473                        $btn_install_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
474                                lang('You do not have any languages installed. Please install one now <br>'),
475                                'POST','lang.php',
476                                'submit',lang('Install Language'),
477                                '');
478                        $setup_tpl->set_var('lang_table_data',$btn_install_lang);
479                        break;
480                case 10:
481                        $langs_list = array();
482                        $languages = get_langs();
483                        foreach ($GLOBALS['phpgw_info']['setup']['installed_langs'] as $key => $value)
484                        {
485                                $langs_list[] = isset($languages[$key]) ? $languages[$key]['descr'] : $value;
486                        }
487                        $setup_tpl->set_var('lang_status_img',$completed);
488                        $setup_tpl->set_var('lang_status_alt','completed');
489                        $btn_manage_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
490                                lang('This stage is completed<br>') . lang('Currently installed languages: %1 <br>',implode(', ',$langs_list)),
491                                'POST','lang.php',
492                                'submit',lang('Manage Languages'),
493                                '');
494                        // show system-charset and offer conversation
495                        include_once(PHPGW_API_INC.'/class.translation_sql.inc.php');
496                        $translation = new translation;
497                        $btn_manage_lang .= lang('Current system-charset is %1, click %2here%3 to change it.',
498                                $translation->system_charset ? "'$translation->system_charset'" : lang('not set'),
499                                '<a href="system_charset.php">','</a>');
500                        $setup_tpl->set_var('lang_table_data',$btn_manage_lang);
501                        break;
502                default:
503                        $setup_tpl->set_var('lang_status_img',$incomplete);
504                        $setup_tpl->set_var('lang_status_alt',lang('not completed'));
505                        $setup_tpl->set_var('lang_table_data',lang('Not ready for this stage yet'));
506                        break;
507        }
508
509        $setup_tpl->set_var('apps_step_text',lang('Step %1 - Advanced Application Management',5));
510//      $GLOBALS['phpgw_info']['setup']['stage']['apps'] = $GLOBALS['phpgw_setup']->check_apps();
511        switch($GLOBALS['phpgw_info']['setup']['stage']['db'])
512        {
513                case 10:
514                        $setup_tpl->set_var('apps_status_img',$completed);
515                        $setup_tpl->set_var('apps_status_alt',lang('completed'));
516                        // check if we have apps to upgrade
517                        $to_upgrade = array();
518                        foreach($setup_info as $app => $data)
519                        {
520                                if ($data['currentver'] && $data['version'] && $data['version'] != $data['currentver'])
521                                {
522                                        $to_upgrade[] = $app;
523                                }
524                        }
525                        $btn_manage_apps = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
526                                count($to_upgrade) ? '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade) :
527                                lang('This stage is completed<br>'),
528                                '','applications.php',
529                                'submit',lang('Manage Applications'),
530                                '');
531                        $setup_tpl->set_var('apps_table_data',$btn_manage_apps);
532                        break;
533                default:
534                        $setup_tpl->set_var('apps_status_img',$incomplete);
535                        $setup_tpl->set_var('apps_status_alt',lang('not completed'));
536                        $setup_tpl->set_var('apps_table_data',lang('Not ready for this stage yet'));
537                        break;
538        }
539
540        $GLOBALS['phpgw_setup']->html->show_header(
541                $GLOBALS['phpgw_info']['setup']['header_msg'],
542                False,
543                'config',
544                $GLOBALS['phpgw_setup']->ConfigDomain . '(' . $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_setup']->ConfigDomain]['db_type'] . ')'
545        );
546        $setup_tpl->pparse('out','T_setup_main');
547        $GLOBALS['phpgw_setup']->html->show_footer();
548?>
Note: See TracBrowser for help on using the repository browser.