phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] [20849] update setup


From: Sigurd Nes
Subject: [Phpgroupware-cvs] [20849] update setup
Date: Fri, 20 Nov 2009 10:29:14 +0000

Revision: 20849
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=20849
Author:   sigurdne
Date:     2009-11-20 10:29:14 +0000 (Fri, 20 Nov 2009)
Log Message:
-----------
update setup

Modified Paths:
--------------
    people/sigurdne/modules/setup/trunk/accounts.php
    people/sigurdne/modules/setup/trunk/applications.php
    people/sigurdne/modules/setup/trunk/config.php
    people/sigurdne/modules/setup/trunk/inc/functions.inc.php
    people/sigurdne/modules/setup/trunk/inc/hook_config.inc.php
    people/sigurdne/modules/setup/trunk/index.php
    people/sigurdne/modules/setup/trunk/lang.php
    people/sigurdne/modules/setup/trunk/ldap.php
    people/sigurdne/modules/setup/trunk/ldapexport.php
    people/sigurdne/modules/setup/trunk/ldapimport.php
    people/sigurdne/modules/setup/trunk/ldapmodify.php
    people/sigurdne/modules/setup/trunk/manageheader.php
    people/sigurdne/modules/setup/trunk/sqltoarray.php
    people/sigurdne/modules/setup/trunk/templates/base/config.tpl
    people/sigurdne/modules/setup/trunk/templates/base/head.tpl
    people/sigurdne/modules/setup/trunk/templates/base/manageheader.tpl

Modified: people/sigurdne/modules/setup/trunk/accounts.php
===================================================================
--- people/sigurdne/modules/setup/trunk/accounts.php    2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/accounts.php    2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -2,7 +2,7 @@
        /**
        * Setup
        *
-       * @copyright Copyright (C) 2000-2008 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @copyright Copyright (C) 2000-2009 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package setup
        * @version $Id$
@@ -78,9 +78,9 @@
                (
                        'common' => array
                        (
-                               'maxmatchs'             => 25,
-                               'template_set'  => 'idots',
-                               'theme'                 => 'idots',
+                               'maxmatchs'             => 10,
+                               'template_set'  => 'portico',
+                               'theme'                 => 'portico',
                                'tz_offset'             => 0,
                                'dateformat'    => 'Y/m/d',
                                'lang'                  => 
substr(phpgw::get_var('ConfigLang'), 0, 2),
@@ -179,6 +179,7 @@
                $GLOBALS['phpgw_info']['server']['account_repository']          
= 'sql';
                $GLOBALS['phpgw_info']['server']['auth_type']                   
        = 'sql';
                $GLOBALS['phpgw_info']['server']['encryption_type']             
        = 'ssha';
+               $GLOBALS['phpgw_info']['server']['password_level']         = 
'NONALPHA'; 
                $GLOBALS['phpgw_info']['server']['account_min_id']              
        = 1000;
                $GLOBALS['phpgw_info']['server']['account_max_id']              
        = 65535;
                $GLOBALS['phpgw_info']['server']['group_min_id']                
        = 500;
@@ -189,8 +190,10 @@
                                . " WHERE config_name LIKE 'ldap%' OR 
config_name LIKE '%_id'"
                                        . " OR config_name = 
'account_repository'"
                                        . " OR config_name = 'auth_type'"
+                                       . " OR config_name = 'encryption_type'"
                                        . " OR config_name = 'encryptkey'"
-                                       . " OR config_name = 'encryption_type'";
+                                       . " OR config_name = 'password_level'"
+                                       . " OR config_name = 'webserver_url'";
 
                $GLOBALS['phpgw_setup']->db->query($sql, __LINE__, __FILE__);
                while ( $GLOBALS['phpgw_setup']->db->next_record() )
@@ -200,14 +203,8 @@
 
                $GLOBALS['phpgw'] = new phpgw;
                $GLOBALS['phpgw']->db       =& $db;
+               $GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts');
                $GLOBALS['phpgw']->acl          = CreateObject('phpgwapi.acl');
-               $GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts');
-               //XXX Dec 08. Caeies : Fix the first admin login when using 
cache as files and that mcrypt is enabled
-               //XXX Dec 08. Caeies : This is stolen from 
phpgwapi/inc/class.sessions.inc.php ... which let me think that's there's a 
design problem there.
-               //XXX Dec 08. Caeies : If a notice or error is triggered from 
here ... then your config was not properly done.
-               //XXX Dec 08. Caeies : note : we rely on the fact that the 
setup use the same session_id than the one which is used for the next session 
generation ... if it not the case ... then 
-               //XXX Dec 08. Caeies : the resulting cached string will not be 
able to be decoded ... hope this don't broke to much thing.
-               //XXX Dec 08. Caeies : btw it's potentially risky not to 
encrypt the session files since the admin password is stored in clear in the 
cache file. no idea for shm.
                $GLOBALS['phpgw']->crypto->init(array(md5(session_id() . 
$GLOBALS['phpgw_info']['server']['encryptkey']), 
$GLOBALS['phpgw_info']['server']['mcrypt_iv']));
 
                /* Posted admin data */
