- installs can now be switched before the install happens to ldap, so all default records get created (eg. sitemgr is working)

- new setup command to create an admin user, used eg. from setup-cli.php
This commit is contained in:
Ralf Becker 2007-12-13 02:41:55 +00:00
parent 21238900c7
commit e3a9dc646f
11 changed files with 186 additions and 79 deletions

View File

@ -101,7 +101,7 @@ if (!$_POST['migrate'])
$GLOBALS['egw_setup']->setup_account_object(); $GLOBALS['egw_setup']->setup_account_object();
// fetch all users and groups // fetch all users and groups
$accounts = $GLOBALS['egw']->accounts->search(array( $accounts = $GLOBALS['egw_setup']->accounts->search(array(
'type' => 'both', 'type' => 'both',
)); ));
// fetch the complete data (search reads not everything), plus the members(hips) // fetch the complete data (search reads not everything), plus the members(hips)
@ -112,15 +112,15 @@ if (!$_POST['migrate'])
unset($accounts[$account_id]); unset($accounts[$account_id]);
$account_id = $account['account_id']; $account_id = $account['account_id'];
} }
$accounts[$account_id] = $GLOBALS['egw']->accounts->read($account_id); $accounts[$account_id] = $GLOBALS['egw_setup']->accounts->read($account_id);
if ($account['account_type'] == 'g') if ($account['account_type'] == 'g')
{ {
$accounts[$account_id]['members'] = $GLOBALS['egw']->accounts->members($account_id,true); $accounts[$account_id]['members'] = $GLOBALS['egw_setup']->accounts->members($account_id,true);
} }
else else
{ {
$accounts[$account_id]['memberships'] = $GLOBALS['egw']->accounts->memberships($account_id,true); $accounts[$account_id]['memberships'] = $GLOBALS['egw_setup']->accounts->memberships($account_id,true);
} }
} }
//_debug_array($accounts); //_debug_array($accounts);
@ -186,7 +186,7 @@ else // do the migration
if (!isset($accounts[$account_id])) continue; if (!isset($accounts[$account_id])) continue;
// check if user already exists // check if user already exists
if ($GLOBALS['egw']->accounts->exists($account_id)) if ($GLOBALS['egw_setup']->accounts->exists($account_id))
{ {
echo '<p>'.lang('%1 already exists in %2.',lang('User')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n"; echo '<p>'.lang('%1 already exists in %2.',lang('User')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n";
continue; continue;
@ -213,12 +213,12 @@ else // do the migration
} }
unset($accounts[$account_id]['person_id']); unset($accounts[$account_id]['person_id']);
if (!$GLOBALS['egw']->accounts->save($accounts[$account_id])) if (!$GLOBALS['egw_setup']->accounts->save($accounts[$account_id]))
{ {
echo '<p>'.lang('Creation of %1 in %2 failed !!!',lang('User')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n"; echo '<p>'.lang('Creation of %1 in %2 failed !!!',lang('User')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n";
continue; continue;
} }
$GLOBALS['egw']->accounts->set_memberships($accounts[$account_id]['memberships'],$account_id); $GLOBALS['egw_setup']->accounts->set_memberships($accounts[$account_id]['memberships'],$account_id);
echo '<p>'.lang('%1 created in %2.',lang('User')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n"; echo '<p>'.lang('%1 created in %2.',lang('User')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n";
} }
} }
@ -229,9 +229,9 @@ else // do the migration
if (!isset($accounts[$account_id])) continue; if (!isset($accounts[$account_id])) continue;
// check if group already exists // check if group already exists
if (!$GLOBALS['egw']->accounts->exists($account_id)) if (!$GLOBALS['egw_setup']->accounts->exists($account_id))
{ {
if (!$GLOBALS['egw']->accounts->save($accounts[$account_id])) if (!$GLOBALS['egw_setup']->accounts->save($accounts[$account_id]))
{ {
echo '<p>'.lang('Creation of %1 in %2 failed !!!',lang('Group')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n"; echo '<p>'.lang('Creation of %1 in %2 failed !!!',lang('Group')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n";
continue; continue;
@ -242,13 +242,13 @@ else // do the migration
{ {
echo '<p>'.lang('%1 already exists in %2.',lang('Group')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n"; echo '<p>'.lang('%1 already exists in %2.',lang('Group')." $account_id ({$accounts[$account_id]['account_lid']})",$target)."</p>\n";
if ($GLOBALS['egw']->accounts->id2name($account_id) != $accounts[$account_id]['account_lid']) if ($GLOBALS['egw_setup']->accounts->id2name($account_id) != $accounts[$account_id]['account_lid'])
{ {
continue; // different group under that gidnumber! continue; // different group under that gidnumber!
} }
} }
// now saving / updating the memberships // now saving / updating the memberships
$GLOBALS['egw']->accounts->set_members($accounts[$account_id]['members'],$account_id); $GLOBALS['egw_setup']->accounts->set_members($accounts[$account_id]['members'],$account_id);
} }
} }
echo '<p align="center">'.lang('Export has been completed!')."</p>\n"; echo '<p align="center">'.lang('Export has been completed!')."</p>\n";

View File

@ -108,11 +108,9 @@
$GLOBALS['egw_setup']->db->delete($table,'1=1',__LINE__,__FILE__); $GLOBALS['egw_setup']->db->delete($table,'1=1',__LINE__,__FILE__);
} }
} }
echo "About to create Default group\n";
/* Create the demo groups */ /* Create the demo groups */
$defaultgroupid = (int)$GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); $defaultgroupid = (int)$GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False);
$admingroupid = (int)$GLOBALS['egw_setup']->add_account('Admins','Admin','Group',False,False); $admingroupid = (int)$GLOBALS['egw_setup']->add_account('Admins','Admin','Group',False,False);
echo "Groups created\n";
if (!$defaultgroupid || !$admingroupid) if (!$defaultgroupid || !$admingroupid)
{ {

View File

@ -866,22 +866,30 @@
} }
} }
function setup_account_object() /**
* Own instance of the accounts class
*
* @var accounts
*/
var $accounts;
function setup_account_object(array $config=array())
{ {
if (!is_object($GLOBALS['egw']->accounts)) if (!is_object($this->accounts) || $config)
{ {
if (!is_object($this->db)) if (!is_object($this->db))
{ {
$this->loaddb(); $this->loaddb();
} }
/* Load up some configured values */ if (!$config)
$this->db->select($this->config_table,'config_name,config_value',
"config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type'",__LINE__,__FILE__);
while(($row = $this->db->row(true)))
{ {
if (!isset($GLOBALS['egw_info']['server'][$row['config_name']])) // dont overwrite // load the configuration from the database
$this->db->select($this->config_table,'config_name,config_value',
"config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type'",__LINE__,__FILE__);
while(($row = $this->db->row(true)))
{ {
$GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value']; $config[$row['config_name']] = $row['config_value'];
} }
} }
if (!is_object($GLOBALS['egw'])) if (!is_object($GLOBALS['egw']))
@ -891,10 +899,12 @@
} }
$GLOBALS['egw']->db = clone($this->db); $GLOBALS['egw']->db = clone($this->db);
$GLOBALS['egw']->common =& CreateObject('phpgwapi.common'); $GLOBALS['egw']->common =& CreateObject('phpgwapi.common');
$GLOBALS['egw']->accounts =& CreateObject('phpgwapi.accounts');
$this->accounts = new accounts($config);
$this->accounts->cache_invalidate(); // the cache is shared for all instances of the class
if(($GLOBALS['egw_info']['server']['account_repository'] == 'ldap') && if(($GLOBALS['egw_info']['server']['account_repository'] == 'ldap') &&
!$GLOBALS['egw']->accounts->ds) !$this->accounts->ds)
{ {
printf("<b>Error: Error connecting to LDAP server %s!</b><br>",$GLOBALS['egw_info']['server']['ldap_host']); printf("<b>Error: Error connecting to LDAP server %s!</b><br>",$GLOBALS['egw_info']['server']['ldap_host']);
return false; return false;
@ -921,9 +931,9 @@
{ {
$this->setup_account_object(); $this->setup_account_object();
$primary_group_id = $primary_group ? $GLOBALS['egw']->accounts->name2id($primary_group) : False; $primary_group_id = $primary_group ? $this->accounts->name2id($primary_group) : False;
if(!($accountid = $GLOBALS['egw']->accounts->name2id($username))) if(!($accountid = $this->accounts->name2id($username)))
{ {
$account = array( $account = array(
'account_type' => $primary_group ? 'u' : 'g', 'account_type' => $primary_group ? 'u' : 'g',
@ -937,7 +947,7 @@
'account_email' => $email, 'account_email' => $email,
'account_members' => '' 'account_members' => ''
); );
if (!($accountid = $GLOBALS['egw']->accounts->save($account))) if (!($accountid = $this->accounts->save($account)))
{ {
error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') failed! accountid=$accountid"); error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') failed! accountid=$accountid");
return false; return false;
@ -945,13 +955,13 @@
} }
if ($primary_group) // only for users, NOT groups if ($primary_group) // only for users, NOT groups
{ {
$memberships = $GLOBALS['egw']->accounts->memberships($accountid,true); $memberships = $this->accounts->memberships($accountid,true);
if($primary_group_id && !in_array($primary_group_id,$memberships)) if($primary_group_id && !in_array($primary_group_id,$memberships))
{ {
$memberships[] = $primary_group_id; $memberships[] = $primary_group_id;
$GLOBALS['egw']->accounts->set_memberships($memberships,$accountid); $this->accounts->set_memberships($memberships,$accountid);
} }
if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid);
} }
@ -969,7 +979,7 @@
{ {
$this->setup_account_object(); $this->setup_account_object();
return $GLOBALS['egw']->accounts->set_memberships($groups,$user); return $this->accounts->set_memberships($groups,$user);
} }
/** /**
@ -983,7 +993,7 @@
{ {
if (!$this->setup_account_object()) return false; if (!$this->setup_account_object()) return false;
$accounts = $GLOBALS['egw']->accounts->search(array( $accounts = $this->accounts->search(array(
'type' => 'accounts', 'type' => 'accounts',
'start' => 0, 'start' => 0,
'offset' => 2 // we only need to check 2 accounts, if we just check for not anonymous 'offset' => 2 // we only need to check 2 accounts, if we just check for not anonymous
@ -1020,7 +1030,7 @@
if (!is_numeric($account)) if (!is_numeric($account))
{ {
$this->setup_account_object(); $this->setup_account_object();
$account = $GLOBALS['egw']->accounts->name2id($account); $account = $this->accounts->name2id($account);
} }
if(!is_object($this->db)) if(!is_object($this->db))
{ {

View File

@ -113,6 +113,8 @@ abstract class setup_cmd extends admin_cmd
$cmd = new setup_cmd_showheader(null); // null = only header, no db stuff, no hashes $cmd = new setup_cmd_showheader(null); // null = only header, no db stuff, no hashes
$header = $cmd->run(); $header = $cmd->run();
$GLOBALS['egw_domain'] = $header['egw_domain']; $GLOBALS['egw_domain'] = $header['egw_domain'];
if ($this->config) self::$egw_setup->setup_account_object($this->config);
} }
if (is_object($GLOBALS['egw']->db) && $domain) if (is_object($GLOBALS['egw']->db) && $domain)
{ {
@ -346,7 +348,7 @@ abstract class setup_cmd extends admin_cmd
'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', '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', 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'@','!','$','%','&','/','(',')','=','?',';',':','#','_','-','<', '@','!','$','%','&','/','(',')','=','?',';',':','#','_','-','<',
'>','|','{','[',']','}', // dont add ,'" as we have problems dealing with them '>','|','{','[',']','}', // dont add \,'" as we have problems dealing with them
); );
$str = ''; $str = '';

View File

@ -0,0 +1,95 @@
<?php
/**
* eGgroupWare setup - create a first eGroupWare user / admin and our two standard groups: Default & Admins
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package setup
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* setup command: create a first eGroupWare user / admin and our two standard groups: Default & Admins
*
* @ToDo: get rid of the ugly setup_admin.php include
*/
class setup_cmd_admin extends setup_cmd
{
/**
* Constructor
*
* @param string|array $domain domain-name or array with all parameters
* @param string $config_user=null user to config the domain (or header_admin_user)
* @param string $config_passwd=null pw of above user
* @param string $admin_user=null
* @param string $admin_password=null
* @param string $admin_firstname=null
* @param string $admin_lastname=null
* @param string $admin_email=null
* @param array $config=array() extra config for the account object: account_repository, ldap_*
*/
function __construct($domain,$config_user=null,$config_passwd=null,$admin_user=null,$admin_password=null,
$admin_firstname=null,$admin_lastname=null,$admin_email=null,array $config=array())
{
if (!is_array($domain))
{
$domain = array(
'domain' => $domain,
'config_user' => $config_user,
'config_passwd' => $config_passwd,
'admin_user' => $admin_user,
'admin_password' => $admin_password,
'admin_firstname' => $admin_firstname,
'admin_lastname' => $admin_lastname,
'admin_email' => $admin_email,
'config' => $config,
);
}
//echo __CLASS__.'::__construct()'; _debug_array($domain);
admin_cmd::__construct($domain);
}
/**
* run the command: create eGW admin and standard groups
*
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @return string success message
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!');
*/
protected function exec($check_only=false)
{
if ($check_only && $this->remote_id)
{
return true; // can only check locally
}
$this->check_installed($this->domain,15);
if (!$this->admin_firstname) $this->set_defaults['admin_firstname'] = $this->admin_firstname = lang('Admin');
if (!$this->admin_lastname) $this->set_defaults['admin_lastname'] = $this->admin_lastname = lang('User');
$_POST['username'] = $this->admin_user;
$_POST['passwd2'] = $_POST['passwd'] = $this->admin_password;
$_POST['fname'] = $this->admin_firstname;
$_POST['lname'] = $this->admin_lastname;
$_POST['email'] = $this->admin_email;
$_POST['submit'] = true;
$error = include(dirname(__FILE__).'/../admin_account.php');
$this->restore_db();
switch ($error)
{
case 41:
throw new egw_exception_wrong_userinput(lang('Error in admin-creation !!!'),41);
case 42:
throw new egw_exception_wrong_userinput(lang('Error in group-creation !!!'),42);
}
$this->restore_db();
return lang('Admin account successful created.');
}
}

View File

@ -41,10 +41,10 @@ class setup_cmd_config extends setup_cmd
} }
/** /**
* test or create database * run the command: write the configuration to the database
* *
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @return string serialized $GLOBALS defined in the header.inc.php * @return string success message
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!'); * @throws Exception('header.inc.php not found!');
*/ */

View File

@ -23,7 +23,7 @@ class setup_cmd_database extends setup_cmd
private $test_db; private $test_db;
/** /**
* Enter description here... * Constructor
* *
* @param string/array $domain domain-name to customize the defaults or array with all parameters * @param string/array $domain domain-name to customize the defaults or array with all parameters
* @param string $db_type db-type (mysql, pgsql, ...) * @param string $db_type db-type (mysql, pgsql, ...)
@ -59,10 +59,10 @@ class setup_cmd_database extends setup_cmd
} }
/** /**
* test or create database * run the command: test or create database
* *
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @return string serialized $GLOBALS defined in the header.inc.php * @return string success message
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!'); * @throws Exception('header.inc.php not found!');
*/ */

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* eGgroupWare setup - install a new instance * eGgroupWare setup - install the tables
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
@ -11,7 +11,7 @@
*/ */
/** /**
* setup command: install a new instance * setup command: install the tables
*/ */
class setup_cmd_install extends setup_cmd class setup_cmd_install extends setup_cmd
{ {
@ -24,8 +24,9 @@ class setup_cmd_install extends setup_cmd
* @param string $backup=null filename of backup to use instead of new install, default new install * @param string $backup=null filename of backup to use instead of new install, default new install
* @param string $charset='utf-8' charset for the install, default utf-8 now * @param string $charset='utf-8' charset for the install, default utf-8 now
* @param boolean $verbose=false if true, echos out some status information during the run * @param boolean $verbose=false if true, echos out some status information during the run
* @param array $config=array() configuration to preset the defaults during the install, eg. set the account_repository
*/ */
function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$charset='utf-8',$verbose=false) function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$charset='utf-8',$verbose=false,$config=array())
{ {
if (!is_array($domain)) if (!is_array($domain))
{ {
@ -36,6 +37,7 @@ class setup_cmd_install extends setup_cmd
'backup' => $backup, 'backup' => $backup,
'charset' => $charset, 'charset' => $charset,
'verbose' => $verbose, 'verbose' => $verbose,
'config' => $config,
); );
} }
elseif(!$domain['charset']) elseif(!$domain['charset'])
@ -47,7 +49,7 @@ class setup_cmd_install extends setup_cmd
} }
/** /**
* test or create database * run the command: install the tables
* *
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @return string serialized $GLOBALS defined in the header.inc.php * @return string serialized $GLOBALS defined in the header.inc.php
@ -90,7 +92,7 @@ class setup_cmd_install extends setup_cmd
self::$egw_setup->db->Link_ID->SetCharSet($this->charset); self::$egw_setup->db->Link_ID->SetCharSet($this->charset);
if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n"; if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n";
$setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True); $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config);
return lang('Installation finished'); return lang('Installation finished');
} }

View File

@ -65,10 +65,10 @@ class setup_cmd_ldap extends setup_cmd
} }
/** /**
* test or create database * run the command: test or create the ldap connection and hierarchy
* *
* @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself
* @return string serialized $GLOBALS defined in the header.inc.php * @return string success message
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!'); * @throws Exception('header.inc.php not found!');
*/ */

View File

@ -56,8 +56,9 @@
* @param boolean $DEBUG=false print debugging info * @param boolean $DEBUG=false print debugging info
* @param boolean $force_en=false install english language files * @param boolean $force_en=false install english language files
* @param string $system_charset=null charset to use * @param string $system_charset=null charset to use
* @param array $preset_config=array()
*/ */
function pass($setup_info,$method='new',$DEBUG=False,$force_en=False) function pass($setup_info,$method='new',$DEBUG=False,$force_en=False,$preset_config=array())
{ {
if(!$method) if(!$method)
{ {
@ -118,7 +119,7 @@
case 'new': case 'new':
/* Create tables and insert new records for each app in this list */ /* Create tables and insert new records for each app in this list */
$passing = $this->current($pass,$DEBUG); $passing = $this->current($pass,$DEBUG);
$this->save_minimal_config(); $this->save_minimal_config($preset_config);
$passing = $this->default_records($passing,$DEBUG); $passing = $this->default_records($passing,$DEBUG);
$do_langs = true; // just do it once at the end of all passes $do_langs = true; // just do it once at the end of all passes
break; break;
@ -190,51 +191,59 @@
/** /**
* saves a minimal default config, so you get a running install without entering and saveing Step #2 config * saves a minimal default config, so you get a running install without entering and saveing Step #2 config
* *
* @param array $preset_config=array()
*/ */
function save_minimal_config() function save_minimal_config(array $preset_config=array())
{ {
$is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN'; $is_windows = strtoupper(substr(PHP_OS,0,3)) == 'WIN';
$GLOBALS['current_config']['site_title'] = 'eGroupWare'; $current_config['site_title'] = 'eGroupWare';
$GLOBALS['current_config']['hostname'] = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : 'localhost'; $current_config['hostname'] = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : 'localhost';
// guessing the eGW url // guessing the eGW url
$parts = explode('/',$_SERVER['PHP_SELF']); $parts = explode('/',$_SERVER['PHP_SELF']);
array_pop($parts); // remove config.php array_pop($parts); // remove config.php
array_pop($parts); // remove setup array_pop($parts); // remove setup
$GLOBALS['current_config']['webserver_url'] = implode('/',$parts); $current_config['webserver_url'] = implode('/',$parts);
$egroupwareDirName = end($parts); $egroupwareDirName = end($parts);
if(!$is_windows) { if(!$is_windows) {
if(@is_dir('/tmp')) { if(@is_dir('/tmp')) {
$GLOBALS['current_config']['temp_dir'] = '/tmp'; $current_config['temp_dir'] = '/tmp';
} else { } else {
$GLOBALS['current_config']['temp_dir'] = '/path/to/temp/dir'; $current_config['temp_dir'] = '/path/to/temp/dir';
} }
$GLOBALS['current_config']['files_dir'] = '/var/lib/'.$egroupwareDirName.'/'.$GLOBALS['egw_setup']->ConfigDomain.'/files'; $current_config['files_dir'] = '/var/lib/'.$egroupwareDirName.'/'.$GLOBALS['egw_setup']->ConfigDomain.'/files';
$GLOBALS['current_config']['backup_dir'] = '/var/lib/'.$egroupwareDirName.'/'.$GLOBALS['egw_setup']->ConfigDomain.'/backup'; $current_config['backup_dir'] = '/var/lib/'.$egroupwareDirName.'/'.$GLOBALS['egw_setup']->ConfigDomain.'/backup';
} else { } else {
if(@is_dir('c:\\windows\\temp')) { if(@is_dir('c:\\windows\\temp')) {
$GLOBALS['current_config']['temp_dir'] = 'c:\\windows\\temp'; $current_config['temp_dir'] = 'c:\\windows\\temp';
} else { } else {
$GLOBALS['current_config']['temp_dir'] = 'c:\\path\\to\\temp\\dir'; $current_config['temp_dir'] = 'c:\\path\\to\\temp\\dir';
} }
$GLOBALS['current_config']['files_dir'] = 'c:\\Program files\\'.$egroupwareDirName.'\\'.$GLOBALS['egw_setup']->ConfigDomain.'\\files'; $current_config['files_dir'] = 'c:\\Program files\\'.$egroupwareDirName.'\\'.$GLOBALS['egw_setup']->ConfigDomain.'\\files';
$GLOBALS['current_config']['backup_dir'] = 'c:\\Program files\\'.$egroupwareDirName.'\\'.$GLOBALS['egw_setup']->ConfigDomain.'\\backup'; $current_config['backup_dir'] = 'c:\\Program files\\'.$egroupwareDirName.'\\'.$GLOBALS['egw_setup']->ConfigDomain.'\\backup';
} }
$datetime =& CreateObject('phpgwapi.datetime'); $datetime =& CreateObject('phpgwapi.datetime');
$GLOBALS['current_config']['tz_offset'] = $datetime->getbestguess(); $current_config['tz_offset'] = $datetime->getbestguess();
unset($datetime); unset($datetime);
// RalfBecker: php.net recommend this for security reasons, it should be our default too // RalfBecker: php.net recommend this for security reasons, it should be our default too
$GLOBALS['current_config']['usecookies'] = 'True'; $current_config['usecookies'] = 'True';
if ($GLOBALS['egw_setup']->system_charset) if ($GLOBALS['egw_setup']->system_charset)
{ {
$GLOBALS['current_config']['system_charset'] = $GLOBALS['egw_setup']->system_charset; $current_config['system_charset'] = $GLOBALS['egw_setup']->system_charset;
} }
foreach($GLOBALS['current_config'] as $name => $value) $current_config['install_id'] = md5($_SERVER['HTTP_HOST'].microtime(true).$GLOBALS['egw_setup']->ConfigDomain);
if ($preset_config)
{
$current_config = array_merge($current_config,$preset_config);
}
foreach($current_config as $name => $value)
{ {
$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array( $GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->config_table,array(
'config_value' => $value, 'config_value' => $value,
@ -243,6 +252,9 @@
'config_name' => $name, 'config_name' => $name,
),__FILE__,__LINE__); ),__FILE__,__LINE__);
} }
// so the default_records use the current data
$GLOBALS['egw_setup']->setup_account_object($current_config);
} }
/** /**

View File

@ -172,23 +172,11 @@ function do_emailadmin()
*/ */
function do_admin($arg) function do_admin($arg)
{ {
list($_POST['username'],$_POST['passwd'],$_POST['fname'],$_POST['lname'],$_POST['email']) = _check_auth_config($arg,15); list($domain,$user,$password,$admin,$pw,$first,$last,$email) = explode(',',$arg);
$_POST['passwd2'] = $_POST['passwd']; _fetch_user_password($user,$password);
if (!$_POST['fname']) $_POST['fname'] = 'Admin'; $cmd = new setup_cmd_admin($domain,$user,$password,$admin,$pw,$first,$last,$email);
if (!$_POST['lname']) $_POST['lname'] = 'User'; echo $cmd->run()."\n";
$_POST['submit'] = true;
$error = include('admin_account.php');
switch ($error)
{
case 41:
fail(41,lang('Error in admin-creation !!!'));
case 42:
fail(42,lang('Error in group-creation !!!'));
}
echo lang('Admin account successful created.')."\n";
} }
/** /**