2007-12-10 05:59:01 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2007-12-13 03:41:55 +01:00
|
|
|
* eGgroupWare setup - install the tables
|
2007-12-10 05:59:01 +01:00
|
|
|
*
|
|
|
|
* @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
|
2008-11-23 14:09:16 +01:00
|
|
|
* @version $Id$
|
2007-12-10 05:59:01 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2007-12-13 03:41:55 +01:00
|
|
|
* setup command: install the tables
|
2007-12-10 05:59:01 +01:00
|
|
|
*/
|
2008-11-23 14:09:16 +01:00
|
|
|
class setup_cmd_install extends setup_cmd
|
2007-12-10 05:59:01 +01:00
|
|
|
{
|
2009-05-24 15:41:39 +02:00
|
|
|
/**
|
|
|
|
* Allow to run this command via setup-cli
|
|
|
|
*/
|
|
|
|
const SETUP_CLI_CALLABLE = true;
|
|
|
|
|
2007-12-10 05:59:01 +01:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param string $domain string with domain-name or array with all arguments
|
|
|
|
* @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 $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
|
2007-12-11 02:28:07 +01:00
|
|
|
* @param boolean $verbose=false if true, echos out some status information during the run
|
2007-12-13 03:41:55 +01:00
|
|
|
* @param array $config=array() configuration to preset the defaults during the install, eg. set the account_repository
|
2008-11-23 17:46:32 +01:00
|
|
|
* @param string $lang='en'
|
2007-12-10 05:59:01 +01:00
|
|
|
*/
|
2008-11-23 17:46:32 +01:00
|
|
|
function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$charset='utf-8',$verbose=false,array $config=array(),$lang='en')
|
2007-12-10 05:59:01 +01:00
|
|
|
{
|
|
|
|
if (!is_array($domain))
|
|
|
|
{
|
|
|
|
$domain = array(
|
|
|
|
'domain' => $domain,
|
|
|
|
'config_user' => $config_user,
|
|
|
|
'config_passwd' => $config_passwd,
|
|
|
|
'backup' => $backup,
|
|
|
|
'charset' => $charset,
|
|
|
|
'verbose' => $verbose,
|
2007-12-13 03:41:55 +01:00
|
|
|
'config' => $config,
|
2008-11-23 17:46:32 +01:00
|
|
|
'lang' => $lang,
|
2007-12-10 05:59:01 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
elseif(!$domain['charset'])
|
|
|
|
{
|
|
|
|
$domain['charset'] = 'utf-8';
|
|
|
|
}
|
|
|
|
//echo __CLASS__.'::__construct()'; _debug_array($domain);
|
|
|
|
admin_cmd::__construct($domain);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2007-12-13 03:41:55 +01:00
|
|
|
* run the command: install the tables
|
2008-11-23 14:09:16 +01:00
|
|
|
*
|
2007-12-10 05:59:01 +01:00
|
|
|
* @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
|
|
|
|
* @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)
|
|
|
|
{
|
|
|
|
global $setup_info;
|
|
|
|
|
|
|
|
// instanciate setup object and check authorisation
|
|
|
|
$this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain);
|
2008-11-23 14:09:16 +01:00
|
|
|
|
2007-12-10 05:59:01 +01:00
|
|
|
$this->check_installed($this->domain,array(13,14,20),$this->verbose);
|
2008-11-23 14:09:16 +01:00
|
|
|
|
2007-12-10 05:59:01 +01:00
|
|
|
// use uploaded backup, instead installing from scratch
|
|
|
|
if ($this->backup)
|
|
|
|
{
|
2009-06-08 18:21:14 +02:00
|
|
|
$db_backup = new db_backup();
|
2008-11-23 14:09:16 +01:00
|
|
|
|
2007-12-10 05:59:01 +01:00
|
|
|
if (!is_resource($f = $db_backup->fopen_backup($this->backup,true)))
|
|
|
|
{
|
2008-11-23 14:09:16 +01:00
|
|
|
throw new egw_exception_wrong_userinput(lang('Restore failed').' ('.$f.')',31);
|
|
|
|
}
|
|
|
|
if ($this->verbose)
|
|
|
|
{
|
|
|
|
echo lang('Restore started, this might take a few minutes ...')."\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ob_start(); // restore echos the table structure
|
2007-12-10 05:59:01 +01:00
|
|
|
}
|
|
|
|
$db_backup->restore($f,$this->charset);
|
|
|
|
fclose($f);
|
|
|
|
|
2008-11-23 14:09:16 +01:00
|
|
|
if (!$this->verbose)
|
|
|
|
{
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
2007-12-10 05:59:01 +01:00
|
|
|
return lang('Restore finished');
|
|
|
|
}
|
|
|
|
// regular (new) install
|
|
|
|
if ($GLOBALS['egw_info']['setup']['stage']['db'] != 3)
|
|
|
|
{
|
|
|
|
throw new egw_exception_wrong_userinput(lang('eGroupWare is already installed!'),30);
|
|
|
|
}
|
|
|
|
$setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info);
|
|
|
|
|
|
|
|
// Set the DB's client charset if a system-charset is set
|
|
|
|
self::$egw_setup->system_charset = strtolower($this->charset);
|
|
|
|
self::$egw_setup->db->Link_ID->SetCharSet($this->charset);
|
2008-11-23 17:46:32 +01:00
|
|
|
$_POST['ConfigLang'] = $this->lang;
|
2007-12-10 05:59:01 +01:00
|
|
|
|
|
|
|
if ($this->verbose) echo lang('Installation started, this might take a few minutes ...')."\n";
|
2007-12-13 03:41:55 +01:00
|
|
|
$setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config);
|
2008-11-23 14:09:16 +01:00
|
|
|
|
2007-12-14 02:28:33 +01:00
|
|
|
$this->restore_db();
|
2008-11-23 14:09:16 +01:00
|
|
|
|
2007-12-10 05:59:01 +01:00
|
|
|
return lang('Installation finished');
|
|
|
|
}
|
|
|
|
}
|