@@ -219,7 +216,7 @@
                $lname                  = phpgw::get_var('lname', 'string', 
'POST');
 
                if ( ($GLOBALS['phpgw_info']['server']['account_repository'] == 
'ldap')
-                       && !$GLOBALS['phpgw']->accounts->ds )
+                       && !$GLOBALS['phpgw']->accounts->connected )
                {
                        echo "<strong>Error: Error connecting to LDAP server 
{$GLOBALS['phpgw_info']['server']['ldap_host']}</strong><br>";
                        exit;
@@ -227,6 +224,11 @@
 
                $errors = validate_admin($username, $passwd, $passwd2, $fname, 
$lname);
                
+               if(in_array($username, array('admin', 'default')))
+               {
+                       $errors[] = lang('That loginid has already been taken');
+               }
+               
                if ( !count($errors) )
                {
                        $admin_acct = array
@@ -238,7 +240,8 @@
                        );
 
                        // Begin transaction for acl, etc
-                       $GLOBALS['phpgw_setup']->db->transaction_begin();
+                       // FIXME: Conflicting transactions - there are 
transactions in phpgwapi_accounts_::create() and acl::save_repository()
+                       //$GLOBALS['phpgw_setup']->db->transaction_begin();
 
                        // Now, clear out existing tables
                        $contacts_to_delete = 
$GLOBALS['phpgw']->accounts->get_account_with_contact();
@@ -246,6 +249,28 @@
                        $GLOBALS['phpgw_setup']->db->query('DELETE FROM 
phpgw_preferences');
                        $GLOBALS['phpgw_setup']->db->query('DELETE FROM 
phpgw_acl');
                        $GLOBALS['phpgw_setup']->db->query('DELETE FROM 
phpgw_mapping');
+                       $GLOBALS['phpgw_setup']->db->query('DELETE FROM 
phpgw_group_map');
+                       $GLOBALS['phpgw_setup']->db->query("DELETE FROM 
phpgw_nextid WHERE appname = 'groups' OR appname = 'accounts'");
+                       $GLOBALS['phpgw_setup']->db->query('DELETE FROM 
phpgw_contact');
+                       $GLOBALS['phpgw_setup']->db->query('DELETE FROM 
phpgw_contact_person');
+                       $GLOBALS['phpgw_setup']->db->query('DELETE FROM 
phpgw_contact_org');
+
+                       // Clean out LDAP
+                       if( 
$GLOBALS['phpgw_info']['server']['account_repository'] == 'ldap' || 
$GLOBALS['phpgw_info']['server']['account_repository'] = 'sqlldap')
+                       {
+                               $accounts = 
$GLOBALS['phpgw']->accounts->get_list('accounts', -1, '', '', '',-1);
+
+                               foreach ($accounts as $account)
+                               {
+                                       
$GLOBALS['phpgw']->accounts->delete($account->id);
+                               }
+                               $accounts = 
$GLOBALS['phpgw']->accounts->get_list('groups', -1, '', '', '',-1);
+                               foreach ($accounts as $account)
+                               {
+                                       
$GLOBALS['phpgw']->accounts->delete($account->id);
+                               }
+                       }
+
                        $contacts = CreateObject('phpgwapi.contacts');
                        if(is_array($contacts_to_delete))
                        {
@@ -270,6 +295,13 @@
                                'todo'
                        );
 
+                       $acls[] = array
+                       (
+                               'appname'       => 'preferences',
+                               'location'      => 'changepassword',
+                               'rights'        => 1
+                       );
+                       
                        $group = array('username' => 'default');
                        $defaultgroupid = add_account($group, 'g', array(), 
$modules);
 
@@ -280,19 +312,10 @@
 
                        $groups = array($defaultgroupid, $admingroupid);
 
-                       try
-                       {
-                               $accountid = add_account($admin_acct, 'u', 
$groups, array('admin'));
-                               
$GLOBALS['phpgw_setup']->db->transaction_commit();
-
+                       $accountid = add_account($admin_acct, 'u', $groups, 
array('admin'), $acls);
                                Header('Location: index.php');
                                exit;
                        }
-                       catch (Exception $e )
-                       {
-                               $errors[] = $e->getMessage();
-                       }
-               }
        }
        
        $tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');

Modified: people/sigurdne/modules/setup/trunk/applications.php
===================================================================
--- people/sigurdne/modules/setup/trunk/applications.php        2009-11-20 
10:29:01 UTC (rev 20848)
+++ people/sigurdne/modules/setup/trunk/applications.php        2009-11-20 
10:29:14 UTC (rev 20849)
@@ -1,34 +1,14 @@
 <?php
        /**
-        * Setup - Applications Manager
+       * Setup
         *
-        * @author Dave Hall <address@hidden>
-        * @author Others <unknown>
-        * @copyright Copyright (C) 2000 - 2008 Free Software Foundation, Inc. 
http://www.fsf.org/
-        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License v3 or later
-        * @package phpgroupware
-        * @subpackage setup
-        * @version $Id$
+       * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+       * @package setup
+       * @version $Id$
         */
 
        /*
-          This program is free software: you can redistribute it and/or modify
-          it under the terms of the GNU General Public License as published by
-          the Free Software Foundation, either version 3 of the License, or
-          (at your option) any later version.
-
-          This program is distributed in the hope that it will be useful,
-          but WITHOUT ANY WARRANTY; without even the implied warranty of
-          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-          GNU Lesser General Public License for more details.
-
-          You should have received a copy of the GNU General Public License
-          along with this program.  If not, see <http://www.gnu.org/licenses/>.
-        */
-
-
-       $DEBUG = (isset($_POST['debug']) && $_POST['debug']) || 
(isset($_GET['debug']) && $_GET['debug']);
-       /*
         TODO: We allow a user to hose their setup here, need to make use
         of dependencies so they are warned that they are pulling the rug
         out from under other apps.  e.g. if they select to uninstall the api
@@ -157,8 +137,14 @@
                $install = phpgw::get_var('install', 'string', 'POST');
                $upgrade = phpgw::get_var('upgrade', 'string', 'POST');
 
+               if( !isset($GLOBALS['phpgw_setup']->oProc) || 
!$GLOBALS['phpgw_setup']->oProc )
+               {
+                       $GLOBALS['phpgw_setup']->process->init_process();
+               }
+
                if(!empty($remove) && is_array($remove))
                {
+                       
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                        foreach($remove as $appname => $key)
                        {
                                echo '<h3>' . lang('Processing: %1', 
lang($appname)) . "</h3>\n<ul>";
@@ -167,7 +153,7 @@
                                if ( isset($setup_info[$appname]['tables'])
                                        && $setup_info[$appname]['tables'] )
                                {
-                                       // Tables has to be dropped in reversed 
order (mssql) if they are referenced by others
+                                       // Sigurd: Tables has to be dropped in 
reversed order (mssql) if they are referenced by others
                                        $terror[0]['tables'] = 
array_reverse($setup_info[$appname]['tables']);
                                        
$GLOBALS['phpgw_setup']->process->droptables($terror, $DEBUG);
                                        echo '<li>' . lang('%1 tables dropped', 
lang($appname)) . ".</li>\n";
@@ -186,10 +172,12 @@
                                $terror = 
$GLOBALS['phpgw_setup']->process->drop_langs($terror, $DEBUG);
                                echo '<li>' . lang('%1 translations removed', 
$appname) . ".</li>\n</ul>\n";
                        }
+                       
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit();
                }
 
                if(!empty($install) && is_array($install))
                {
+                       
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
                        foreach($install as $appname => $key)
                        {
                                echo '<h3>' . lang('Processing: %1', 
lang($appname)) . "</h3>\n<ul>";
@@ -230,6 +218,7 @@
                                $terror = 
$GLOBALS['phpgw_setup']->process->add_langs($terror,$DEBUG,$force_en);
                                echo '<li>' . lang('%1 translations added', 
lang($appname)) . ".</li>\n</ul>\n";
                        }
+                       
$GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit();
                }
 
                if(!empty($upgrade) && is_array($upgrade))

Modified: people/sigurdne/modules/setup/trunk/config.php
===================================================================
--- people/sigurdne/modules/setup/trunk/config.php      2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/config.php      2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -82,50 +82,38 @@
        $GLOBALS['phpgw_setup']->loaddb();
 
        // Guessing default values.
-       $current_config['hostname']  = $_SERVER['SERVER_NAME'];
+       $GLOBALS['current_config']['hostname']  = $_SERVER['HTTP_HOST'];
        // files-dir is not longer allowed in document root, for security 
reasons !!!
-       $current_config['files_dir'] = '/outside/webserver/docroot';
+       $GLOBALS['current_config']['files_dir'] = '/outside/webserver/docroot';
 
        if( @is_dir('/tmp') )
        {
-               $current_config['temp_dir'] = '/tmp';
+               $GLOBALS['current_config']['temp_dir'] = '/tmp';
        }
        elseif( @is_dir('C:\\TEMP') )
        {
-               $current_config['temp_dir'] = 'C:\\TEMP';
+               $GLOBALS['current_config']['temp_dir'] = 'C:\\TEMP';
        }
        else
        {
-               $current_config['temp_dir'] = '/path/to/temp/dir';
+               $GLOBALS['current_config']['temp_dir'] = '/path/to/temp/dir';
        }
        // guessing the phpGW url
        $parts = explode('/',$_SERVER['PHP_SELF']);
-       array_pop($parts); // config.php
-       array_pop($parts); // setup
-       if ( count((array) $parts) > 1)
-       {
-               $current_config['webserver_url'] = implode('/',$parts);
-       }
-       else
-       {
-               $http = 'http';
-               if ( isset($_SERVER['HTTPS']) )
-               {
-                       $http .= 's';
-               }
-               $current_config['webserver_url'] = 
"{$http}://{$_SERVER['HTTP_HOST']}";
-       }
+       unset($parts[count($parts)-1]); // config.php
+       unset($parts[count($parts)-1]); // setup
+       $GLOBALS['current_config']['webserver_url'] = implode('/',$parts);
 
        // Add some sane defaults for accounts
-       $current_config['account_min_id'] = 1000;
-       $current_config['account_max_id'] = 65535;
-       $current_config['group_min_id'] = 500;
-       $current_config['group_max_id'] = 999;
-       $current_config['ldap_account_home'] = '/noexistant';
-       $current_config['ldap_account_shell'] = '/bin/false';
-       $current_config['ldap_host'] = 'localhost';
+       $GLOBALS['current_config']['account_min_id'] = 1000;
+       $GLOBALS['current_config']['account_max_id'] = 65535;
+       $GLOBALS['current_config']['group_min_id'] = 500;
+       $GLOBALS['current_config']['group_max_id'] = 999;
+       $GLOBALS['current_config']['ldap_account_home'] = '/noexistant';
+       $GLOBALS['current_config']['ldap_account_shell'] = '/bin/false';
+       $GLOBALS['current_config']['ldap_host'] = 'localhost';
        
-       $current_config['encryptkey'] = md5(time() . $_SERVER['HTTP_HOST']); // 
random enough
+       $GLOBALS['current_config']['encryptkey'] = md5(time() . 
$_SERVER['HTTP_HOST']); // random enough
 
 
        $setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions();
@@ -158,7 +146,7 @@
 
                        /* Don't erase passwords, since we also do not print 
them below */
                        if ( $value 
-                               || (!preg_match('/(passwd|password|root_pw)/', 
$setting)) )
+                               || (!preg_match('/passwd/', $setting) && 
!preg_match('/password/', $setting) && !preg_match('/root_pw/', $setting)) )
                        {
                                $GLOBALS['phpgw_setup']->db->query("DELETE FROM 
phpgw_config WHERE config_name='{$setting}'", __LINE__, __FILE__);
                        }
@@ -205,7 +193,7 @@
        $GLOBALS['phpgw_setup']->db->query('SELECT * FROM phpgw_config');
        while($GLOBALS['phpgw_setup']->db->next_record())
        {
-               $current_config[$GLOBALS['phpgw_setup']->db->f('config_name')] 
= $GLOBALS['phpgw_setup']->db->f('config_value');
+               
$GLOBALS['current_config'][$GLOBALS['phpgw_setup']->db->f('config_name')] = 
$GLOBALS['phpgw_setup']->db->f('config_value');
        }
        
        // are we here because of an error: files-dir in docroot
@@ -215,7 +203,7 @@
 
                foreach($_POST['newsettings'] as $key => $val)
                {
-                       $current_config[$key] = $val;
+                       $GLOBALS['current_config'][$key] = $val;
                }
        }
 
@@ -261,16 +249,15 @@
                                $setup_tpl->set_var($value, lang($newval));
                                break;
                        case 'value':
-                               $newval = preg_replace('/ /','_',$newval);
+                               $newval = ereg_replace(' ','_',$newval);
                                /* Don't show passwords in the form */
-                               if ( !isset($current_config[$newval])
-                                       || 
preg_match('/(passwd|password|root_pw)/', $value) )
+                               if(ereg('passwd',$value) || 
ereg('password',$value) || ereg('root_pw',$value))
                                {
-                                       $setup_tpl->set_var($value, '');
+                                       $setup_tpl->set_var($value,'');
                                }
                                else
                                {
-                                       $setup_tpl->set_var($value, 
$current_config[$newval]);
+                                       
$setup_tpl->set_var($value,@$current_config[$newval]);
                                }
                                break;
                        case 'selected':

Modified: people/sigurdne/modules/setup/trunk/inc/functions.inc.php
===================================================================
--- people/sigurdne/modules/setup/trunk/inc/functions.inc.php   2009-11-20 
10:29:01 UTC (rev 20848)
+++ people/sigurdne/modules/setup/trunk/inc/functions.inc.php   2009-11-20 
10:29:14 UTC (rev 20849)
@@ -17,24 +17,6 @@
 
   /* $Id$ */
 
-       // PHP5 compat fix
-       if (version_compare(phpversion(), '5.0') < 0)
-       {
-               eval('
-                       function clone($obj)
-                       {
-                               if ( method_exists($obj, "__clone") )
-                               {
-                                       $new_obj = $obj;
-                                       $new_obj->__clone();
-                                       return $new_obj;
-                               }
-                               return $obj;
-                       }
-               ');
-       }
-
-
        /**
        * phpGroupWare Information level "error"
        */
@@ -277,7 +259,7 @@
                        case E_STRICT:
                                $log_args['severity'] = 'N';
                                $log->notice($log_args);
-                               echo "\n<br>" . lang('ERROR Notice: %1 in %2 at 
line %3', $error_msg, $error_file, $error_line) . "<br>\n"; //this will be 
commented in the final version
+                       //      echo "\n<br>" . lang('ERROR Notice: %1 in %2 at 
line %3', $error_msg, $error_file, $error_line) . "<br>\n"; //this will be 
commented in the final version
                        //No default, we just ignore it, for now
                }
        }
@@ -358,4 +340,18 @@
 
        $GLOBALS['phpgw_info']['server']['app_images'] = 
'templates/base/images';
 
+       if($_POST['setting']['enable_mcrypt'] == 'True')
+       {
+               $GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = true;
+               $_iv  = $_POST['setting']['mcrypt_iv'];
+               $_key = $_POST['setting']['setup_mcrypt_key'];
+       }
+       else
+       {
+               $_iv  = $GLOBALS['phpgw_info']['server']['mcrypt_iv'];
+               $_key = $GLOBALS['phpgw_info']['server']['setup_mcrypt_key'];   
+       }
+
+       $GLOBALS['phpgw']->crypto->init(array($_key, $_iv));
+
        $GLOBALS['phpgw_setup'] = CreateObject('phpgwapi.setup', True, True);

Modified: people/sigurdne/modules/setup/trunk/inc/hook_config.inc.php
===================================================================
--- people/sigurdne/modules/setup/trunk/inc/hook_config.inc.php 2009-11-20 
10:29:01 UTC (rev 20848)
+++ people/sigurdne/modules/setup/trunk/inc/hook_config.inc.php 2009-11-20 
10:29:14 UTC (rev 20849)
@@ -2,15 +2,74 @@
        /**
        * Setup - configuration hook
        *
-       * cConfiguration hook
+       * @author Dave Hall <address@hidden>
        * @author Mark Peters <address@hidden>
-       * @copyright Copyright (C) 2000-2002,2005 Free Software Foundation, 
Inc. http://www.fsf.org/
+       * @copyright Copyright (C) 2000-2008 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @package setup
+       * @package phpgroupware
+       * @subpackage setup
+       * @caegory hooks
        * @version $Id$
        */
 
+       /*
+          This program is free software: you can redistribute it and/or modify
+          it under the terms of the GNU General Public License as published by
+          the Free Software Foundation, either version 2 of the License, or
+          (at your option) any later version.
+
+          This program is distributed in the hope that it will be useful,
+          but WITHOUT ANY WARRANTY; without even the implied warranty of
+          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+          GNU General Public License for more details.
+
+          You should have received a copy of the GNU General Public License
+          along with this program.  If not, see <http://www.gnu.org/licenses/>.
+       */
+
        /**
+        * Get a list of possible domains to be used for a session cookies
+        *
+        * @param array $config the current configuration values
+        * @return string HTML snippet with the available domain options
+        */
+       function cookie_domain($config)
+       {
+               $current_domain = '';
+               if ( isset($config['cookie_domain']) )
+               {
+                       $current_domain = $config['cookie_domain'];
+               }
+
+               $available = array();
+               $domain_parts = explode('.', $_SERVER['HTTP_HOST']);
+
+               foreach ( $domain_parts as $cnt => $part )
+               {
+                       $str = '.' . implode('.', $domain_parts);
+                       $available[$str] = $str;
+                       unset($domain_parts[$cnt]);
+               }
+
+               // give the user a sane default
+               $available[''] = lang('request fqdn');
+
+               $available = array_reverse($available, true);
+
+               $out = '';
+               foreach ( $available as $key => $domain )
+               {
+                       $sel = '';
+                       if ( $key == $current_domain )
+                       {
+                               $sel = ' selected';
+                       }
+                       $out .= "<option 
value=\"{$key}\"{$sel}>{$domain}</option>\n";
+               }
+               return $out;
+       }
+
+       /**
        * Get selectbox for supported encryption algorithms selectbox
        *
        * @param $config
@@ -18,46 +77,46 @@
        */
        function encryptalgo($config)
        {
-               if(@function_exists('mcrypt_list_algorithms'))
+               if ( function_exists('mcrypt_list_algorithms') )
                {
                        $listed = array();
                        if(!isset($config['mcrypt_algo']))
                        {
-                               $config['mcrypt_algo'] = 'tripledes';  /* 
MCRYPT_TRIPLEDES */
+                               $config['mcrypt_algo'] = MCRYPT_TRIPLEDES; 
                        }
-                       $algos = @mcrypt_list_algorithms();
+                       $algos = mcrypt_list_algorithms();
                        $found = False;
 
                        $out = '';
-                       while(list($key,$value) = each($algos))
+                       foreach ( $algos as $algo )
                        {
                                $found = True;
                                /* Only show each once - seems this is a 
problem in some installs */
-                               if(!in_array($value,$listed))
-                               {
-                                       if($config['mcrypt_algo'] == $value)
+                               if ( in_array($algo, $listed) )
                                        {
-                                               $selected = ' 
selected="selected"';
+                                       continue;
                                        }
-                                       else
-                                       {
+
                                                $selected = '';
+                               if ( $config['mcrypt_algo'] == $algo )
+                               {
+                                       $selected = ' selected';
                                        }
-                                       $descr = strtoupper($value);
 
-                                       $out .= '<option value="' . $value . 
'"' . $selected . '>' . $descr . '</option>' . "\n";
-                                       $listed[] = $value;
-                               }
+                               $descr = strtoupper($algo);
+
+                               $out .= "<option 
value=\"{$algo}\"{$selected}>{$descr}</option>\n";
+                               $listed[] = $algo;
                        }
                        if(!$found)
                        {
                                /* Something is wrong with their mcrypt install 
or php.ini */
-                               $out = '<option value="">' . lang('no 
algorithms available') . '</option>' . "\n";;
+                               $out = '<option value="">' . lang('no 
algorithms available') . '</option>' . "\n";
                        }
                }
                else
                {
-                       $out = '<option value="tripledes">TRIPLEDES</option>' . 
"\n";;
+                       $out = '<option value="tripledes">TRIPLEDES</option>' . 
"\n";
                }
                return $out;
        }
@@ -154,43 +213,42 @@
                }
                return $out;
        }
-
        /**
-       * Get HTML select options with cookie_domain data
+       * Configureable password securitylevel
        *
-       * @param none
+       * @param $config
        * @return string HTML select box
        */
-       function cookie_domain($config)
-       {
-               $current = 'request_fqdn';
-               if ( isset($config['cookie_domain']))
+       function passwdlevels($config)
                {
-                       $current = $config['cookie_domain'];
-               }
+               $levels = array
+               (
+                       '8CHAR' => lang('at least 8 characters long'),
+                       '2UPPER'        => lang('..and at least 2 upper case 
characters'),
+                       '2LOW'  => lang('..and at least 2 lower case 
characters'),
+                       '1NUM'  => lang('..and contain at least 1 number'),
+                       'NONALPHA'      => lang('..and at least 1 non 
alphanumeric character')
+               );
                
-               $options = array('request_fqdn' => lang('Fully Qualified Domain 
of Request'));
-               
-               $domain = '';
-               
-               $parts = explode('.', phpgw::get_var('SERVER_NAME', 'string', 
'SERVER'));
-               for ( $i = count($parts) -1; $i >= 0; --$i )
+               if ( !isset($config['password_level']) )
                {
-                       $domain .= ".{$parts[$i]}";
-                       $options[$domain] = $domain;
+                       $config['password_level'] = 'NONALPHA';
                }
+               $enc_type = $config['password_level'];
                
                $out = '';
-               foreach ( $options as $key => $option )
+               foreach ( $levels as $level => $label)
                {
                        $selected = '';
-                       if ( $key == $current )
+                       if ( $enc_type == $level)
                        {
                                $selected = ' selected';
                        }
                        
-                       $out .= "<option 
value=\"{$key}\"{$selected}>$option</option>\n";
+                       $out .=  <<<HTML
+                               <option 
value="{$level}"{$selected}>{$label}</option>";
+
+HTML;
                }
                return $out;
        }
-       
\ No newline at end of file

Modified: people/sigurdne/modules/setup/trunk/index.php
===================================================================
--- people/sigurdne/modules/setup/trunk/index.php       2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/index.php       2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -248,7 +248,14 @@
                        switch 
($GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'])
                        {
                                case 'dbcreate':
+                                       try
+                                       {
                                        
$GLOBALS['phpgw_setup']->db->create_database($_POST['db_root'], 
$_POST['db_pass']);
+                                       }
+                                       catch (Exception $e)
+                                       {
+                                               
$setup_tpl->set_var('status',$e->getMessage());
+                                       }
                                        break;
                                case 'drop':
                                        $setup_info = 
$GLOBALS['phpgw_setup']->detection->get_versions($setup_info);
@@ -338,7 +345,7 @@
                                        $btn_config_ldap = 
$GLOBALS['phpgw_setup']->html->make_frm_btn_simple(
                                                lang('LDAP account 
import/export'),
                                                'POST','ldap.php',
-                                               'submit',lang('Configure Now'),
+                                               'submit',lang('Configure LDAP 
accounts'),
                                                ''
                                        );
                                }

Modified: people/sigurdne/modules/setup/trunk/lang.php
===================================================================
--- people/sigurdne/modules/setup/trunk/lang.php        2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/lang.php        2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -9,6 +9,7 @@
        */
 
        $phpgw_info = array();
+       $error = '';
        if ( !isset($included) || !$included )
        {
                $GLOBALS['phpgw_info']['flags'] = array

Modified: people/sigurdne/modules/setup/trunk/ldap.php
===================================================================
--- people/sigurdne/modules/setup/trunk/ldap.php        2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/ldap.php        2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -65,7 +65,7 @@
        $setup_tpl->set_var('ldapmodify','ldapmodify.php');
        $setup_tpl->set_var('ldapimport','ldapimport.php');
        $setup_tpl->set_var('ldapexport','ldapexport.php');
-       $setup_tpl->set_var('ldapdummy','setup_demo.php');
+       $setup_tpl->set_var('ldapdummy','accounts.php');
        $setup_tpl->set_var('action_url','index.php');
        $setup_tpl->set_var('cancel',lang('Cancel'));
 

Modified: people/sigurdne/modules/setup/trunk/ldapexport.php
===================================================================
--- people/sigurdne/modules/setup/trunk/ldapexport.php  2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/ldapexport.php  2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -2,18 +2,18 @@
        /**
        * Setup
        *
-       * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @copyright Copyright (C) 2000-2009 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package setup
        * @version $Id$
        */
 
-       $phpgw_info = array();
-       $phpgw_info["flags"] = array(
-               'noheader'   => True,
-               'nonavbar'   => True,
+       $GLOBALS['phpgw_info']['flags'] = array
+       (
+               'noheader'   => true,
+               'nonavbar'   => true,
                'currentapp' => 'home',
-               'noapi'      => True
+               'noapi'      => true
        );
        
        /**
@@ -29,47 +29,61 @@
        }
        // Does not return unless user is authorized
 
-       //This stops timeout problems for larger conversions
-       @set_time_limit(0);
 
        /**
-       * phpGroupWare class
-       * @package setup
-       * @ignore
+        * Add account
+        * 
+        * @param array  $acct    Account name and other information to use
+        * @param string $type    Account type: u = user | g = group
+        * @param array  $groups  Groups to add account to
+        * @param array  $modules Modules to grant account access to
+        * @param array  $acls    ACLs to set for account
+        *
+        * @return integer Account ID
        */
-       class phpgw
+       function add_account($acct, $type, $groups = array(), $modules = 
array(), $acls = array())
        {
-               /**
-                * Common
-                * @var object
-                */
-               var $common;
+               if ( $type == 'u' )
+               {
+                       $account                        = new phpgwapi_user();
+                       $account->id            = $acct['id'];
+                       $account->lid           = $acct['lid'];
+                       $account->firstname     = $acct['firstname'];
+                       $account->lastname      = $acct['lastname'];
+                       $account->passwd        = $acct['password'];
+                       $account->enabled       = true;
+                       $account->expires       = -1;
+                       $account->person_id     = $acct['person_id'];
+               }
+               else
+               {
+                       $account                        = new phpgwapi_group();
+                       $account->id            = $acct['id'];
+                       $account->lid           = $acct['lid'];
+                       $account->firstname = ucfirst($acct['lid']);
+                       $account->person_id     = $acct['person_id'];
+               }
                
-               /**
-                * Accounts
-                * @var object
-                */
-               var $accounts;
+               return $GLOBALS['phpgw']->accounts->create($account, $groups, 
$acls, $modules);
+       }
                
-               /**
-                * Applications
-                * @var object
-                */
-               var $applications;
+
+       //This stops timeout problems for larger conversions
+       @set_time_limit(0);
                
                /**
-                * Database
-                * @var object
+       * phpGroupWare class
+       * @package setup
+       * @ignore
                 */
-               var $db;
-       }
-       $phpgw = new phpgw;
-       $phpgw->common = CreateObject('phpgwapi.common');
 
-       $common = $phpgw->common;
+       $common = $GLOBALS['phpgw']->common;
        $GLOBALS['phpgw_setup']->loaddb();
-       $phpgw->db = $GLOBALS['phpgw_setup']->db;
+       $GLOBALS['phpgw']->db = $GLOBALS['phpgw_setup']->db;
+       $GLOBALS['phpgw']->hooks = createObject('phpgwapi.hooks');      
+       $GLOBALS['phpgw']->acl = createObject('phpgwapi.acl');
 
+
        $tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
        $setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
        $setup_tpl->set_file(array(
@@ -95,11 +109,6 @@
        // connect to ldap server
        if(!$ldap = $common->ldapConnect())
        {
-               $noldapconnection = True;
-       }
-
-       if($noldapconnection)
-       {
                Header('Location: config.php?error=badldapconnection');
                exit;
        }
@@ -109,17 +118,19 @@
        while($GLOBALS['phpgw_setup']->db->next_record())
        {
                $i = $GLOBALS['phpgw_setup']->db->f('account_id');
-               $account_info[$i]['account_id']        = 
$GLOBALS['phpgw_setup']->db->f('account_id');
-               $account_info[$i]['account_lid']       = 
$GLOBALS['phpgw_setup']->db->f('account_lid');
-               $account_info[$i]['account_firstname'] = 
$GLOBALS['phpgw_setup']->db->f('account_firstname');
-               $account_info[$i]['account_lastname']  = 
$GLOBALS['phpgw_setup']->db->f('account_lastname');
-               $account_info[$i]['account_status']    = 
$GLOBALS['phpgw_setup']->db->f('account_status');
-               $account_info[$i]['account_expires']   = 
$GLOBALS['phpgw_setup']->db->f('account_expires');
+               $account_info[$i]['id']        = 
$GLOBALS['phpgw_setup']->db->f('account_id');
+               $account_info[$i]['lid']       = 
$GLOBALS['phpgw_setup']->db->f('account_lid');
+               $account_info[$i]['firstname'] = 
$GLOBALS['phpgw_setup']->db->f('account_firstname');
+               $account_info[$i]['lastname']  = 
$GLOBALS['phpgw_setup']->db->f('account_lastname');
+               $account_info[$i]['status']    = 
$GLOBALS['phpgw_setup']->db->f('account_status');
+               $account_info[$i]['expires']   = 
$GLOBALS['phpgw_setup']->db->f('account_expires');
+               $account_info[$i]['person_id'] = 
$GLOBALS['phpgw_setup']->db->f('person_id');
        }
 
+       $newaccount = array();
        while(list($key,$data) = @each($account_info))
        {
-               $tmp = $data['account_id'];
+               $tmp = $data['id'];
                $newaccount[$tmp] = $data;
        }
        $account_info = $newaccount;
@@ -129,48 +140,47 @@
        while($GLOBALS['phpgw_setup']->db->next_record())
        {
                $i = $GLOBALS['phpgw_setup']->db->f('account_id');
-               $group_info[$i]['account_id']        = 
$GLOBALS['phpgw_setup']->db->f('account_id');
-               $group_info[$i]['account_lid']       = 
$GLOBALS['phpgw_setup']->db->f('account_lid');
-               $group_info[$i]['account_firstname'] = 
$GLOBALS['phpgw_setup']->db->f('account_firstname');
-               $group_info[$i]['account_lastname']  = 
$GLOBALS['phpgw_setup']->db->f('account_lastname');
-               $group_info[$i]['account_status']    = 
$GLOBALS['phpgw_setup']->db->f('account_status');
-               $group_info[$i]['account_expires']   = 
$GLOBALS['phpgw_setup']->db->f('account_expires');
+               $group_info[$i]['id']        = 
$GLOBALS['phpgw_setup']->db->f('account_id');
+               $group_info[$i]['lid']       = 
$GLOBALS['phpgw_setup']->db->f('account_lid');
+               $group_info[$i]['firstname'] = 
$GLOBALS['phpgw_setup']->db->f('account_firstname');
+               $group_info[$i]['lastname']  = 
$GLOBALS['phpgw_setup']->db->f('account_lastname');
+               $group_info[$i]['status']    = 
$GLOBALS['phpgw_setup']->db->f('account_status');
+               $group_info[$i]['expires']   = 
$GLOBALS['phpgw_setup']->db->f('account_expires');
+               $group_info[$i]['person_id'] = 
$GLOBALS['phpgw_setup']->db->f('person_id');
        }
-
-       if($_POST['cancel'])
+       if(isset($_POST['cancel']) && $_POST['cancel'])
        {
                Header('Location: ldap.php');
                exit;
        }
 
-       if($_POST['submit'])
+       if(isset($_POST['submit']) && $_POST['submit'])
        {
-               if($_POST['ldapgroups'] && is_array($_POST['ldapgroups']))
+               if(isset($_POST['ldapgroups']) && $_POST['ldapgroups'] && 
is_array($_POST['ldapgroups']))
                {
-
+                       $groups = CreateObject('phpgwapi.accounts');
                        foreach($_POST['ldapgroups'] as $key => $groupid)
                        {
                                $id_exist = 0;
-                               $thisacctid    = 
$group_info[$groupid]['account_id'];
-                               $thisacctlid   = 
$group_info[$groupid]['account_lid'];
-                               $thisfirstname = 
$group_info[$groupid]['account_firstname'];
-                               $thislastname  = 
$group_info[$groupid]['account_lastname'];
-                               $thismembers   = 
$group_info[$groupid]['members'];
+                               $thisacctid    = $group_info[$groupid]['id'];
+                               $thisacctlid   = $group_info[$groupid]['lid'];
+                               $thisfirstname = 
$group_info[$groupid]['firstname'];
+                               $thislastname  = 
$group_info[$groupid]['lastname'];
+               //              $thismembers   = 
$group_info[$groupid]['members'];
+                               $thisperson    = 
$group_info[$groupid]['person_id'];
 
                                // Do some checks before we try to import the 
data to LDAP.
                                if(!empty($thisacctid) && !empty($thisacctlid))
                                {
-                                       $groups = 
CreateObject('phpgwapi.accounts',intval($thisacctid));
-                                       $groups->db = 
$GLOBALS['phpgw_setup']->db;
-
+                               //      $groups->set_account($thisacctid, 'g');
                                        // Check if the account is already 
there.
                                        // If so, we won't try to create it 
again.
-                                       $acct_exist = 
$acct->groupName2id($thisacctlid);
+                                       $acct_exist = 
$groups->name2id($thisacctlid);
                                        if($acct_exist)
                                        {
                                                $thisacctid = $acct_exist;
                                        }
-                                       $id_exist = 
$groups->group_exists(intval($thisacctid));
+                                       $id_exist = 
$groups->exists(intval($thisacctid));
                                        
                                        /*
                                        echo '<br />accountid: ' . $thisacctid;
@@ -182,18 +192,20 @@
                                        if(!$id_exist)
                                        {
                                                echo "<br />\nAdding Group:  
$thisacctlid (gid: $thisacctid)";
-                                               $groups->create(
-                                                       array(
-                                                               'account_type'  
    => 'g',
-                                                               'account_id'    
    => $thisacctid,
-                                                               'account_lid'   
    => $thisacctlid,
-                                                               
'account_passwd'    => 'x',
-                                                               
'account_firstname' => $thisfirstname,
-                                                               
'account_lastname'  => $thislastname,
-                                                               
'account_status'    => 'A',
-                                                               
'account_expires'   => -1
-                                                       )
+                                               $thisgroup_info = array
+                                               (
+                                                               'type'      => 
'g',
+                                                               'id'        => 
$thisacctid,
+                                                               'lid'       => 
$thisacctlid,
+                                               //              'passwd'    => 
'x',
+                                                               'firstname' => 
$thisfirstname,
+                                                               'lastname'  => 
$thislastname,
+                                                               'status'    => 
'A',
+                                                               'expires'   => 
-1,
+                                                               'person_id' => 
$thisperson
                                                );
+
+                                               add_account($thisgroup_info, 
'g');
                                        }
                                        else
                                        {
@@ -203,21 +215,22 @@
                        }
                }
 
-               if($_POST['users'] && is_array($_POST['users']))
+               if(isset($_POST['users']) && $_POST['users'] && 
is_array($_POST['users']))
                {
+                       $accounts = CreateObject('phpgwapi.accounts');
                        foreach($_POST['users'] as $key => $accountid)
                        {
                                $id_exist = 0; $acct_exist = 0;
-                               $thisacctid    = 
$account_info[$accountid]['account_id'];
-                               $thisacctlid   = 
$account_info[$accountid]['account_lid'];
-                               $thisfirstname = 
$account_info[$accountid]['account_firstname'];
-                               $thislastname  = 
$account_info[$accountid]['account_lastname'];
+                               $thisacctid    = 
$account_info[$accountid]['id'];
+                               $thisacctlid   = 
$account_info[$accountid]['lid'];
+                               $thisfirstname = 
$account_info[$accountid]['firstname'];
+                               $thislastname  = 
$account_info[$accountid]['lastname'];
+                               $thisperson    = 
$account_info[$accountid]['person_id'];                                
 
                                // Do some checks before we try to import the 
data.
                                if(!empty($thisacctid) && !empty($thisacctlid))
                                {
-                                       $accounts = 
CreateObject('phpgwapi.accounts',intval($thisacctid));
-                                       $accounts->db = 
$GLOBALS['phpgw_setup']->db;
+                                       $accounts->set_account($thisacctid, 
'u');
 
                                        // Check if the account is already 
there.
                                        // If so, we won't try to create it 
again.
@@ -226,28 +239,30 @@
                                        {
                                                $thisacctid = $acct_exist;
                                        }
-                                       /* create_account handles existing 
accounts
+
                                        $id_exist = 
$accounts->exists(intval($thisacctid));
-                                       */
+
                                        // If not, create it now.
-                                       if(!$id_exist)
+                                       if($id_exist)
                                        {
                                                echo "<br />\nAdding User: 
$thisacctlid (uid: $thisacctid)";
-                                               $accounts->create(
-                                                               array(
-                                                                       
'account_type'      => 'u',
-                                                                       
'account_id'        => $thisacctid,
-                                                                       
'account_lid'       => $thisacctlid,
-                                                                       
'account_passwd'    => 'x',
-                                                                       
'account_firstname' => $thisfirstname,
-                                                                       
'account_lastname'  => $thislastname,
-                                                                       
'account_status'    => 'A',
-                                                                       
'account_expires'   => -1,
-                                                                       
'homedirectory'     => $config['ldap_account_home'] 
-                                                                               
                . '/' . $thisacctlid,
-                                                                       
'loginshell'        => $config['ldap_account_shell']
-                                                               )
+                                               $thisaccount_info  = array
+                                               (
+                                                                       'type'  
    => 'u',
+                                                                       'id'    
    => $thisacctid,
+                                                                       'lid'   
    => $thisacctlid,
+                                                                       
'password'    => '12345678XXxx_&',
+                                                                       
'firstname' => $thisfirstname,
+                                                                       
'lastname'  => $thislastname,
+                                                                       
'status'    => 'A',
+                                                                       
'expires'   => -1,
+                                                                       
'person_id' => $thisperson
+                                                       //              
'homedirectory'     => $config['ldap_account_home'] 
+                                                       //                      
                . '/' . $thisacctlid,
+                                                       //              
'loginshell'        => $config['ldap_account_shell']
                                                );
+
+                                               add_account($thisaccount_info, 
'u');
                                        }
                                        else
                                        {
@@ -261,13 +276,13 @@
 
        $GLOBALS['phpgw_setup']->html->show_header('LDAP 
Export','','config',$ConfigDomain);
 
-       if($error)
+       if(isset($error) && $error)
        {
                //echo '<br /><center><b>Error:</b> '.$error.'</center>';
                $GLOBALS['phpgw_setup']->html->show_alert_msg('Error',$error);
        }
 
-       if($setup_complete)
+       if(isset($setup_complete) && $setup_complete)
        {
                echo '<br /><center>'.lang('Export has been completed!  You 
will need to set the user passwords manually.').'</center>';
                echo '<br /><center>'.lang('Click <a href="index.php">here</a> 
to return to setup.').'</center>';
@@ -283,25 +298,28 @@
        $setup_tpl->set_block('ldap','submit','submit');
        $setup_tpl->set_block('ldap','footer','footer');
 
+       $user_list = '';
        while(list($key,$account) = @each($account_info))
        {
-               $user_list .= '<option value="' . $account['account_id'] . '">'
-                       . 
$common->display_fullname($account['account_lid'],$account['account_firstname'],$account['account_lastname'])
+               $user_list .= '<option value="' . $account['id'] . '">'
+                       . 
$common->display_fullname($account['lid'],$account['firstname'],$account['lastname'])
                        . '</option>';
        }
 
        @reset($account_info);
+       $admin_list = '';
        while(list($key,$account) = @each($account_info))
        {
-               $admin_list .= '<option value="' . $account['account_id'] . '">'
-                       . 
$common->display_fullname($account['account_lid'],$account['account_firstname'],$account['account_lastname'])
+               $admin_list .= '<option value="' . $account['id'] . '">'
+                       . 
$common->display_fullname($account['lid'],$account['firstname'],$account['lastname'])
                        . '</option>';
        }
 
+       $group_list = '';
        while(list($key,$group) = @each($group_info))
        {
-               $group_list .= '<option value="' . $group['account_id'] . '">'
-                       . $group['account_lid']
+               $group_list .= '<option value="' . $group['id'] . '">'
+                       . $group['lid']
                        . '</option>';
        }
 
@@ -309,7 +327,7 @@
        $setup_tpl->set_var('users',$user_list);
        $setup_tpl->set_var('admins',$admin_list);
        $setup_tpl->set_var('ldapgroups',$group_list);
-       $setup_tpl->set_var('s_apps',$app_list);
+//     $setup_tpl->set_var('s_apps',$app_list);
 
        $setup_tpl->set_var('ldap_import',lang('LDAP export users'));
        $setup_tpl->set_var('description',lang("This section will help you 
export users and groups from phpGroupWare's account tables into your LDAP 
tree").'.');

Modified: people/sigurdne/modules/setup/trunk/ldapimport.php
===================================================================
--- people/sigurdne/modules/setup/trunk/ldapimport.php  2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/ldapimport.php  2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -2,19 +2,18 @@
        /**
        * Setup
        *
-       * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @copyright Copyright (C) 2000-2009 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package setup
        * @version $Id$
        */
 
-       $GLOBALS['phpgw_info'] = array();
        $GLOBALS['phpgw_info']['flags'] = array
        (
-               'noheader'   => True,
-               'nonavbar'   => True,
+               'noheader'   => true,
+               'nonavbar'   => true,
                'currentapp' => 'home',
-               'noapi'      => True
+               'noapi'      => true
        );
        
        /**
@@ -30,59 +29,51 @@
        }
        // Does not return unless user is authorized
 
-       /**
-       * phpGroupWare class
-       * @package setup
-       * @ignore
-       */
-       class phpgw
-       {
-               /**
-                * Common
-                * @var object
-                */
-               var $common;
                
                /**
-                * Accounts
-                * @var object
+        * Add account
+        * 
+        * @param array  $acct    Account name and other information to use
+        * @param string $type    Account type: u = user | g = group
+        * @param array  $groups  Groups to add account to
+        * @param array  $modules Modules to grant account access to
+        * @param array  $acls    ACLs to set for account
+        *
+        * @return integer Account ID
                 */
-               var $accounts;
+       function add_account($acct, $type, $groups = array(), $modules = 
array(), $acls = array())
+       {
+               $person_id = 0;
+               if ( $type == 'u' )
+               {
+                       $account                        = new phpgwapi_user();
+                       $account->id            = $acct['id'];
+                       $account->lid           = $acct['lid'];
+                       $account->firstname     = $acct['firstname'];
+                       $account->lastname      = $acct['lastname'];
+                       $account->passwd        = $acct['password'];
+                       $account->enabled       = true;
+                       $account->expires       = -1;
+               }
+               else
+               {
+                       $account                        = new phpgwapi_group();
+                       $account->id            = $acct['id'];
+                       $account->lid           = $acct['lid'];
+                       $account->firstname = ucfirst($acct['lid']);
+               }
                
-               /**
-                * Applications
-                * @var object
-                */
-               var $applications;
-               
-               /**
-                * Database
-                * @var object
-                */
-               var $db;
-               
-               /**
-                * Hooks
-                * @var object
-                */
-               var $hooks;
-               
-               /**
-                * Access control list
-                * @var object
-                */
-               var $acl;
+               return $GLOBALS['phpgw']->accounts->create($account, $groups, 
$acls, $modules);
        }
-       $GLOBALS['phpgw'] = new phpgw;
-       $GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
 
+
+       $GLOBALS['phpgw_info']['server']['account_repository'] = 'sql'; // 
importing into sql repository
        $common = $GLOBALS['phpgw']->common;
        $GLOBALS['phpgw_setup']->loaddb();
        $GLOBALS['phpgw']->db = $GLOBALS['phpgw_setup']->db;
        $GLOBALS['phpgw']->hooks = createObject('phpgwapi.hooks');
        
        $GLOBALS['phpgw']->acl = createObject('phpgwapi.acl');
-       $GLOBALS['phpgw']->acl->db = $GLOBALS['phpgw_setup']->db;
 
        $tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
        $setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
@@ -99,7 +90,17 @@
        $GLOBALS['phpgw']->applications = CreateObject('phpgwapi.applications');
        $applications        = $GLOBALS['phpgw']->applications;
 
-       $GLOBALS['phpgw_setup']->db->query("SELECT config_name,config_value 
FROM phpgw_config WHERE config_name LIKE 'ldap%' OR 
config_name='account_repository'",__LINE__,__FILE__);
+       $sql = "SELECT config_name,config_value FROM phpgw_config"
+               . " WHERE config_name LIKE 'ldap%'"
+               . " OR config_name='account_repository'"
+               . " OR config_name='account_min_id'"
+               . " OR config_name='account_max_id'"
+               . " OR config_name='group_min_id'"
+               . " OR config_name='group_max_id'"
+               . " OR config_name='encryption_type'";
+
+       $GLOBALS['phpgw_setup']->db->query($sql, __LINE__,__FILE__);
+
        while ($GLOBALS['phpgw_setup']->db->next_record())
        {
                $config[$GLOBALS['phpgw_setup']->db->f('config_name')] = 
$GLOBALS['phpgw_setup']->db->f('config_value');
@@ -109,8 +110,15 @@
        $GLOBALS['phpgw_info']['server']['ldap_group_context'] = 
$config['ldap_group_context'];
        $GLOBALS['phpgw_info']['server']['ldap_root_dn']       = 
$config['ldap_root_dn'];
        $GLOBALS['phpgw_info']['server']['ldap_root_pw']       = 
$config['ldap_root_pw'];
-       $GLOBALS['phpgw_info']['server']['account_repository'] = 
$config['account_repository'];
+       $GLOBALS['phpgw_info']['server']['account_min_id']     = 
$config['account_min_id'];
+       $GLOBALS['phpgw_info']['server']['account_max_id']     = 
$config['account_max_id'];
+       $GLOBALS['phpgw_info']['server']['group_min_id']       = 
$config['group_min_id'];
+       $GLOBALS['phpgw_info']['server']['group_max_id']       = 
$config['group_max_id'];
+       $GLOBALS['phpgw_info']['server']['encryption_type']    = 
$config['encryption_type'];
+       $GLOBALS['phpgw_info']['server']['password_level']     = '8CHAR';
 
+       //$GLOBALS['phpgw_info']['server']['account_repository'] = 
$config['account_repository'];
+
        $GLOBALS['phpgw']->accounts = CreateObject('phpgwapi.accounts');
        $acct = $GLOBALS['phpgw']->accounts;
 
@@ -120,55 +128,52 @@
        // connect to ldap server
        if (! $ldap = $common->ldapConnect())
        {
-               $noldapconnection = True;
-       }
-
-       if ($noldapconnection)
-       {
                Header('Location: config.php?error=badldapconnection');
                exit;
        }
 
        $sr = 
ldap_search($ldap,$config['ldap_context'],'(|(uid=*))',array('sn','givenname','uid','uidnumber'));
        $info = ldap_get_entries($ldap, $sr);
+
        $tmp = '';
+       phpgw::import_class('phpgwapi.globally_denied');
 
+       $account_info = array();
        for ($i=0; $i<$info['count']; ++$i)
        {
-               if (! 
$GLOBALS['phpgw_info']['server']['global_denied_users'][$info[$i]['uid'][0]])
+               if (! phpgwapi_globally_denied::user($info[$i]['uid'][0]) )
                {
                        $tmp = $info[$i]['uidnumber'][0];
-                       $account_info[$tmp]['account_id']        = 
$info[$i]['uidnumber'][0];
-                       $account_info[$tmp]['account_lid']       = 
$info[$i]['uid'][0];
-                       $account_info[$tmp]['account_firstname'] = 
$info[$i]['givenname'][0];
-                       $account_info[$tmp]['account_lastname']  = 
$info[$i]['sn'][0];
-                       $account_info[$tmp]['account_passwd']    = 
$info[$i]['userpassword'][0];
+                       $account_info[$tmp]['id']        = 
$info[$i]['uidnumber'][0];
+                       $account_info[$tmp]['lid']       = $info[$i]['uid'][0];
+                       $account_info[$tmp]['firstname'] = 
$info[$i]['givenname'][0];
+                       $account_info[$tmp]['lastname']  = $info[$i]['sn'][0];
+                       $account_info[$tmp]['password']    = 
isset($info[$i]['userpassword'][0]) ? $info[$i]['userpassword'][0] : '';
+                       //echo 'password?';
                }
        }
 
+       $group_info = array();
        if ($GLOBALS['phpgw_info']['server']['ldap_group_context'])
        {
                $srg = 
ldap_search($ldap,$config['ldap_group_context'],'(|(cn=*))',array('gidnumber','cn','memberuid'));
                $info = ldap_get_entries($ldap, $srg);
+
                $tmp = '';
-
                for ($i=0; $i<$info['count']; ++$i)
                {
-                       if (! 
$GLOBALS['phpgw_info']['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
-                               ! $account_info[$i][$info[$i]['cn'][0]])
+                       if ( isset($info[$i]['cn'][0])
+                                &&  ! 
phpgwapi_globally_denied::user($info[$i]['cn'][0]) 
+                                &&      ( 
!isset($account_info[$i][$info[$i]['cn'][0]]) || ! 
$account_info[$i][$info[$i]['cn'][0]]) )
                        {
                                $tmp = $info[$i]['gidnumber'][0];
-                               $group_info[$tmp]['account_id']        = 
$info[$i]['gidnumber'][0];
-                               $group_info[$tmp]['account_lid']       = 
$info[$i]['cn'][0];
+                               $group_info[$tmp]['id']                         
= $info[$i]['gidnumber'][0];
+                               $group_info[$tmp]['lid']                        
= $info[$i]['cn'][0];
                                $group_info[$tmp]['members']           = 
$info[$i]['memberuid'];
-                               $group_info[$tmp]['account_firstname'] = 
$info[$i]['cn'][0];
-                               $group_info[$tmp]['account_lastname']  = 
'Group';
-                       }
+                               $group_info[$tmp]['firstname']          = 
$info[$i]['cn'][0];
+                               $group_info[$tmp]['lastname']           = 
'Group';
                }
        }
-       else
-       {
-               $group_info = array();
        }
 
        $GLOBALS['phpgw_setup']->db->query("SELECT app_name FROM 
phpgw_applications WHERE app_enabled!='0' AND app_enabled!='3' ORDER BY 
app_name",__LINE__,__FILE__);
@@ -177,13 +182,13 @@
                $apps[$GLOBALS['phpgw_setup']->db->f('app_name')] = 
lang($GLOBALS['phpgw_setup']->db->f('app_name'));
        }
 
-       if ($_POST['cancel'])
+       if (isset($_POST['cancel']) && $_POST['cancel'])
        {
                Header("Location: ldap.php");
                exit;
        }
 
-       if ($_POST['submit'])
+       if (isset($_POST['submit']) && $_POST['submit'])
        {
                if (! @count($_POST['admins']) )
                {
@@ -195,24 +200,35 @@
                        $error .= '<br />You must select at least 1 
application';
                }
 
-               if (!$error)
+               if (!isset($error) || !$error)
                {
-                       if ( isset($_POST['ldapgroups']) && 
count($_POST['ldapgroups']) )
+                       if ( $ldapgroups =  phpgw::get_var('ldapgroups', '', 
'POST') )
                        {
+                               $modules = array
+                               (
+                                       'addressbook',
+                                       'calendar',
+                                       'email',
+                                       'filemanager',
+                                       'manual',
+                                       'preferences',
+                                       'notes',
+                                       'todo'
+                               );
+
                                foreach($ldapgroups as $key => $groupid)
                                {
                                        $id_exist = 0;
-                                       $thisacctid    = 
$group_info[$groupid]['account_id'];
-                                       $thisacctlid   = 
$group_info[$groupid]['account_lid'];
-                                       $thisfirstname = 
$group_info[$groupid]['account_firstname'];
-                                       $thislastname  = 
$group_info[$groupid]['account_lastname'];
+                                       $thisacctid    = 
$group_info[$groupid]['id'];
+                                       $thisacctlid   = 
$group_info[$groupid]['lid'];
+                                       $thisfirstname = 
$group_info[$groupid]['firstname'];
+                                       $thislastname  = 
$group_info[$groupid]['lastname'];
                                        $thismembers   = 
$group_info[$groupid]['members'];
 
                                        // Do some checks before we try to 
import the data.
-                                       if (!empty($thisacctid) && 
!empty($thisacctlid))
+                                       if ($thisacctid > 0  && 
!empty($thisacctlid))
                                        {
                                                $groups = 
CreateObject('phpgwapi.accounts',intval($thisacctid));
-                                               $groups->db = 
$GLOBALS['phpgw_setup']->db;
        
                                                // Check if the account is 
already there.
                                                // If so, we won't try to 
create it again.
@@ -227,16 +243,18 @@
                                                if(!$id_exist)
                                                {
                                                        $thisgroup_info = array(
-                                                               'account_type'  
    => 'g',
-                                                               'account_lid'   
    => $thisacctlid,
-                                                               
'account_passwd'    => $passwd,
-                                                               
'account_firstname' => $thisfirstname,
-                                                               
'account_lastname'  => $thislastname,
-                                                               
'account_status'    => 'A',
-                                                               
'account_expires'   => -1
+                                                               'type'      => 
'g',
+                                                               'id'            
=> $thisacctid,
+                                                               'lid'       => 
$thisacctlid,
+                                       //                      'passwd'    => 
$passwd,
+                                                               'firstname' => 
$thisfirstname,
+                                                               'lastname'  => 
$thislastname,
+                                                               'status'    => 
'A',
+                                                               'expires'   => 
-1
                                                        );
-                                                       
$groups->create($thisgroup_info);
-                                                       $thisacctid = 
$acct->name2id($thisacctlid);
+
+                                                       
add_account($thisgroup_info, 'g', array(), $modules);
+                                       //              $thisacctid = 
$acct->name2id($thisacctlid);
                                                }
 
                                                // Now make them a member of 
this group in phpgw.
@@ -264,14 +282,10 @@
                                                        */
                                                        if($tmpid)
                                                        {
-                                                               
$GLOBALS['phpgw']->acl->acl($tmpid);
-                                                               
$GLOBALS['phpgw']->acl->read();
+                                                               
$acct->add_user2group($tmpid, $thisacctid);
 
-                                                               
$GLOBALS['phpgw']->acl->delete('phpgw_group',$thisacctid,1);
-                                                               
$GLOBALS['phpgw']->acl->add('phpgw_group',$thisacctid,1);
-
+                                                               
$GLOBALS['phpgw']->acl->set_account_id($tmpid);
                                                                /* Now add the 
acl to let them change their password */
-                                                               
$GLOBALS['phpgw']->acl->delete('preferences','changepassword',1);
                                                                
$GLOBALS['phpgw']->acl->add('preferences','changepassword',1);
 
                                                                
$GLOBALS['phpgw']->acl->save_repository();
@@ -280,8 +294,7 @@
                                                                        App 
access is added below.
                                                                */
                                                                $pref = 
CreateObject('phpgwapi.preferences',$tmpid);
-                                                               $pref->db = 
$GLOBALS['phpgw_setup']->db;
-                                                               
$pref->account_id = intval($tmpid);
+                                                               
$pref->set_account_id(intval($tmpid));
                                                                $pref->read();
                                                                
@reset($_POST['s_apps']);
                                                                while 
(list($key,$app) = each($_POST['s_apps']))
@@ -292,15 +305,13 @@
                                                        }
                                                }
                                                /* Now give this group some 
rights */
-                                               
$GLOBALS['phpgw']->acl->acl($thisacctid);
-                                               $GLOBALS['phpgw']->acl->read();
+                                               
$GLOBALS['phpgw']->acl->set_account_id($thisacctid);
                                                @reset($_POST['s_apps']);
                                                while (list($key,$app) = 
each($_POST['s_apps']))
                                                {
-                                                       
$GLOBALS['phpgw']->acl->delete($app,'run',1);
                                                        
$GLOBALS['phpgw']->acl->add($app,'run',1);
                                                }
-                                               
$acl->add('preferences','changepassword', 1);
+                                               
$GLOBALS['phpgw']->acl->add('preferences','changepassword', 1);
                                                
$GLOBALS['phpgw']->acl->save_repository();
                                                $defaultgroupid = $thisacctid;
                                        }
@@ -308,9 +319,9 @@
                        }
                        else
                        {
+                               $acls = array();
                                /* Create the 'Default' group */
                                $groups = 
CreateObject('phpgwapi.accounts',$defaultgroupid);
-                               $groups->db = $GLOBALS['phpgw_setup']->db;
 
                                // Check if the group account is already there.
                                // If so, set our group_id to that account's id 
for use below.
@@ -325,30 +336,25 @@
                                {
                                        $groups->delete($defaultgroupid);
                                }
-                               $thisgroup_info = array
-                               (
-                                       'account_type'      => 'g',
-                                       'account_lid'       => 'Default',
-                                       'account_passwd'    => $passwd,
-                                       'account_firstname' => 'Default',
-                                       'account_lastname'  => 'Group',
-                                       'account_status'    => 'A',
-                                       'account_expires'   => -1
-                               );
-                               $acct->create($thisgroup_info);
 
-                               $defaultgroupid = $acct->name2id('Default');
-
-                               $acl = 
CreateObject('phpgwapi.acl',$defaultgroupid);
-                               $acl->db = $GLOBALS['phpgw_setup']->db;
-                               $acl->set_account_id(intval($defaultgroupid));
                                foreach ( $_POST['s_apps'] as $app )
                                {
-                                       $acl->delete($app,'run',1);
-                                       $acl->add($app,'run',1);
+                                       $acls[] = array
+                                       (
+                                               'appname'       => $app,
+                                               'location'      => 'run',
+                                               'rights'        => 1
+                                       );
                                }
-                               $acl->add('preferences','changepassword', 1);
-                               $acl->save_repository();
+                               $acls[] = array
+                               (
+                                       'appname'       => 'preferences',
+                                       'location'      => 'changepassword',
+                                       'rights'        => 1
+                               );
+               
+                               add_account(array('username' => 'default'), 
'g', array(), $modules, $acls);
+
                        } //end default group creation
                }
 
@@ -356,18 +362,18 @@
                {
                        foreach($_POST['users'] as $key => $id)
                        {
+                               $acls = array();
                                $id_exist = 0;
-                               $thisacctid    = 
$account_info[$id]['account_id'];
-                               $thisacctlid   = 
$account_info[$id]['account_lid'];
-                               $thisfirstname = 
$account_info[$id]['account_firstname'];
-                               $thislastname  = 
$account_info[$id]['account_lastname'];
-                               $thispasswd    = 
$account_info[$id]['account_passwd'];
+                               $thisacctid    = $account_info[$id]['id'];
+                               $thisacctlid   = $account_info[$id]['lid'];
+                               $thisfirstname = 
$account_info[$id]['firstname'];
+                               $thislastname  = $account_info[$id]['lastname'];
+                               $thispasswd    = $account_info[$id]['password'];
 
                                // Do some checks before we try to import the 
data.
                                if (!empty($thisacctid) && !empty($thisacctlid) 
)
                                {
                                        $accounts = 
CreateObject('phpgwapi.accounts',intval($thisacctid));
-                                       $accounts->db = 
$GLOBALS['phpgw_setup']->db;
 
                                        // Check if the account is already 
there.
                                        // If so, we won't try to create it 
again.
@@ -381,36 +387,39 @@
                                        if(!$id_exist)
                                        {
                                                $thisaccount_info = array(
-                                                       'account_type'      => 
'u',
-                                                       'account_lid'       => 
$thisacctlid,
-                                                       'account_passwd'    => 
'x',
+                                                       'type'      => 'u',
+                                                       'id'            => 
$thisacctid,
+                                                       'lid'       => 
$thisacctlid,
+                                                       'password'  => 
'xxxxxxxx',
                                                /*      'account_passwd'    => 
$thispasswd, */
-                                                       'account_firstname' => 
$thisfirstname,
-                                                       'account_lastname'  => 
$thislastname,
-                                                       'account_status'    => 
'A',
-                                                       'account_expires'   => 
-1
+                                                       'firstname' => 
$thisfirstname,
+                                                       'lastname'  => 
$thislastname,
+                                                       'status'    => 'A',
+                                                       'expires'   => -1
                                                );
-                                               
$accounts->create($thisaccount_info);
-                                               $thisacctid = 
$acct->name2id($thisacctlid);
                                        }
 
                                        // Insert default acls for this user.
                                        // Since the group has app rights, we 
don't need to give users
                                        //  these rights.  Instead, we make the 
user a member of the Default group
                                        //  below.
-                                       
$GLOBALS['phpgw']->acl->acl($thisacctid);
-                                       $GLOBALS['phpgw']->acl->read();
 
                                        // Only give them admin if we asked for 
them to have it.
                                        // This is typically an exception to 
apps for run rights
                                        //  as a group member.
-                                       $cnt_admins = count($_POST['admins']);
+                                       $admins =  phpgw::get_var('admins', '', 
'POST');
+                                       $cnt_admins = count($admins);
+
                                        for ($a = 0; $a < $cnt_admins; ++$a)
                                        {
                                                if ($admins[$a] == $thisacctlid)
                                                {
-                                                       
$GLOBALS['phpgw']->acl->delete('admin','run',1);
-                                                       
$GLOBALS['phpgw']->acl->add('admin','run',1);
+                                                       $acls[] = array
+                                                       (
+                                                               'appname'       
=> 'admin',
+                                                               'location'      
=> 'run',
+                                                               'rights'        
=> 1
+                                                       );
                                                }
                                        }
 
@@ -423,27 +432,28 @@
 
                                        if($defaultgroupid)
                                        {
-                                               
$GLOBALS['phpgw']->acl->delete('phpgw_group',$defaultgroupid,1);
-                                               
$GLOBALS['phpgw']->acl->add('phpgw_group',$defaultgroupid,1);
+                                               $groups = 
array($defaultgroupid);
                                        }
-
+                                       if(!$id_exist)
+                                       {
+                                               $thisacctid = 
add_account($thisaccount_info, 'u', $groups, array('admin'), $acls);
+                                       }
                                        // Save these new acls.
-                                       
$GLOBALS['phpgw']->acl->save_repository();
                                }
                        }
                }
-               $setup_complete = True;
+               $setup_complete = true;
        }
 
        $GLOBALS['phpgw_setup']->html->show_header('LDAP 
Import','','config',$_COOKIE['ConfigDomain']);
 
-       if ($error)
+       if (isset($error) && $error)
        {
                //echo '<br /><center><b>Error:</b> '.$error.'</center>';
                $GLOBALS['phpgw_setup']->html->show_alert_msg('Error',$error);
        }
 
-       if ($setup_complete)
+       if (isset($setup_complete) && $setup_complete)
        {
                echo '<br /><center>'.lang('Import has been completed!').' 
'.lang('Click <a href="index.php">here</a> to return to setup.').'</center>';
                $GLOBALS['phpgw_setup']->html->show_footer();
@@ -458,28 +468,32 @@
        $setup_tpl->set_block('ldap','submit','submit');
        $setup_tpl->set_block('ldap','footer','footer');
 
+       $user_list = '';
        while (list($key,$account) = each($account_info))
        {
-               $user_list .= '<option value="' . $account['account_id'] . '">'
-                       . 
$common->display_fullname($account['account_lid'],$account['account_firstname'],$account['account_lastname'])
+               $user_list .= '<option value="' . $account['id'] . '">'
+                       . 
$common->display_fullname($account['lid'],$account['firstname'],$account['lastname'])
                        . '</option>';
        }
 
        @reset($account_info);
+       $admin_list = '';
        while (list($key,$account) = each($account_info))
        {
-               $admin_list .= '<option value="' . $account['account_lid'] . 
'">'
-                       . 
$common->display_fullname($account['account_lid'],$account['account_firstname'],$account['account_lastname'])
+               $admin_list .= '<option value="' . $account['lid'] . '">'
+                       . 
$common->display_fullname($account['lid'],$account['firstname'],$account['lastname'])
                        . '</option>';
        }
 
+       $group_list = '';
        while (list($key,$group) = each($group_info))
        {
-               $group_list .= '<option value="' . $group['account_id'] . '">'
-                       . $group['account_lid']
+               $group_list .= '<option value="' . $group['id'] . '">'
+                       . $group['lid']
                        . '</option>';
        }
 
+       $app_list = '';
        while(list($appname,$apptitle) = each($apps))
        {
                if($appname == 'admin' ||

Modified: people/sigurdne/modules/setup/trunk/ldapmodify.php
===================================================================
--- people/sigurdne/modules/setup/trunk/ldapmodify.php  2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/ldapmodify.php  2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -2,18 +2,18 @@
        /**
        * Setup
        *
-       * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc. 
http://www.fsf.org/
+       * @copyright Copyright (C) 2000-2009 Free Software Foundation, Inc. 
http://www.fsf.org/
        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
        * @package setup
        * @version $Id$
        */
 
-       $GLOBALS['phpgw_info'] = array();
-       $GLOBALS['phpgw_info']['flags'] = array(
-                       'noheader'   => True,
-                       'nonavbar'   => True,
+       $GLOBALS['phpgw_info']['flags'] = array
+       (
+               'noheader'   => true,
+               'nonavbar'   => true,
                        'currentapp' => 'home',
-                       'noapi'      => True
+               'noapi'      => true
                );
 
        /**
@@ -35,34 +35,6 @@
        * @package setup
        * @ignore
        */
-       class phpgw
-       {
-               /**
-                * Common
-                * @var object
-                */
-               var $common;
-               
-               /**
-                * Accounts
-                * @var object
-                */
-               var $accounts;
-               
-               /**
-                * Applications
-                * @var object
-                */
-               var $applications;
-               
-               /**
-                * Database
-                * @var object
-                */
-               var $db;
-       }
-       $GLOBALS['phpgw'] = new phpgw;
-       $GLOBALS['phpgw']->common = CreateObject('phpgwapi.common');
 
        $common =& $GLOBALS['phpgw']->common;
        $GLOBALS['phpgw_setup']->loaddb();
@@ -94,10 +66,10 @@
        // connect to ldap server
        if (! $ldap = $common->ldapConnect())
        {
-               $noldapconnection = True;
+               $noldapconnection = true;
        }
 
-       if ($noldapconnection)
+       if (isset($noldapconnection))
        {
                Header('Location: config.php?error=badldapconnection');
                exit;
@@ -109,7 +81,7 @@
 
        for ($i=0; $i<$info['count']; ++$i)
        {
-               if (! 
$GLOBALS['phpgw_info']['server']['global_denied_users'][$info[$i]['uid'][0]])
+               if 
(!isset($GLOBALS['phpgw_info']['server']['global_denied_users'][$info[$i]['uid'][0]])
 || 
!$GLOBALS['phpgw_info']['server']['global_denied_users'][$info[$i]['uid'][0]])
                {
                        $account_info[$info[$i]['uidnumber'][0]] = $info[$i];
                }
@@ -123,8 +95,8 @@
 
                for ($i=0; $i<$info['count']; ++$i)
                {
-                       if (! 
$GLOBALS['phpgw_info']['server']['global_denied_groups'][$info[$i]['cn'][0]] &&
-                               ! $account_info[$i][$info[$i]['cn'][0]])
+                       if 
((!isset($GLOBALS['phpgw_info']['server']['global_denied_groups'][$info[$i]['cn'][0]])
 || 
!$GLOBALS['phpgw_info']['server']['global_denied_groups'][$info[$i]['cn'][0]]) 
&&
+                               (!isset($account_info[$i][$info[$i]['cn'][0]]) 
|| !$account_info[$i][$info[$i]['cn'][0]]))
                        {
                                $group_info[$info[$i]['gidnumber'][0]] = 
$info[$i];
                        }
@@ -151,14 +123,12 @@
 
        $GLOBALS['phpgw_setup']->html->show_header('LDAP 
Modify','','config',$ConfigDomain);
 
-       if ($_POST['submit'])
+       if (isset($_POST['submit']) && $_POST['submit'])
        {
                $acl = CreateObject('phpgwapi.acl');
-               $acl->db = $GLOBALS['phpgw_setup']->db;
                if ( isset($_POST['ldapgroups']) && count($_POST['ldapgroups']) 
)
                {
                        $groups = CreateObject('phpgwapi.accounts');
-                       $groups->db = $GLOBALS['phpgw_setup']->db;
                        foreach($_POST['ldapgroups'] as $key => $groupid)
                        {
                                $id_exist = 0;
@@ -173,7 +143,7 @@
                                // Do some checks before we try to import the 
data.
                                if (!empty($thisacctid) && !empty($thisacctlid))
                                {
-                                       $groups->account_id = 
intval($thisacctid);
+                                       
$groups->set_account(intval($thisacctid));
 
                                        $sr = 
ldap_search($ldap,$config['ldap_group_context'],'cn='.$thisacctlid);
                                        $entry = ldap_get_entries($ldap, $sr);
@@ -197,8 +167,7 @@
 
                                                // We add this here as it is 
mandatory
                                                $replace['phpgwGroupID'] = 
$thisacctlid;
-
-                                               $ok = 
ldap_mod_replace($ldap,$thisdn,$replace);
+                                               $ok = 
@ldap_mod_replace($ldap,$thisdn,$replace);
                                                if (!$ok) // give user some 
feedback
                                                {
                                                        echo lang('failed to 
modify: %1', $thisdn) . '<br />';
@@ -263,7 +232,7 @@
                if( isset($_POST['users']) && count($_POST['users']) )
                {
                        $accounts = CreateObject('phpgwapi.accounts');
-                       $accounts->db = $GLOBALS['phpgw_setup']->db;
+               //      $accounts->db = $GLOBALS['phpgw_setup']->db;
                        foreach($_POST['users'] as $key => $id)
                        {
                                $id_exist = 0;
@@ -275,7 +244,7 @@
                                /* Do some checks before we try to import the 
data. */
                                if (!empty($thisacctid) && !empty($thisacctlid))
                                {
-                                       $accounts->account_id = 
intval($thisacctid);
+                                       
$accounts->set_account(intval($thisacctid));
                                        $sr = 
ldap_search($ldap,$config['ldap_context'],'uid='.$thisacctlid);
                                        $entry = ldap_get_entries($ldap, $sr);
                                        reset($entry[0]['objectclass']);
@@ -358,6 +327,8 @@
                                        This is typically an exception to apps 
for run rights
                                        as a group member.
                                        */
+                                       if(isset($admins) && is_array($admins)) 
// Sigurd: don't seems to defined at all
+                                       {
                                        for ($a=0; $a < count($admins); ++$a)
                                        {
                                                if ($admins[$a] == $thisacctid)
@@ -366,6 +337,7 @@
                                                        
$acl->add('admin','run',1);
                                                }
                                        }
+                                       }
                                        /* Save these new acls. */
                                        $acl->save_repository();
                                }
@@ -374,13 +346,13 @@
                $setup_complete = True;
        }
 
-       if ($error)
+       if (isset($error) && $error)
        {
                /* echo '<br /><center><b>Error:</b> '.$error.'</center>'; */
                $GLOBALS['phpgw_setup']->html->show_alert_msg('Error',$error);
        }
 
-       if ($setup_complete)
+       if (isset($setup_complete) && $setup_complete)
        {
                echo '<br /><center>'.lang('Modifications have been 
completed!').' '.lang('Click <a href="index.php">here</a> to return to 
setup.').'<br /><center>';
                $GLOBALS['phpgw_setup']->html->show_footer();
@@ -395,22 +367,26 @@
        $setup_tpl->set_block('ldap','submit','submit');
        $setup_tpl->set_block('ldap','footer','footer');
 
+       $user_list = '';
        while (list($key,$account) = @each($account_info))
        {
                $user_list .= '<option value="' . $account['uidnumber'][0] . 
'">' . $account['cn'][0] . '(' . $account['uid'][0] . ')</option>';
        }
 
        @reset($account_info);
+       $admin_list = '';
        while (list($key,$account) = @each($account_info))
        {
                $admin_list .= '<option value="' . $account['uidnumber'][0] . 
'">' . $account['cn'][0] . '(' . $account['uid'][0] . ')</option>';
        }
 
+       $group_list = '';
        while (list($key,$group) = @each($group_info))
        {
                $group_list .= '<option value="' . $group['gidnumber'][0] . 
'">' . $group['cn'][0]  . '</option>';
        }
 
+       $app_list = '';
        while(list($appname,$apptitle) = each($apps)) // TODO: IMHO This needs 
to go - skwashd Jul-04
        {
                if($appname == 'admin' ||

Modified: people/sigurdne/modules/setup/trunk/manageheader.php
===================================================================
--- people/sigurdne/modules/setup/trunk/manageheader.php        2009-11-20 
10:29:01 UTC (rev 20848)
+++ people/sigurdne/modules/setup/trunk/manageheader.php        2009-11-20 
10:29:14 UTC (rev 20849)
@@ -18,23 +18,37 @@
                'noapi'                         => true
        );
        
-       // These are the system wide defaults, which will be overwritten below 
if the user has a valid config
-       // This is the best way to prevent notices - skwashd jan08
-       $GLOBALS['phpgw_info']['server']['server_root'] = realpath('../'); 
//'/path/to/phpgroupware';
-       $GLOBALS['phpgw_info']['server']['include_root'] = realpath('../');
-       $GLOBALS['phpgw_info']['server']['header_admin_password'] = '';
-       $GLOBALS['phpgw_info']['server']['sessions_type'] = 'php';
-       $GLOBALS['phpgw_info']['server']['db_persistent'] = false;
-       $GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = false;
-       $GLOBALS['phpgw_info']['server']['versions']['mcrypt'] = '';
-       $GLOBALS['phpgw_info']['server']['domain_from_host'] = false;
-       $GLOBALS['phpgw_info']['server']['show_domain_selectbox'] = false;
-       
        /**
         * Include setup functions
         */
        require_once('./inc/functions.inc.php');
 
+       srand((double)microtime()*1000000);
+       $random_char = array(
+               '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
+               'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
+               'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
+               'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
+       );
+
+       if(!isset($GLOBALS['phpgw_info']['server']['mcrypt_iv']) || 
!$GLOBALS['phpgw_info']['server']['mcrypt_iv'])
+       {
+               $GLOBALS['phpgw_info']['server']['mcrypt_iv'] = '';
+               for($i=0; $i < 30; ++$i)
+               {
+                       $GLOBALS['phpgw_info']['server']['mcrypt_iv'] .= 
$random_char[rand(0,count($random_char)-1)];
+               }
+       }
+
+       if(!isset($GLOBALS['phpgw_info']['server']['setup_mcrypt_key']) || 
!$GLOBALS['phpgw_info']['server']['setup_mcrypt_key'])
+       {
+               $GLOBALS['phpgw_info']['server']['setup_mcrypt_key'] = '';
+               for($i=0; $i < 30; ++$i)
+               {
+                       $GLOBALS['phpgw_info']['server']['setup_mcrypt_key'] .= 
$random_char[rand(0,count($random_char)-1)];
+               }
+       }
+
        //$GLOBALS['phpgw_info']['server']['versions']['current_header'] = 
$setup_info['phpgwapi']['versions']['current_header'];
        unset($setup_info);
 
@@ -46,48 +60,36 @@
        function check_form_values()
        {
                $errors = '';
+               $domains = phpgw::get_var('domains', 'string', 'POST');
+               if ( !is_array($domains) )
+               {
+                       $domains = array();
+               }
 
-               $settings = phpgw::get_var('settings', 'string', 'POST');
-               $deletedomain = phpgw::get_var('deletedomain', 'string', 
'POST', array());
-               $domains = phpgw::get_var('domains', 'string', 'POST', array());
-
-               foreach ( array_keys($domains) as $domain )
+               foreach($domains as $k => $v)
                {
-                       if ( isset($deletedomain[$domain]) )
+                       $deletedomain = phpgw::get_var('deletedomain', 
'string', 'POST');
+                       if ( isset($deletedomain[$k]) )
                        {
                                continue;
                        }
                        
-                       if ( !$settings[$domain]['config_pass'] )
+                       if(!$_POST['settings'][$k]['config_pass'])
                        {
-                               $errors .= '<li>' . lang('You didn\'t enter a 
config password for domain %1', $domain) . '</li>';
+                               $errors .= '<br>' . lang("You didn't enter a 
config password for domain %1",$v);
                        }
-                       else if ( $settings[$domain]['config_pass'] == 
'changeme' )
-                       {
-                               $errors .= '<li>' . lang('You must set a real 
password for domain %1, \'changeme\' is the insecure default', $domain) . 
'</li>';
-                       }
                }
 
                $setting = phpgw::get_var('setting', 'string', 'POST');
-               if ( !$setting['HEADER_ADMIN_PASSWORD'] )
+               if(!$setting['HEADER_ADMIN_PASSWORD'])
                {
-                       $errors .= '<li>' . lang('You didn\'t enter a header 
admin password') . '</li>';
+                       $errors .= '<br>' . lang("You didn't enter a header 
admin password");
                }
 
                if($errors)
                {
                        
$GLOBALS['phpgw_setup']->html->show_header('Error',True);
-                       $lang_back = lang('go back');
-                       echo <<<HTML
-                               <h1>Whoops!</h1>
-                               <div class="err">
-                                       <ul>
-                                               $errors
-                                       </ul>
-                               </div>
-                               <a href="javascript:back();">$lang_back</a>
-
-HTML;
+                       echo $errors;
                        exit;
                }
        }
@@ -200,6 +202,7 @@
                case 'write':
                        check_form_values();
                        $header_template = 
CreateObject('phpgwapi.Template','../');
+                       $lang_continue = lang('continue');
                        if(is_writeable('../header.inc.php') || 
(!file_exists('../header.inc.php') && is_writeable('../')))
                        {
                                $newheader = 
$GLOBALS['phpgw_setup']->html->generate_header();
@@ -227,6 +230,7 @@
                        }
                        break;
                default:
+
                        
$GLOBALS['phpgw_setup']->html->show_header($GLOBALS['phpgw_info']['setup']['HeaderFormMSG'],
 False, 'header');
 
                        $detected = '';
@@ -245,7 +249,6 @@
 
                        $detected .= '<table id="manageheader">' . "\n";
 
-                       
                        if ( !isset($ConfigLang) || !$ConfigLang )
                        {
                                $_POST['ConfigLang'] = 'en';
@@ -285,7 +288,6 @@
                        {
                                $detected .= '<li class="warn">' . lang('No 
Microsoft SQL Server support found. Disabling') . "</li>\n";
                        }
-                       /* We don't currently support oracle
                        if (extension_loaded('oci8'))
                        {
                                $detected .= '<li>' . lang('You appear to have 
Oracle V8 (OCI) support enabled') . "</li>\n";
@@ -303,33 +305,32 @@
                                        $detected .= '<li class="warn">' . 
lang('No Oracle-DB support found. Disabling') . "</li>\n";
                                }
                        }
-                       */
 
                        /* Not currently supported
                        if (extension_loaded('odbc') || 
function_exists('odbc_connect'))
                        {
-                               $detected .= lang('You appear to have 
ODBC/SAPDB support enabled') . '<br />' . "\n";
+                               $detected .= lang('You appear to have 
ODBC/SAPDB support enabled') . '<br>' . "\n";
                                $supported_db[] = 'sapdb';
                        }
                        else
                        {
-                               $detected .= lang('No ODBC/SAPDB support found. 
Disabling') . '<br />' . "\n";
+                               $detected .= lang('No ODBC/SAPDB support found. 
Disabling') . '<br>' . "\n";
                        }
                        */
-                       if(!count($supported_db))
+                       if ( !count($supported_db) )
                        {
-                               $lang_err_nodb = lang('Did not find any valid 
DB support!');
-                               $lang_fix_nodb = lang('Try to configure your 
php to support one of the above mentioned DBMS, or install phpGroupWare by 
hand.');
+                               $lang_nodb = lang('Did not find any valid DB 
support!');
+                               $lang_fix = lang('Try to configure your php to 
support one of the above mentioned DBMS, or install phpGroupWare by hand.');
                                $detected .= <<<HTML
-                                                               <li 
class="err">$lang_err_nodb</li>
+                                                       <li 
class="err">$lang_nodb</li>
                                                        </ul>
+                                               <h2>$lang_fix</h2>
                                                </b>
-                                               $lang_fix_nodb
-                                       </td>
+                               <td>
                                </tr>
                        </table>
                </body>
-       </html>
+</html>
 
 HTML;
                                die($detected);
@@ -355,26 +356,23 @@
                        {
                                $detected .= '<li class="warn">' . lang('No 
IMAP support found. Email functions will be disabled') . "</li>\n";
                        }
-                       
-                       if(extension_loaded('mcrypt') || 
function_exists('mcrypt_list_modes'))
+                       if(extension_loaded('shmop') || 
function_exists('shmop_open'))
                        {
-                               $detected .= '<li>' . lang('You appear to have 
mcrypt support enabled') . "</li>\n";
-                               
$GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = true;
+                               $detected .= '<li>' . lang('You appear to have 
support for shared memory') . "</li>\n";
                        }
                        else
                        {
-                               $detected .= '<li class="warn">' . lang('No 
mcrypt support found. Some sensitive data may be store as plain text') . 
"</li>\n";
+                               $detected .= '<li class="warn">' . lang('No 
support for shared memory found.') . "</li>\n";
                        }
-                       
-                       if(extension_loaded('shmop') || 
function_exists('shmop_open'))
+                       if(extension_loaded('mcrypt') || 
function_exists('mcrypt_list_modes'))
                        {
-                               $detected .= '<li>' . lang('You appear to have 
shared memory support enabled') . "</li>\n";
+                               $detected .= '<li>' . lang('You appear to have 
enabled support for mcrypt') . "</li>\n";
+//                             
$GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = true;
                        }
                        else
                        {
-                               $detected .= '<li class="warn">' . lang('No 
SHMOP support found. Install or enable php-shmop if you want to use shared 
memory') . "</li>\n";
+                               $detected .= '<li class="warn">' . lang('No 
mcrypt support found.') . "</li>\n";
                        }
-                       
                        if( extension_loaded('xsl') && 
class_exists('XSLTProcessor') )
                        {
                                $detected .= '<li>' . lang('You appear to have 
XML/XSLT support enabled') . "</li>\n";
@@ -414,13 +412,12 @@
                                }
                                else
                                {
-                                       if ( 
!isset($GLOBALS['phpgw_info']['server']['header_version'])
-                                               || 
!isset($GLOBALS['phpgw_info']['server']['current_header_version'])
-                                               || 
$GLOBALS['phpgw_info']['server']['header_version'] != 
$GLOBALS['phpgw_info']['server']['current_header_version'] )
+                                       if( 
$GLOBALS['phpgw_info']['setup']['stage']['header'] == 3 )
                                        {
                                                $detected .= '<li 
class="warn">' . lang("You're using an old header.inc.php version...") . 
"</li>\n";
                                                $detected .= '<li>' . 
lang('Importing old settings into the new format....') . "</li>\n";
                                        }
+
                                        reset($GLOBALS['phpgw_domain']);
                                        $default_domain = 
each($GLOBALS['phpgw_domain']);
                                        
$GLOBALS['phpgw_info']['server']['default_domain'] = $default_domain[0];
@@ -442,12 +439,12 @@
                                                
$setup_tpl->set_var('lang_domain',lang('Domain'));
                                                
$setup_tpl->set_var('lang_delete',lang('Delete'));
                                                
$setup_tpl->set_var('db_domain',$key);
-                                               
$setup_tpl->set_var('db_host',$GLOBALS['phpgw_domain'][$key]['db_host']);
-                                               
$setup_tpl->set_var('db_name',$GLOBALS['phpgw_domain'][$key]['db_name']);
-                                               
$setup_tpl->set_var('db_user',$GLOBALS['phpgw_domain'][$key]['db_user']);
-                                               
$setup_tpl->set_var('db_pass',$GLOBALS['phpgw_domain'][$key]['db_pass']);
+                                               
$setup_tpl->set_var('db_host',$GLOBALS['phpgw']->crypto->decrypt($GLOBALS['phpgw_domain'][$key]['db_host']));
+                                               
$setup_tpl->set_var('db_name',$GLOBALS['phpgw']->crypto->decrypt($GLOBALS['phpgw_domain'][$key]['db_name']));
+                                               
$setup_tpl->set_var('db_user',$GLOBALS['phpgw']->crypto->decrypt($GLOBALS['phpgw_domain'][$key]['db_user']));
+                                               
$setup_tpl->set_var('db_pass',$GLOBALS['phpgw']->crypto->decrypt($GLOBALS['phpgw_domain'][$key]['db_pass']));
                                                
$setup_tpl->set_var('db_type',$GLOBALS['phpgw_domain'][$key]['db_type']);
-                                               
$setup_tpl->set_var('config_pass',$GLOBALS['phpgw_domain'][$key]['config_passwd']);
+                                               
$setup_tpl->set_var('config_pass',$GLOBALS['phpgw']->crypto->decrypt($GLOBALS['phpgw_domain'][$key]['config_passwd']));
 
                                                $selected = '';
                                                $dbtype_options = '';
@@ -456,7 +453,7 @@
                                                {
                                                        if ( $db == 
$GLOBALS['phpgw_domain'][$key]['db_type'] )
                                                        {
-                                                               $selected = ' 
selected ';
+                                                               $selected = ' 
selected';
                                                                $found_dbtype = 
true;
                                                        }
                                                        else
@@ -464,10 +461,11 @@
                                                                $selected = '';
                                                        }
                                                        $dbtype_options .= 
<<<HTML
-                                                               
<option{$selected}value="{$db}">$db</option>
+                                                               
<option{$selected} value="{$db}">$db</option>
 
 HTML;
                                                }
+
                                                
$setup_tpl->set_var('dbtype_options', $dbtype_options);
 
                                                
$setup_tpl->parse('domains','domain', true);
@@ -520,23 +518,10 @@
                                $setup_tpl->set_var('comment_l','<!-- ');
                                $setup_tpl->set_var('comment_r',' -->');
 
-                               srand((double)microtime()*1000000);
-                               $random_char = array(
-                                       
'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f',
-                                       
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
-                                       
'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L',
-                                       
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
-                               );
-
-                               $GLOBALS['phpgw_info']['server']['mcrypt_iv'] = 
'';
-                               for($i=0; $i < 30; ++$i)
-                               {
-                                       
$GLOBALS['phpgw_info']['server']['mcrypt_iv'] .= 
$random_char[rand(0,count($random_char)-1)];
-                               }
                                
$GLOBALS['phpgw_info']['server']['header_admin_password'] = '';
                                
$GLOBALS['phpgw_info']['server']['db_persistent'] = false;
                                
$GLOBALS['phpgw_info']['server']['sessions_type'] = 'php';
-                               
$GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = extension_loaded('mcrypt');
+//                             
$GLOBALS['phpgw_info']['server']['mcrypt_enabled'] = extension_loaded('mcrypt');
                                
$GLOBALS['phpgw_info']['server']['show_domain_selectbox'] = false;
                                
$GLOBALS['phpgw_info']['server']['domain_from_host'] = false;
 
@@ -558,9 +543,10 @@
 
                        $setup_tpl->set_var('server_root', 
$GLOBALS['phpgw_info']['server']['server_root']);
                        $setup_tpl->set_var('include_root', 
$GLOBALS['phpgw_info']['server']['include_root']);
-                       $setup_tpl->set_var('header_admin_password', 
$GLOBALS['phpgw_info']['server']['header_admin_password']);
+                       $setup_tpl->set_var('header_admin_password', 
isset($GLOBALS['phpgw_info']['server']['header_admin_password']) ? 
$GLOBALS['phpgw']->crypto->decrypt($GLOBALS['phpgw_info']['server']['header_admin_password'])
 : '');
+//                     $setup_tpl->set_var('header_admin_password', 
isset($GLOBALS['phpgw_info']['server']['header_admin_password']) ? 
$GLOBALS['phpgw_info']['server']['header_admin_password'] : '');
 
-                       if ( $GLOBALS['phpgw_info']['server']['db_persistent'] )
+                       if ( 
isset($GLOBALS['phpgw_info']['server']['db_persistent']) && 
$GLOBALS['phpgw_info']['server']['db_persistent'] )
                        {
                                $setup_tpl->set_var('db_persistent_yes',' 
selected');
                        }
@@ -573,22 +559,20 @@
                        $session_options = '';
                        foreach ( $supported_sessions_type as $stype )
                        {
-                               if( $stype == 
$GLOBALS['phpgw_info']['server']['sessions_type'])
+                               $selected = '';
+                               if( 
isset($GLOBALS['phpgw_info']['server']['sessions_type'])
+                                       && $stype == 
$GLOBALS['phpgw_info']['server']['sessions_type'])
                                {
                                        $selected = ' selected ';
                                }
-                               else
-                               {
-                                       $selected = '';
-                               }
                                $session_options .= <<<HTML
-                                       
<option{$selected}value="{$stype}">{$stype}</option>
+                                       <option{$selected} 
value="{$stype}">{$stype}</option>
 
 HTML;
                        }
                        $setup_tpl->set_var('session_options',$session_options);
 
-                       if ( $GLOBALS['phpgw_info']['server']['mcrypt_enabled'] 
)
+                       if ( 
isset($GLOBALS['phpgw_info']['server']['mcrypt_enabled']) && 
$GLOBALS['phpgw_info']['server']['mcrypt_enabled'] )
                        {
                                $setup_tpl->set_var('mcrypt_enabled_yes',' 
selected');
                        }
@@ -597,9 +581,10 @@
                                $setup_tpl->set_var('mcrypt_enabled_no',' 
selected');
                        }
 
-                       
$setup_tpl->set_var('mcrypt',$GLOBALS['phpgw_info']['server']['versions']['mcrypt']);
                        
$setup_tpl->set_var('mcrypt_iv',$GLOBALS['phpgw_info']['server']['mcrypt_iv']);
 
+                       
$setup_tpl->set_var('setup_mcrypt_key',$GLOBALS['phpgw_info']['server']['setup_mcrypt_key']);
+
                        if ( 
!isset($GLOBALS['phpgw_info']['server']['setup_acl']) || 
!$GLOBALS['phpgw_info']['server']['setup_acl'] )
                        {
                                $GLOBALS['phpgw_info']['server']['setup_acl'] = 
'127.0.0.1';
@@ -607,7 +592,7 @@
                        $setup_tpl->set_var('lang_setup_acl',lang('Limit access 
to setup to the following addresses or networks (e.g. 10.1.1,127.0.0.1)'));
                        $setup_tpl->set_var('setup_acl', 
$GLOBALS['phpgw_info']['server']['setup_acl']);
 
-                       if ( 
$GLOBALS['phpgw_info']['server']['show_domain_selectbox'] )
+                       if ( 
isset($GLOBALS['phpgw_info']['server']['show_domain_selectbox']) && 
$GLOBALS['phpgw_info']['server']['show_domain_selectbox'] )
                        {
                                $setup_tpl->set_var('domain_selectbox_yes',' 
selected');
                        }
@@ -616,7 +601,7 @@
                                $setup_tpl->set_var('domain_selectbox_no',' 
selected');
                        }
 
-                       if ( 
$GLOBALS['phpgw_info']['server']['domain_from_host'] )
+                       if ( 
isset($GLOBALS['phpgw_info']['server']['domain_from_host']) && 
$GLOBALS['phpgw_info']['server']['domain_from_host'] )
                        {
                                $setup_tpl->set_var('domain_from_host_yes',' 
selected');
                        }
@@ -678,6 +663,10 @@
                        $setup_tpl->set_var('lang_mcryptversiondescr',lang('Set 
this to "old" for versions &lt; 2.4, otherwise the exact mcrypt version you 
use.'));
                        $setup_tpl->set_var('lang_mcryptiv',lang('MCrypt 
initialization vector'));
                        $setup_tpl->set_var('lang_mcryptivdescr',lang('This 
should be around 30 bytes in length.<br>Note: The default has been randomly 
generated.'));
+
+                       $setup_tpl->set_var('lang_setup_mcrypt_key',lang('Enter 
some random text as encryption key for the setup encryption'));
+                       
$setup_tpl->set_var('lang_setup_mcrypt_key_descr',lang('This should be around 
30 bytes in length.<br>Note: The default has been randomly generated.'));
+
                        $setup_tpl->set_var('lang_domselect',lang('Domain 
select box on login'));
                        $setup_tpl->set_var('lang_domain_from_host', 
lang('Automatically detect domain from hostname'));
                        $setup_tpl->set_var('lang_note_domain_from_host', 
lang('Note: This option will only work if show domain select box is off.'));

Modified: people/sigurdne/modules/setup/trunk/sqltoarray.php
===================================================================
--- people/sigurdne/modules/setup/trunk/sqltoarray.php  2009-11-20 10:29:01 UTC 
(rev 20848)
+++ people/sigurdne/modules/setup/trunk/sqltoarray.php  2009-11-20 10:29:14 UTC 
(rev 20849)
@@ -41,7 +41,7 @@
                $setup_tpl->set_file(array(
                        'sqlarr'   => 'arraydl.tpl'
                ));
-               $setup_tpl->set_var('idstring',"/* \$Id" . ": 
tables_current.inc.php" . ",v 1.0" . " 2001/05/28 08:42:04 username " . "Exp \$ 
*/");
+               $setup_tpl->set_var('idstring',"/* \$Id" . ": 
tables_current.inc.php" . ",v 1.0 " . @date('Y/m/d',time()) .  " username " . 
"Exp \$ */");
                $setup_tpl->set_block('sqlarr','sqlheader','sqlheader');
                $setup_tpl->set_block('sqlarr','sqlbody','sqlbody');
                $setup_tpl->set_block('sqlarr','sqlfooter','sqlfooter');
@@ -101,24 +101,34 @@
 
                if (count($fk) > 1)
                {
-                       $GLOBALS['setup_tpl']->set_var('fks', "\n\t\t\t\t'" . 
implode(",\n\t\t\t\t'",$fk) );
+                       $GLOBALS['setup_tpl']->set_var('fks', "\n\t\t\t\t" . 
implode(",\n\t\t\t\t",$fk) );
                }
                elseif($fk && !empty($fk))
                {
-                       $GLOBALS['setup_tpl']->set_var('fks', "'" . $fk[0]);
+                       $GLOBALS['setup_tpl']->set_var('fks', $fk[0]);
                }
                else
                {
                        $GLOBALS['setup_tpl']->set_var('fks','');
                }
-
                if (count($ix) > 1)
                {
-                       $GLOBALS['setup_tpl']->set_var('ixs', implode(",",$ix));
+                       foreach($ix as $entry)
+                       {
+                               if(count($entry) > 1)
+                               {
+                                       $ix_temp[] = "array('" . 
implode("','",$entry) . "')";
+                               }
+                               else
+                               {
+                                       $ix_temp[] = "array('{$entry}')";
+                               }
+                       }
+                       $GLOBALS['setup_tpl']->set_var('ixs', 
implode(",",$ix_temp));
                }
                elseif($ix && !empty($ix))
                {
-                       $GLOBALS['setup_tpl']->set_var('ixs', $ix[0]);
+                       $GLOBALS['setup_tpl']->set_var('ixs', "'{$ix[0]}'");
                }
                else
                {

Modified: people/sigurdne/modules/setup/trunk/templates/base/config.tpl
===================================================================
--- people/sigurdne/modules/setup/trunk/templates/base/config.tpl       
2009-11-20 10:29:01 UTC (rev 20848)
+++ people/sigurdne/modules/setup/trunk/templates/base/config.tpl       
2009-11-20 10:29:14 UTC (rev 20849)
@@ -44,12 +44,15 @@
    </tr>
 
    <tr class="row_off">
-     <td>{lang_cookie_domain_for_sessions_-_if_unsure_use_request_fqdn}</td>
+     <td>{lang_cookie_domain_for_sessions_-_if_unsure_leave_empty}</td>
+        <td><input name="newsettings[cookie_domain]" 
value="{value_cookie_domain}"></td>
+<!--
         <td>
           <select name="newsettings[cookie_domain]">
          {hook_cookie_domain}
           </select>
         </td>
+-->
    </tr>
 
    <tr class="row_on">
@@ -142,6 +145,7 @@
      <select name="newsettings[account_repository]">
       <option value="sql"{selected_account_repository_sql}>SQL</option>
       <option value="ldap"{selected_account_repository_ldap}>LDAP</option>
+      <option value="sqlldap"{selected_account_repository_sqlldap}>SQL - 
replicate changes to LDAP</option>
       <option value="contacts"{selected_account_repository_contacts} 
style="text-decoration: line-through;">Contacts - DEPRECATED</option>
      </select>
     </td>
@@ -211,6 +215,15 @@
     </td>
    </tr>
 
+   <tr class="row_off">
+    <td>{lang_password_password_level}:</td>
+    <td>
+     <select name="newsettings[password_level]">
+{hook_passwdlevels}
+     </select>
+    </td>
+   </tr>
+
    <tr class="row_on">
     <td colspan="2">&nbsp;</td>
    </tr>

Modified: people/sigurdne/modules/setup/trunk/templates/base/head.tpl
===================================================================
--- people/sigurdne/modules/setup/trunk/templates/base/head.tpl 2009-11-20 
10:29:01 UTC (rev 20848)
+++ people/sigurdne/modules/setup/trunk/templates/base/head.tpl 2009-11-20 
10:29:14 UTC (rev 20849)
@@ -89,9 +89,8 @@
 
                        #analysis li
                        {
-                               border: 1px solid #4f8a10;
-                       background-color: #dff2bf;
-                       color: #4f8a10;
+                               background-color: #cdeb8b;
+                               border: 1px solid #008c00;
                                margin: 2px;
                                padding: 3px;
                        }
@@ -210,16 +209,14 @@
                        /* Extra qualifiers are used here to override 
definitions above */
                        .err, #analysis li.err
                        {
-                               background-color: #ffbaba;
-                               border-color: #d8000c;
-                               color: #d8000c;
+                               border: 1px solid #f00;
+                               color: #f00;
                        }
 
                        .warn, #analysis li.warn
                        {
-                               background-color: #fefeb3;
-                               border-color: #9f600;
-                               color: #9f6000;  
+                               background-color: #ff8;
+                               border-color: #fc0;
                        }
                -->
                </style>

Modified: people/sigurdne/modules/setup/trunk/templates/base/manageheader.tpl
===================================================================
--- people/sigurdne/modules/setup/trunk/templates/base/manageheader.tpl 
2009-11-20 10:29:01 UTC (rev 20848)
+++ people/sigurdne/modules/setup/trunk/templates/base/manageheader.tpl 
2009-11-20 10:29:14 UTC (rev 20849)
@@ -47,6 +47,10 @@
     <td>{lang_mcryptivdescr}</td>
   </tr>
   <tr>
+    <td><b>{lang_setup_mcrypt_key}</b><br><input type="text" 
name="setting[setup_mcrypt_key]" value="{setup_mcrypt_key}" size="40"></td>
+    <td>{lang_setup_mcrypt_key_descr}</td>
+  </tr>
+  <tr>
     <td><b>{lang_domselect}</b><br>
       <select name="setting[domain_selectbox]">
         <option value="True"{domain_selectbox_yes}>True</option>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]