source: branches/2.3/setup/index.php @ 3653

Revision 3653, 24.5 KB checked in by rodsouza, 13 years ago (diff)

Ticket #707 - Adicionando usuario/senha da base postgres no momento da instalacao

  • 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
173                        $info = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_setup']->ConfigDomain];
174
175                        $setup_tpl->set_var('db_root', $info[ 'db_user' ] );
176                        $setup_tpl->set_var('db_pass', $info[ 'db_pass' ] );
177
178                        switch ($info['db_type'])
179                        {
180                                case 'mysql':
181                                        $setup_tpl->set_var('instr',
182                                                lang("Instructions for creating the database in %1:",'MySql')
183                                                . '<br>'.lang('Login to mysql -')
184                                                . '<br><i>[user@server user]# mysql -u root -p</i><br>'
185                                                . lang('Create the empty database and grant user permissions -')
186                                                . "<br><i>mysql> create database $info[db_name];</i>"
187                                                . "<br><i>mysql> grant all on " . $info['db_name']
188                                                . ".* to " . $info['db_user'] . "@localhost identified by '" . $info['db_pass'] . "';</i>");
189                                        break;
190                                case 'pgsql':
191                                        $setup_tpl->set_var('instr',
192                                                lang('Instructions for creating the database in %1:','PostgreSQL')
193                                                . '<br>'.lang('Start the postmaster')
194                                                . "<br><i>[user@server user]# postmaster -i -D /home/[username]/[dataDir]</i><br>"
195                                                . lang('Create the empty database -')
196                                                . "<br><i>[user@server user]# createdb " . $info['db_name'] . "</i>");
197                                        break;
198                                default:
199                                        $setup_tpl->set_var('instr','');
200                        }
201                        $setup_tpl->parse('V_db_stage_1','B_db_stage_1');
202                        $db_filled_block = $setup_tpl->get_var('V_db_stage_1');
203                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
204                        break;
205                case 2:
206                        $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.'));
207                        $setup_tpl->set_var('notcomplete',lang('not complete'));
208                        $setup_tpl->parse('V_db_stage_2','B_db_stage_2');
209                        $db_filled_block = $setup_tpl->get_var('V_db_stage_2');
210                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
211                        break;
212                case 3:
213                        $setup_tpl->set_var('dbexists',lang('Your database is working, but you dont have any applications installed'));
214                        $setup_tpl->set_var('install',lang('Install'));
215                        $setup_tpl->set_var('proceed',lang('We can proceed'));
216                        $setup_tpl->set_var('coreapps',lang('all applications'));
217                        $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
218                        $setup_tpl->parse('V_db_stage_3','B_db_stage_3');
219                        $db_filled_block = $setup_tpl->get_var('V_db_stage_3');
220                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
221                        break;
222                case 4:
223                        $setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',$setup_info['phpgwapi']['currentver']));
224                        $setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['phpgwapi']['version']));
225                        $setup_tpl->set_var('backupwarn',lang('backupwarn'));
226                        $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages'));
227                        $setup_tpl->set_var('upgrade',lang('Upgrade'));
228                        $setup_tpl->set_var('goto',lang('Go to'));
229                        $setup_tpl->set_var('configuration',lang('configuration'));
230                        $setup_tpl->set_var('admin_account',lang('Create admin account'));
231                        $setup_tpl->set_var('applications',lang('Manage Applications'));
232                        $setup_tpl->set_var('language_management',lang('Manage Languages'));
233                        $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications'));
234                        $setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data'));
235                        $setup_tpl->set_var('dropwarn',lang('Your tables may be altered and you may lose data'));
236
237                        $setup_tpl->parse('V_db_stage_4','B_db_stage_4');
238                        $db_filled_block = $setup_tpl->get_var('V_db_stage_4');
239                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
240                        break;
241                case 5:
242                        $setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?'));
243                        $setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications'));
244                        $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
245                        $setup_tpl->set_var('cancel',lang('cancel'));
246                        $setup_tpl->parse('V_db_stage_5','B_db_stage_5');
247                        $db_filled_block = $setup_tpl->get_var('V_db_stage_5');
248                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
249                        break;
250                case 6:
251                        $setup_tpl->set_var('status',lang('Status'));
252                        $setup_tpl->set_var('notcomplete',lang('not complete'));
253                        $setup_tpl->set_var('tblchange',lang('Table Change Messages'));
254                        $setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre');
255                        $db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre');
256
257                        // FIXME : CAPTURE THIS OUTPUT
258                        $GLOBALS['phpgw_setup']->db->Halt_On_Error = 'report';
259
260                        switch ($GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'])
261                        {
262                                case 'dbcreate':
263                                        $GLOBALS['phpgw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass']);
264                                        break;
265                                case 'drop':
266                                        $setup_info = $GLOBALS['phpgw_setup']->detection->get_versions($setup_info);
267                                        $setup_info = $GLOBALS['phpgw_setup']->process->droptables($setup_info);
268                                        break;
269                                case 'new':
270                                        /* process all apps and langs(last param True), excluding apps with the no_mass_update flag set. */
271                                        $setup_info = $GLOBALS['phpgw_setup']->detection->upgrade_exclude($setup_info);
272                                        $setup_info = $GLOBALS['phpgw_setup']->process->pass($setup_info,'new',$_REQUEST['debug'],True);
273                                        $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
274                                        break;
275                                case 'oldversion':
276                                        $setup_info = $GLOBALS['phpgw_setup']->process->pass($setup_info,'upgrade',$_REQUEST['debug']);
277                                        $GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
278                                        break;
279                        }
280
281                        $GLOBALS['phpgw_setup']->db->Halt_On_Error = 'no';
282
283                        $setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been'));
284                        $setup_tpl->set_var('re-check_my_installation',lang('Re-Check My Installation'));
285                        $setup_tpl->parse('V_db_stage_6_post','B_db_stage_6_post');
286                        $db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post');
287                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
288                        /* Hack to fix database inconsistency */
289                        $GLOBALS['phpgw_setup']->db->query("ALTER TABLE phpgw_access_log ADD COLUMN browser varchar(200);");
290                        $GLOBALS['phpgw_setup']->db->query("CREATE TABLE phpgw_async (
291                                id character varying(255) NOT NULL,
292                                next integer NOT NULL,
293                                times character varying(255) NOT NULL,
294                                method character varying(80) NOT NULL,
295                                data text NOT NULL,
296                                account_id integer DEFAULT 0 NOT NULL);");     
297
298                        break;
299                case 10:
300                        $setup_tpl->set_var('tablescurrent',lang('Your applications are current'));
301                        $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications'));
302                        $setup_tpl->set_var('insanity',lang('Insanity'));
303                        $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));
304                        $setup_tpl->set_var('deletetables',lang('Uninstall all applications'));
305                        $setup_tpl->parse('V_db_stage_10','B_db_stage_10');
306                        $db_filled_block = $setup_tpl->get_var('V_db_stage_10');
307                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
308                        break;
309                default:
310                        $setup_tpl->set_var('dbnotexist',lang('Your database does not exist'));
311                        $setup_tpl->parse('V_db_stage_default','B_db_stage_default');
312                        $db_filled_block = $setup_tpl->get_var('V_db_stage_default');
313                        $setup_tpl->set_var('V_db_filled_block',$db_filled_block);
314                        break;
315        }
316
317        // Config Section
318        $setup_tpl->set_var('config_step_text',lang('Step %1 - Configuration',2));
319        $GLOBALS['phpgw_info']['setup']['stage']['config'] = $GLOBALS['phpgw_setup']->detection->check_config();
320
321        // begin DEBUG code
322        //$GLOBALS['phpgw_info']['setup']['stage']['config'] = 10;
323        // end DEBUG code
324
325        switch($GLOBALS['phpgw_info']['setup']['stage']['config'])
326        {
327                case 1:
328                        $setup_tpl->set_var('config_status_img',$incomplete);
329                        $setup_tpl->set_var('config_status_alt',lang('not completed'));
330                        $btn_config_now = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
331                                lang('Please configure eGroupWare for your environment'),
332                                'POST','config.php',
333                                'submit',lang('Configure Now'),
334                                '');
335                        $setup_tpl->set_var('config_table_data',$btn_config_now);
336                        $setup_tpl->set_var('ldap_table_data','&nbsp;');
337                        break;
338                case 10:
339                        $setup_tpl->set_var('config_status_img',$completed);
340                        $setup_tpl->set_var('config_status_alt',lang('completed'));
341                        $btn_edit_config = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
342                                lang('Configuration completed'),
343                                'POST','config.php',
344                                'submit',lang('Edit Current Configuration'),
345                                ''
346                        );
347                        $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type' and config_app='phpgwapi'");
348                        $GLOBALS['phpgw_setup']->db->next_record();
349                        if ($GLOBALS['phpgw_setup']->db->f(0) == 'ldap')
350                        {
351                                $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host' and config_app='phpgwapi'");
352                                $GLOBALS['phpgw_setup']->db->next_record();
353                                if ($GLOBALS['phpgw_setup']->db->f(0) != '')
354                                {
355                                        $btn_config_ldap = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
356                                                lang('LDAP account import/export'),
357                                                'POST','ldap.php',
358                                                'submit',lang('Configure Now'),
359                                                ''
360                                        );
361                                }
362                                else
363                                {
364                                        $btn_config_ldap = '';
365                                }
366/*
367                                $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='webserver_url'");
368                                $GLOBALS['phpgw_setup']->db->next_record();
369                                if ($GLOBALS['phpgw_setup']->db->f(0))
370                                {
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                                else
379                                {
380                                        $link_make_accts = '&nbsp;';
381                                }
382                        }
383                        else
384                        {
385                                $btn_config_ldap = '';
386                                $link_make_accts = $GLOBALS['phpgw_setup']->html->make_href_link_simple(
387                                        '<br>',
388                                        'setup_demo.php',
389                                        lang('Click Here'),
390                                        '<b>'.lang('to setup 1 admin account and 3 demo accounts.').'</b>'
391                                );
392                        }
393                        $config_td = "$btn_edit_config"."$link_make_accts";
394*/
395                        }
396                        $setup_tpl->set_var('config_table_data',$btn_edit_config);
397                        $setup_tpl->set_var('ldap_table_data',$btn_config_ldap);
398                        break;
399                default:
400                        $setup_tpl->set_var('config_status_img',$incomplete);
401                        $setup_tpl->set_var('config_status_alt',lang('not completed'));
402                        $setup_tpl->set_var('config_table_data',lang('Not ready for this stage yet'));
403                        $setup_tpl->set_var('ldap_table_data','&nbsp;');
404                        break;
405        }
406        // Admin Account Section
407        $setup_tpl->set_var('admin_step_text',lang('Step %1 - Admin Account',3));
408        switch($GLOBALS['phpgw_info']['setup']['stage']['config'])
409        {
410                case 10:
411                        // check if there is already a user account (not the anonymous account of sitemgr or a group)
412                        // Note: this does not check the availiblitly of accounts via other auth-methods then sql and ldap!!
413
414                        $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type' and config_app='phpgwapi'");
415                        $GLOBALS['phpgw_setup']->db->next_record();
416                        if ($GLOBALS['phpgw_setup']->db->f(0) == 'ldap')
417                        {
418                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host' and config_app='phpgwapi'");
419                          $GLOBALS['phpgw_setup']->db->next_record();
420                          $ldap_host = $GLOBALS['phpgw_setup']->db->f(0);
421                         
422                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_context' and config_app='phpgwapi'");
423                          $GLOBALS['phpgw_setup']->db->next_record();
424                          $ldap_context = $GLOBALS['phpgw_setup']->db->f(0);
425
426                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_root_dn' and config_app='phpgwapi'");
427                          $GLOBALS['phpgw_setup']->db->next_record();
428                          $ldap_root_dn = $GLOBALS['phpgw_setup']->db->f(0);
429
430                          $GLOBALS['phpgw_setup']->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_root_pw' and config_app='phpgwapi'");
431                          $GLOBALS['phpgw_setup']->db->next_record();
432                          $ldap_root_pw = $GLOBALS['phpgw_setup']->db->f(0);
433                         
434                          $ldap_connection = ldap_connect($ldap_host);                   
435                          ldap_set_option($ldap_connection,LDAP_OPT_PROTOCOL_VERSION,3);
436                          ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);
437                          $ldap_bind = ldap_bind($ldap_connection, $ldap_root_dn, $ldap_root_pw);
438
439                          $filter="(&(phpgwaccounttype=u)(uid=expresso-admin))";
440                          $justthese = array("uidnumber");
441                          $sr=ldap_search($ldap_connection, $ldap_context, $filter, $justthese);
442                          $info = ldap_get_entries($ldap_connection, $sr);
443                          $no_accounts = !$info['count'];
444                        }
445                        else
446                        {
447                                $GLOBALS['phpgw_setup']->db->query("SELECT count(*) FROM phpgw_accounts WHERE account_type='u' AND account_lid!='anonymous'",__LINE__,__FILE__);
448                                $no_accounts = !$GLOBALS['phpgw_setup']->db->next_record() || !$GLOBALS['phpgw_setup']->db->f(0);
449                        }
450                        $setup_tpl->set_var('admin_status_img',$no_accounts ? $incomplete : $completed);
451                        $setup_tpl->set_var('admin_status_alt',$no_accounts ? lang('not completed') : lang('completed'));
452                        $setup_tpl->set_var('admin_table_data',$GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
453                        $no_accounts ? 'Nenhuma conta <font color=red>expresso-admin</font> existe no ldap.' : 'A conta expresso-admin já existe.',
454                                            'POST','setup_demo.php',
455                                            'submit',lang('Create admin account'),
456                                            ''));
457                        break;
458                default:
459                        $setup_tpl->set_var('admin_status_img',$incomplete);
460                        $setup_tpl->set_var('admin_status_alt',lang('not completed'));
461                        $setup_tpl->set_var('admin_table_data',lang('Not ready for this stage yet'));
462                        break;
463        }
464
465        // Lang Section
466        $setup_tpl->set_var('lang_step_text',lang('Step %1 - Language Management',4));
467        $GLOBALS['phpgw_info']['setup']['stage']['lang'] = $GLOBALS['phpgw_setup']->detection->check_lang();
468
469        // begin DEBUG code
470        //$GLOBALS['phpgw_info']['setup']['stage']['lang'] = 0;
471        // end DEBUG code
472
473        switch($GLOBALS['phpgw_info']['setup']['stage']['lang'])
474        {
475                case 1:
476                        $setup_tpl->set_var('lang_status_img',$incomplete);
477                        $setup_tpl->set_var('lang_status_alt','not completed');
478                        $btn_install_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
479                                lang('You do not have any languages installed. Please install one now <br>'),
480                                'POST','lang.php',
481                                'submit',lang('Install Language'),
482                                '');
483                        $setup_tpl->set_var('lang_table_data',$btn_install_lang);
484                        break;
485                case 10:
486                        $langs_list = array();
487                        $languages = get_langs();
488                        foreach ($GLOBALS['phpgw_info']['setup']['installed_langs'] as $key => $value)
489                        {
490                                $langs_list[] = isset($languages[$key]) ? $languages[$key]['descr'] : $value;
491                        }
492                        $setup_tpl->set_var('lang_status_img',$completed);
493                        $setup_tpl->set_var('lang_status_alt','completed');
494                        $btn_manage_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
495                                lang('This stage is completed<br>') . lang('Currently installed languages: %1 <br>',implode(', ',$langs_list)),
496                                'POST','lang.php',
497                                'submit',lang('Manage Languages'),
498                                '');
499                        // show system-charset and offer conversation
500                        include_once(PHPGW_API_INC.'/class.translation_sql.inc.php');
501                        $translation = new translation;
502                        $btn_manage_lang .= lang('Current system-charset is %1, click %2here%3 to change it.',
503                                $translation->system_charset ? "'$translation->system_charset'" : lang('not set'),
504                                '<a href="system_charset.php">','</a>');
505                        $setup_tpl->set_var('lang_table_data',$btn_manage_lang);
506                        break;
507                default:
508                        $setup_tpl->set_var('lang_status_img',$incomplete);
509                        $setup_tpl->set_var('lang_status_alt',lang('not completed'));
510                        $setup_tpl->set_var('lang_table_data',lang('Not ready for this stage yet'));
511                        break;
512        }
513
514        $setup_tpl->set_var('apps_step_text',lang('Step %1 - Advanced Application Management',5));
515//      $GLOBALS['phpgw_info']['setup']['stage']['apps'] = $GLOBALS['phpgw_setup']->check_apps();
516        switch($GLOBALS['phpgw_info']['setup']['stage']['db'])
517        {
518                case 10:
519                        $setup_tpl->set_var('apps_status_img',$completed);
520                        $setup_tpl->set_var('apps_status_alt',lang('completed'));
521                        // check if we have apps to upgrade
522                        $to_upgrade = array();
523                        foreach($setup_info as $app => $data)
524                        {
525                                if ($data['currentver'] && $data['version'] && $data['version'] != $data['currentver'])
526                                {
527                                        $to_upgrade[] = $app;
528                                }
529                        }
530                        $btn_manage_apps = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
531                                count($to_upgrade) ? '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade) :
532                                lang('This stage is completed<br>'),
533                                '','applications.php',
534                                'submit',lang('Manage Applications'),
535                                '');
536                        $setup_tpl->set_var('apps_table_data',$btn_manage_apps);
537                        break;
538                default:
539                        $setup_tpl->set_var('apps_status_img',$incomplete);
540                        $setup_tpl->set_var('apps_status_alt',lang('not completed'));
541                        $setup_tpl->set_var('apps_table_data',lang('Not ready for this stage yet'));
542                        break;
543        }
544
545        $GLOBALS['phpgw_setup']->html->show_header(
546                $GLOBALS['phpgw_info']['setup']['header_msg'],
547                False,
548                'config',
549                $GLOBALS['phpgw_setup']->ConfigDomain . '(' . $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_setup']->ConfigDomain]['db_type'] . ')'
550        );
551        $setup_tpl->pparse('out','T_setup_main');
552        $GLOBALS['phpgw_setup']->html->show_footer();
553?>
Note: See TracBrowser for help on using the repository browser.