using new api for setup

This commit is contained in:
Ralf Becker 2016-05-01 15:56:49 +00:00
parent 04e890d919
commit ca2ffb6aea
27 changed files with 478 additions and 430 deletions

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupware Setup - Account migration between SQL <--> LDAP
* EGroupware Setup - Account migration between SQL <--> LDAP
*
* The migration is done to the account-repository configured for eGroupWare!
*
@ -31,7 +31,7 @@ $setup_tpl->set_file(array(
'T_footer' => 'footer.tpl',
'T_alert_msg' => 'msg_alert_msg.tpl'
));
$setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
// check CSRF token for POST requests with any content (setup uses empty POST to call it's modules!)
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST)
@ -108,7 +108,7 @@ if (!$_POST['migrate'] && !$_POST['passwords2sql'])
else
{
$user_list .= '<option value="' . $account_id . '" selected="1">'.
common::display_fullname($account['account_lid'],
Api\Accounts::format_username($account['account_lid'],
$account['account_firstname'],$account['account_lastname']) . "</option>\n";
}
}
@ -129,7 +129,7 @@ if (!$_POST['migrate'] && !$_POST['passwords2sql'])
$setup_tpl->set_var('cancel',lang('Cancel'));
if ($from == 'sql' && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap')
{
$setup_tpl->set_var('extra_button', html::submit_button('passwords2sql', lang('Passwords --> SQL')));
$setup_tpl->set_var('extra_button', Api\Html::submit_button('passwords2sql', lang('Passwords --> SQL')));
}
$setup_tpl->pfp('out','header');
@ -163,10 +163,10 @@ else // do the migration
// store new repostory (and auth_type), as we are migrated now
if ($_POST['migrate'])
{
config::save_value('account_repository', $GLOBALS['egw_info']['server']['account_repository']=$to, 'phpgwapi');
Api\Config::save_value('account_repository', $GLOBALS['egw_info']['server']['account_repository']=$to, 'phpgwapi');
if (empty($GLOBALS['egw_info']['server']['auth_type']) || $GLOBALS['egw_info']['server']['auth_type'] == $from)
{
config::save_value('auth_type', $GLOBALS['egw_info']['server']['auth_type']=$to, 'phpgwapi');
Api\Config::save_value('auth_type', $GLOBALS['egw_info']['server']['auth_type']=$to, 'phpgwapi');
}
}
echo '<p align="center">'.lang('Click <a href="index.php">here</a> to return to setup.')."</p>\n";

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupware Setup - create admin account
* EGroupware Setup - create admin account
*
* @link http://www.egroupware.org
* @package setup
@ -11,6 +11,7 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
if (strpos($_SERVER['PHP_SELF'],'admin_account.php') !== false)
{
@ -54,7 +55,7 @@ if ($_POST['submit'])
if(!$_POST['submit'] || $error)
{
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = new Template($tpl_root);
$setup_tpl = new Framework\Template($tpl_root);
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',
@ -91,7 +92,7 @@ if(!$_POST['submit'] || $error)
$setup_tpl->set_var('create_demo_accounts',lang('Create demo accounts'));
$setup_tpl->set_var('demo_desc',lang('The username/passwords are: demo/guest, demo2/guest and demo3/guest.'));
$setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('lang_submit',lang('Save'));
$setup_tpl->set_var('lang_cancel',lang('Cancel'));

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupware Setup - Install, update & remove single apps
* EGroupware Setup - Install, update & remove single apps
*
* @link http://www.egroupware.org
* @package setup
@ -11,6 +11,7 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
$DEBUG = @$_POST['debug'] || @$_GET['debug'];
/*
@ -33,7 +34,7 @@ if (!$GLOBALS['egw_setup']->auth('Config'))
// Does not return unless user is authorized
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = new Template($tpl_root);
$setup_tpl = new Framework\Template($tpl_root);
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare Setup - System configuration
* EGroupWare Setup - System configuration
*
* @link http://www.egroupware.org
* @package setup
@ -11,6 +11,7 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
include('./inc/functions.inc.php');
@ -25,7 +26,7 @@ if(!$GLOBALS['egw_setup']->auth('Config') || @$_POST['cancel'])
}
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = new Template($tpl_root);
$setup_tpl = new Framework\Template($tpl_root);
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
@ -34,7 +35,7 @@ $setup_tpl->set_file(array(
'T_config_pre_script' => 'config_pre_script.tpl',
'T_config_post_script' => 'config_post_script.tpl'
));
$setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
// check CSRF token for POST requests with any content (setup uses empty POST to call it's modules!)
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST)
@ -120,7 +121,7 @@ class phpgw
$GLOBALS['egw'] = new phpgw;
$GLOBALS['egw']->db =& $GLOBALS['egw_setup']->db;
$t = new Template(common::get_tpl_dir('setup'));
$t = new Framework\Template(Framework\Template::get_dir('setup'));
$t->set_unknowns('keep');
$t->set_file(array('config' => 'config.tpl'));

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare Setup - DB backup and restore
* EGroupware Setup - DB backup and restore
*
* @link http://www.egroupware.org
* @package setup
@ -10,6 +10,9 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
use EGroupware\Api\Egw;
use EGroupware\Api\Vfs;
if (!is_object(@$GLOBALS['egw'])) // called from outside eGW ==> setup
{
@ -32,7 +35,7 @@ if (!is_object(@$GLOBALS['egw'])) // called from outside eGW ==> setup
$is_setup = true;
}
$db_backup = new Api\Db\Backup();
$asyncservice = new asyncservice();
$asyncservice = new Api\AsyncService();
// download a backup, has to be before any output !!!
if ($_POST['download'])
@ -41,17 +44,17 @@ if ($_POST['download'])
$file = $db_backup->backup_dir.'/'.basename($file); // basename to now allow to change the dir
while (@ob_end_clean()) {} // end all active output buffering
ini_set('zlib.output_compression',0); // switch off zlib.output_compression, as this would limit downloads in size to memory_limit
html::content_header(basename($file));
Api\Header\Content::type(basename($file));
readfile($file);
exit;
}
$setup_tpl = new Template($tpl_root);
$setup_tpl = new Framework\Template($tpl_root);
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',
'T_db_backup' => 'db_backup.tpl',
));
$setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
// check CSRF token for POST requests with any content (setup uses empty POST to call it's modules!)
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST)
@ -76,7 +79,7 @@ else
$setup_tpl->set_block('T_db_backup','setup_header');
$setup_tpl->set_var('setup_header','');
$GLOBALS['egw_info']['flags']['app_header'] = $stage_title;
common::egw_header();
$GLOBALS['egw']->framework->header();
parse_navbar();
$run_in_egw = true;
}
@ -107,13 +110,13 @@ if ($_POST['save_backup_settings'])
}
if ($_POST['mount'])
{
Api\Vfs::$is_root = true;
Vfs::$is_root = true;
echo '<div align="center">'.
(Api\Vfs::mount('filesystem://default'.$db_backup->backup_dir.'?group=Admins&mode=070','/backup',false) ?
(Vfs::mount('filesystem://default'.$db_backup->backup_dir.'?group=Admins&mode=070','/backup',false) ?
lang('Backup directory %1 mounted as %2',$db_backup->backup_dir,'/backup') :
lang('Failed to mount Backup directory!')).
"</div>\n";
Api\Vfs::$is_root = false;
Vfs::$is_root = false;
}
// create a backup now
if($_POST['backup'])
@ -204,7 +207,7 @@ if ($_POST['restore'])
$GLOBALS['egw_info']['server']['header_admin_user']='admin',
$GLOBALS['egw_info']['server']['header_admin_password']=uniqid('pw',true),false,true);
echo $cmd->run()."\n";
echo '<h3>'.lang('You should %1log out%2 and in again, to update your current session!','<a href="'.egw::link('/logout.php').'" target="_parent">','</a>')."</h3>\n";
echo '<h3>'.lang('You should %1log out%2 and in again, to update your current session!','<a href="'.Egw::link('/logout.php').'" target="_parent">','</a>')."</h3>\n";
}
}
else
@ -301,7 +304,7 @@ $setup_tpl->pparse('out','T_db_backup');
if ($run_in_egw)
{
common::egw_footer();
$GLOBALS['egw']->framework->footer();
}
else
{

View File

@ -14,6 +14,9 @@
*/
use EGroupware\Api;
use EGroupware\Api\Link;
use EGroupware\Api\Egw;
use EGroupware\Api\Vfs;
class setup
{
@ -77,8 +80,7 @@ class setup
if (!is_object($GLOBALS['egw']))
{
require_once(EGW_API_INC.'/class.egw.inc.php');
$GLOBALS['phpgw'] = $GLOBALS['egw'] = new egw_minimal();
$GLOBALS['phpgw'] = $GLOBALS['egw'] = new Egw\Base();
}
$this->detection = new setup_detection();
$this->process = new setup_process();
@ -631,7 +633,7 @@ class setup
$this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__);
// Remove links to the app
Api\Link::unlink(0, $appname);
Link::unlink(0, $appname);
$this->clear_session_cache();
}
@ -903,7 +905,7 @@ class setup
/**
* Own instance of the accounts class
*
* @var accounts
* @var Api\Accounts
*/
var $accounts;
@ -1009,19 +1011,19 @@ class setup
return false;
}
}
// call Api\Vfs\Hooks::add{account|group} hook to create the vfs-home-dirs
// call Vfs\Hooks::add{account|group} hook to create the vfs-home-dirs
// calling general add{account|group} hook fails, as we are only in setup
// --> setup_cmd_admin execs "admin/admin-cli.php --edit-user" to run them
if ($primary_group)
{
Api\Vfs\Hooks::addAccount(array(
Vfs\Hooks::addAccount(array(
'account_id' => $accountid,
'account_lid' => $username,
));
}
else
{
Api\Vfs\Hooks::addGroup(array(
Vfs\Hooks::addGroup(array(
'account_id' => $accountid,
'account_lid' => $username,
));
@ -1071,7 +1073,7 @@ class setup
$this->accounts->search(array(
'type' => 'accounts',
'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 Api\Accounts, if we just check for not anonymous
));
return $this->accounts->total > 1;

View File

@ -10,6 +10,7 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Egw;
/**
@ -27,7 +28,7 @@ abstract class setup_cmd extends admin_cmd
/**
* Should be called by every command usually requiring header admin rights
*
* @throws egw_exception_no_permission(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Api\Exception\NoPermission(lang('Wrong credentials to access the header.inc.php file!'),2);
*/
protected function _check_header_access()
{
@ -43,7 +44,7 @@ abstract class setup_cmd extends admin_cmd
if ($this->header_secret != $secret)
{
//echo "_check_header_access: header_secret='$this->header_secret' != '$secret'=_calc_header_secret({$GLOBALS['egw_info']['server']['header_admin_user']},{$GLOBALS['egw_info']['server']['header_admin_password']})\n";
throw new egw_exception_no_permission(lang('Wrong credentials to access the header.inc.php file!'),5);
throw new Api\Exception\NoPermission(lang('Wrong credentials to access the header.inc.php file!'),5);
}
}
@ -139,10 +140,10 @@ abstract class setup_cmd extends admin_cmd
if (is_object($GLOBALS['egw']->db) && $domain)
{
$GLOBALS['egw']->db->disconnect();
$GLOBALS['egw']->db = new egw_db($GLOBALS['egw_domain'][$domain]);
$GLOBALS['egw']->db = new Api\Db($GLOBALS['egw_domain'][$domain]);
// change caching to managed instance
egw_cache::unset_instance_key();
Api\Cache::unset_instance_key();
}
}
@ -155,15 +156,15 @@ abstract class setup_cmd extends admin_cmd
if (is_object($GLOBALS['egw']->db))
{
$GLOBALS['egw']->db->disconnect();
$GLOBALS['egw']->db = new egw_db($GLOBALS['egw_info']['server']);
$GLOBALS['egw']->db = new Api\Db($GLOBALS['egw_info']['server']);
// change caching back to own instance
egw_cache::unset_instance_key();
Api\Cache::unset_instance_key();
if (!is_null(self::$egw_accounts_backup))
{
$GLOBALS['egw']->accounts = self::$egw_accounts_backup;
accounts::cache_invalidate();
Api\Accounts::cache_invalidate();
unset(self::$egw_accounts_backup);
}
}
@ -175,8 +176,8 @@ abstract class setup_cmd extends admin_cmd
* @param string $user
* @param string $pw
* @param string $domain =null if given we also check agains config user/pw
* @throws egw_exception_no_permission(lang('Access denied: wrong username or password for manage-header !!!'),21);
* @throws egw_exception_no_permission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40);
* @throws Api\Exception\NoPermission(lang('Access denied: wrong username or password for manage-header !!!'),21);
* @throws Api\Exception\NoPermission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40);
*/
static function check_setup_auth($user,$pw,$domain=null)
{
@ -193,11 +194,11 @@ abstract class setup_cmd extends admin_cmd
{
if (is_null($domain))
{
throw new egw_exception_no_permission(lang('Access denied: wrong username or password for manage-header !!!'),21);
throw new Api\Exception\NoPermission(lang('Access denied: wrong username or password for manage-header !!!'),21);
}
else
{
throw new egw_exception_no_permission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40);
throw new Api\Exception\NoPermission(lang("Access denied: wrong username or password to configure the domain '%1(%2)' !!!",$domain,$GLOBALS['egw_domain'][$domain]['db_type']),40);
}
}
}
@ -243,7 +244,7 @@ abstract class setup_cmd extends admin_cmd
{
if (!include(EGW_INCLUDE_ROOT.'/phpgwapi/setup/setup.inc.php'))
{
throw new egw_exception_wrong_userinput(lang("eGroupWare sources in '%1' are not complete, file '%2' missing !!!",realpath('..'),'phpgwapi/setup/setup.inc.php'),99); // should not happen ;-)
throw new Api\Exception\WrongUserinput(lang("eGroupWare sources in '%1' are not complete, file '%2' missing !!!",realpath('..'),'phpgwapi/setup/setup.inc.php'),99); // should not happen ;-)
}
$versions['phpgwapi'] = $setup_info['phpgwapi']['version'];
unset($setup_info);
@ -257,13 +258,13 @@ abstract class setup_cmd extends admin_cmd
switch ($header_stage)
{
case 1: throw new egw_exception_wrong_userinput(lang('eGroupWare configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1);
case 1: throw new Api\Exception\WrongUserinput(lang('eGroupWare configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1);
// case 2: throw new egw_exception_wrong_userinput(lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('No header admin password set! Use --edit-header <password>[,<user>] to set one (--usage gives more options).'),2);
// case 2: throw new Api\Exception\WrongUserinput(lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('No header admin password set! Use --edit-header <password>[,<user>] to set one (--usage gives more options).'),2);
case 3: throw new egw_exception_wrong_userinput(lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('No eGroupWare domains / database instances exist! Use --edit-header --domain to add one (--usage gives more options).'),3);
case 3: throw new Api\Exception\WrongUserinput(lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('No eGroupWare domains / database instances exist! Use --edit-header --domain to add one (--usage gives more options).'),3);
case 4: throw new egw_exception_wrong_userinput(lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('It needs upgrading to version %1! Use --update-header <password>[,<user>] to do so (--usage gives more options).',$versions['current_header']),4);
case 4: throw new Api\Exception\WrongUserinput(lang('eGroupWare configuration file (header.inc.php) version %1 exists%2',$versions['header'],'.')."\n".lang('It needs upgrading to version %1! Use --update-header <password>[,<user>] to do so (--usage gives more options).',$versions['current_header']),4);
}
if ($header_checks)
{
@ -275,7 +276,7 @@ abstract class setup_cmd extends admin_cmd
$domains = $GLOBALS['egw_domain'];
if ($domain) // domain to check given
{
if (!isset($GLOBALS['egw_domain'][$domain])) throw new egw_exception_wrong_userinput(lang("Domain '%1' does NOT exist !!!",$domain), 92);
if (!isset($GLOBALS['egw_domain'][$domain])) throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!",$domain), 92);
$domains = array($domain => $GLOBALS['egw_domain'][$domain]);
}
@ -309,11 +310,11 @@ abstract class setup_cmd extends admin_cmd
}
switch($db_stage)
{
case 1: throw new egw_exception_wrong_userinput(lang('Your Database is not working!')." $db: ".self::$egw_setup->db->Error,11);
case 1: throw new Api\Exception\WrongUserinput(lang('Your Database is not working!')." $db: ".self::$egw_setup->db->Error,11);
case 3: throw new egw_exception_wrong_userinput(lang('Your database is working, but you dont have any applications installed')." ($db). ".lang("Use --install to install eGroupWare."),13);
case 3: throw new Api\Exception\WrongUserinput(lang('Your database is working, but you dont have any applications installed')." ($db). ".lang("Use --install to install eGroupWare."),13);
case 4: throw new egw_exception_wrong_userinput(lang('eGroupWare API needs a database (schema) update from version %1 to %2!',$setup_info['phpgwapi']['currentver'],$versions['phpgwapi']).' '.lang('Use --update to do so.'),14);
case 4: throw new Api\Exception\WrongUserinput(lang('eGroupWare API needs a database (schema) update from version %1 to %2!',$setup_info['phpgwapi']['currentver'],$versions['phpgwapi']).' '.lang('Use --update to do so.'),14);
case 10: // also check apps of updates
self::$apps_to_upgrade = self::$apps_to_install = array();
@ -338,7 +339,7 @@ abstract class setup_cmd extends admin_cmd
$db_stage = 4;
if ($stop && in_array(10+$db_stage,$stop)) return $messages;
throw new egw_exception_wrong_userinput(lang('The following applications need to be upgraded:').' '.implode(', ',self::$apps_to_upgrade).'! '.lang('Use --update to do so.'),14);
throw new Api\Exception\WrongUserinput(lang('The following applications need to be upgraded:').' '.implode(', ',self::$apps_to_upgrade).'! '.lang('Use --update to do so.'),14);
}
break;
}
@ -347,7 +348,7 @@ abstract class setup_cmd extends admin_cmd
self::$egw_setup->detection->check_config();
if ($GLOBALS['egw_info']['setup']['config_errors'] && $stop && !in_array(15,$stop))
{
throw new egw_exception_wrong_userinput(lang('You need to configure eGroupWare:')."\n- ".@implode("\n- ",$GLOBALS['egw_info']['setup']['config_errors']),15);
throw new Api\Exception\WrongUserinput(lang('You need to configure eGroupWare:')."\n- ".@implode("\n- ",$GLOBALS['egw_info']['setup']['config_errors']),15);
}
}
return $messages;

View File

@ -5,11 +5,13 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package setup
* @copyright (c) 2007-10 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* setup command: create a first eGroupWare user / admin and our two standard groups: Default & Admins
*
@ -26,15 +28,15 @@ 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_*
* @param string $lang='en'
* @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_*
* @param string $lang ='en'
*/
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(),$lang='en')
@ -61,7 +63,7 @@ class setup_cmd_admin extends setup_cmd
/**
* 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
* @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!');
@ -97,25 +99,26 @@ class setup_cmd_admin extends setup_cmd
switch ($error)
{
case 41:
throw new egw_exception_wrong_userinput(lang('Error in admin-creation !!!'),41);
throw new Api\Exception\WrongUserinput(lang('Error in admin-creation !!!'),41);
case 42:
throw new egw_exception_wrong_userinput(lang('Error in group-creation !!!'),42);
throw new Api\Exception\WrongUserinput(lang('Error in group-creation !!!'),42);
}
$this->restore_db();
// run admin/admin-cli.php --add-user to store the new accounts once in EGroupware
// run admin/admin-cli.php --add-user to store the new Api\Accounts once in EGroupware
// to run all hooks (some of them can NOT run inside setup)
$cmd = EGW_SERVER_ROOT.'/admin/admin-cli.php --add-user '.
escapeshellarg($this->admin_user.'@'.$this->domain.','.$this->admin_password.','.$this->admin_user);
if (php_sapi_name() !== 'cli' || !file_exists(EGW_SERVER_ROOT.'/stylite') || file_exists(EGW_SERVER_ROOT.'/managementserver'))
{
$output = $ret = null;
exec($cmd,$output,$ret);
}
$output = implode("\n",$output);
//echo "ret=$ret\n".$output;
if ($ret)
{
throw new egw_exception ($output,$ret);
throw new Api\Exception ($output,$ret);
}
return lang('Admin account successful created.');
}

View File

@ -5,11 +5,13 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package setup
* @copyright (c) 2007-10 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* setup command: test or create the database
*/
@ -28,9 +30,9 @@ class setup_cmd_database extends setup_cmd
const MAX_DB_NAME_LEN = 16;
/**
* Instance of egw_db to connect or create the db
* Instance of Api\Db to connect or create the db
*
* @var egw_db
* @var Api\Db
*/
private $test_db;
@ -39,16 +41,16 @@ class setup_cmd_database extends setup_cmd
*
* @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_host=null
* @param string $db_port=null
* @param string $db_name=null
* @param string $db_user=null
* @param string $db_pass=null
* @param string $db_root=null
* @param string $db_root_pw=null
* @param string $sub_command='create_db' 'create_db', 'test_db', 'test_db_root'
* @param string $db_grant_host='localhost' host/ip of webserver for grant
* @param boolean $make_db_name_unique=false true: if create fails because db exists,
* @param string $db_host =null
* @param string $db_port =null
* @param string $db_name =null
* @param string $db_user =null
* @param string $db_pass =null
* @param string $db_root =null
* @param string $db_root_pw =null
* @param string $sub_command ='create_db' 'create_db', 'test_db', 'test_db_root'
* @param string $db_grant_host ='localhost' host/ip of webserver for grant
* @param boolean $make_db_name_unique =false true: if create fails because db exists,
* try creating a unique name by shortening the name and adding a number to it
*/
function __construct($domain,$db_type=null,$db_host=null,$db_port=null,$db_name=null,$db_user=null,$db_pass=null,
@ -78,7 +80,7 @@ class setup_cmd_database extends setup_cmd
/**
* 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 success message
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!');
@ -87,7 +89,7 @@ class setup_cmd_database extends setup_cmd
{
if (!empty($this->domain) && !preg_match('/^([a-z0-9_-]+\.)*[a-z0-9]+/i',$this->domain))
{
throw new egw_exception_wrong_userinput(lang("'%1' is no valid domain name!",$this->domain));
throw new Api\Exception\WrongUserinput(lang("'%1' is no valid domain name!",$this->domain));
}
if ($this->remote_id && $check_only) return true; // further checks can only done locally
@ -127,10 +129,10 @@ class setup_cmd_database extends setup_cmd
/**
* Connect to database
*
* @param string $user=null default $this->db_user
* @param string $pass=null default $this->db_pass
* @param string $name=null default $this->db_name
* @throws egw_exception_wrong_userinput Can not connect to database ...
* @param string $user =null default $this->db_user
* @param string $pass =null default $this->db_pass
* @param string $name =null default $this->db_name
* @throws Api\Exception\WrongUserinput Can not connect to database ...
*/
private function connect($user=null,$pass=null,$name=null)
{
@ -138,7 +140,7 @@ class setup_cmd_database extends setup_cmd
if (is_null($pass)) $pass = $this->db_pass;
if (is_null($name)) $name = $this->db_name;
$this->test_db = new egw_db();
$this->test_db = new Api\Db();
$error_rep = error_reporting();
error_reporting($error_rep & ~E_WARNING); // switch warnings of, in case they are on
@ -152,7 +154,7 @@ class setup_cmd_database extends setup_cmd
if ($e)
{
throw new egw_exception_wrong_userinput(lang('Can not connect to %1 database %2 on host %3 using user %4!',
throw new Api\Exception\WrongUserinput(lang('Can not connect to %1 database %2 on host %3 using user %4!',
$this->db_type,$name,$this->db_host.($this->db_port?':'.$this->db_port:''),$user).' ('.$e->getMessage().')');
}
return lang('Successful connected to %1 database %2 on %3 using user %4.',
@ -168,7 +170,7 @@ class setup_cmd_database extends setup_cmd
* added to $this->db_name AND $this->db_user, if db already exists.
*
* @return string with success message
* @throws egw_exception_wrong_userinput
* @throws Api\Exception\WrongUserinput
*/
private function create()
{
@ -184,13 +186,13 @@ class setup_cmd_database extends setup_cmd
try {
$msg = $this->connect();
}
catch (egw_exception_wrong_userinput $e) {
catch (Api\Exception\WrongUserinput $e) {
// db or user not working --> connect as root and create it
try {
$this->test_db->create_database($this->db_root,$this->db_root_pw,$this->db_charset,$this->db_grant_host);
$this->connect();
}
catch(egw_exception_db $e) { // catches failed to create database
catch(Api\Db\Exception $e) { // catches failed to create database
// try connect as root to check if wrong root/root_pw is the problem
$this->connect($this->db_root,$this->db_root_pw,$this->db_meta);
@ -201,6 +203,7 @@ class setup_cmd_database extends setup_cmd
try {
$this->connect($this->db_root,$this->db_root_pw);
// create new db_name by incrementing an existing numeric postfix
$matches = null;
if (preg_match('/([0-9]+)$/',$this->db_name,$matches))
{
$num = (string)(++$matches[1]);
@ -215,13 +218,13 @@ class setup_cmd_database extends setup_cmd
return $this->create();
}
catch (egw_exception_wrong_userinput $e2)
catch (Api\Exception\WrongUserinput $e2)
{
// we can NOT connect to db as root --> ignore exception to give general error
}
}
// if not give general error
throw new egw_exception_wrong_userinput(lang('Can not create %1 database %2 on %3 for user %4!',
throw new Api\Exception\WrongUserinput(lang('Can not create %1 database %2 on %3 for user %4!',
$this->db_type,$this->db_name,$this->db_host.($this->db_port?':'.$this->db_port:''),$this->db_user));
}
$msg = lang('Successful connected to %1 on %3 and created database %2 for user %4.',
@ -234,7 +237,7 @@ class setup_cmd_database extends setup_cmd
{
$table = $table['table_name'];
}
throw new egw_exception_wrong_userinput(lang('%1 database %2 on %3 already contains the following tables:',
throw new Api\Exception\WrongUserinput(lang('%1 database %2 on %3 already contains the following tables:',
$this->db_type,$this->db_name,$this->db_host.($this->db_port?':'.$this->db_port:'')).' '.
implode(', ',$tables));
}
@ -245,8 +248,8 @@ class setup_cmd_database extends setup_cmd
* Drop database and user
*
* @return string with success message
* @throws egw_exception_wrong_userinput
* @throws egw_db_exception if database not exist
* @throws Api\Exception\WrongUserinput
* @throws Api\Db\Exception if database not exist
*/
private function drop()
{
@ -257,7 +260,8 @@ class setup_cmd_database extends setup_cmd
$this->test_db->query('DROP USER '.$this->test_db->quote($this->db_user).'@'.
$this->test_db->quote($this->db_grant_host?$this->db_grant_host:'%'),__LINE__,__FILE__);
}
catch (egw_db_exception $e) {
catch (Api\Db\Exception $e) {
unset($e);
// we make this no fatal error, as the granthost might be something else ...
$msg .= ' '.lang('Error dropping User!');
}
@ -267,7 +271,7 @@ class setup_cmd_database extends setup_cmd
/**
* Return default database settings for a given domain
*
* @param string $db_type='mysql'
* @param string $db_type ='mysqli'
* @return array
*/
static function defaults($db_type='mysqli')

View File

@ -5,11 +5,13 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package setup
* @copyright (c) 2007/8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* setup command: create or update the header.inc.php
*
@ -33,8 +35,8 @@ class setup_cmd_header extends setup_cmd
/**
* Constructor
*
* @param string/array $sub_command='create' 'create','edit','delete'(-domain) or array with all arguments
* @param array $arguments=null comand line arguments
* @param string|array $sub_command ='create' 'create','edit','delete'(-domain) or array with all arguments
* @param array $arguments =null comand line arguments
*/
function __construct($sub_command='create',$arguments=null)
{
@ -66,7 +68,7 @@ class setup_cmd_header extends setup_cmd
/**
* Create or update header.inc.php
*
* @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
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!');
@ -81,7 +83,7 @@ class setup_cmd_header extends setup_cmd
{
if ($this->sub_command != 'create')
{
throw new egw_exception_wrong_userinput(lang('eGroupWare configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1);
throw new Api\Exception\WrongUserinput(lang('eGroupWare configuration file (header.inc.php) does NOT exist.')."\n".lang('Use --create-header to create the configuration file (--usage gives more options).'),1);
}
$this->defaults(false);
}
@ -89,7 +91,7 @@ class setup_cmd_header extends setup_cmd
{
if ($this->sub_command == 'create')
{
throw new egw_exception_wrong_userinput(
throw new Api\Exception\WrongUserinput(
lang('eGroupWare configuration file header.inc.php already exists, you need to use --edit-header or delete it first!'),20);
}
if ($this->arguments)
@ -123,7 +125,7 @@ class setup_cmd_header extends setup_cmd
echo '$GLOBALS[egw_info] = '; print_r($GLOBALS['egw_info']);
echo '$GLOBALS[egw_domain] = '; print_r($GLOBALS['egw_domain']);
}
throw new egw_exception_wrong_userinput(lang('Configuration errors:')."\n- ".implode("\n- ",$errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"),23);
throw new Api\Exception\WrongUserinput(lang('Configuration errors:')."\n- ".implode("\n- ",$errors)."\n".lang("You need to fix the above errors, before the configuration file header.inc.php can be written!"),23);
}
if ($check_only)
{
@ -142,20 +144,20 @@ class setup_cmd_header extends setup_cmd
{
unlink($this->header_path);
}
if (($f = fopen($this->header_path,'wb')) && ($w=fwrite($f,$header)))
if (($f = fopen($this->header_path,'wb')) && fwrite($f,$header))
{
fclose($f);
return lang('header.inc.php successful written.');
}
}
throw new egw_exception_no_permission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"),24);
throw new Api\Exception\NoPermission(lang("Failed writing configuration file header.inc.php, check the permissions !!!"),24);
}
/**
* Magic method to allow to call all methods from setup_header, as if they were our own
*
* @param string $method
* @param array $args=null
* @param array $args =null
* @return mixed
*/
function __call($method,array $args=null)
@ -271,18 +273,18 @@ class setup_cmd_header extends setup_cmd
if (!isset(self::$options[$arg]))
{
throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!",$arg),90);
throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$arg),90);
}
$option = self::$options[$arg];
$values = !is_array($option) ? array($values) : explode(',',$values);
$vals = !is_array($option) ? array($values) : explode(',',$values);
if (!is_array($option)) $option = array($option => $option);
$n = 0;
foreach($option as $name => $data)
{
if ($n >= count($values)) break;
if ($n >= count($vals)) break;
$this->_parse_value($arg,$name,$data,$values[$n++]);
$this->_parse_value($arg,$name,$data,$vals[$n++]);
}
}
}
@ -296,7 +298,7 @@ class setup_cmd_header extends setup_cmd
{
if (!isset($GLOBALS['egw_domain'][$domain]))
{
throw new egw_exception_wrong_userinput(lang("Domain '%1' does NOT exist !!!",$domain),92);
throw new Api\Exception\WrongUserinput(lang("Domain '%1' does NOT exist !!!",$domain),92);
}
unset($GLOBALS['egw_domain'][$domain]);
}
@ -311,7 +313,7 @@ class setup_cmd_header extends setup_cmd
*/
private function _parse_value($arg,$name,$data,$value)
{
static $domain;
static $domain=null;
if (!is_array($data)) $data = array('type' => $data);
$type = $data['type'];
@ -320,7 +322,7 @@ class setup_cmd_header extends setup_cmd
{
if (!isset($data['allowed'][$value]))
{
throw new egw_exception_wrong_userinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1+$n,$arg),91);
throw new Api\Exception\WrongUserinput(lang("'%1' is not allowed as %2. arguments of option %3 !!!",$value,1,$arg),91);
}
$value = $data['allowed'][$value];
}
@ -359,6 +361,6 @@ class setup_cmd_header extends setup_cmd
{
$var =& $var[$name];
}
$var = strpos($name,'passw') !== false ? md5($value) : $value;
if (true) $var = strpos($name,'passw') !== false ? md5($value) : $value;
}
}

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package setup
* @copyright (c) 2011 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2011-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -40,7 +40,7 @@ class setup_cmd_hooks extends setup_cmd
/**
* run the command: register all hooks
*
* @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 success message
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!');

View File

@ -5,11 +5,13 @@
* @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>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
use EGroupware\Api;
/**
* setup command: install the tables
*/
@ -24,13 +26,13 @@ class setup_cmd_install extends setup_cmd
* 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
* @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
* @param string $lang='en'
* @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
* @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
* @param string $lang ='en'
*/
function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$charset='utf-8',$verbose=false,array $config=array(),$lang='en')
{
@ -58,13 +60,14 @@ class setup_cmd_install extends setup_cmd
/**
* 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
* @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)
{
unset($check_only); // not used;
global $setup_info;
// instanciate setup object and check authorisation
@ -79,7 +82,7 @@ class setup_cmd_install extends setup_cmd
if (!is_resource($f = $db_backup->fopen_backup($this->backup,true)))
{
throw new egw_exception_wrong_userinput(lang('Restore failed').' ('.$f.')',31);
throw new Api\Exception\WrongUserinput(lang('Restore failed').' ('.$f.')',31);
}
if ($this->verbose)
{
@ -101,7 +104,7 @@ class setup_cmd_install extends setup_cmd
// regular (new) install
if ($GLOBALS['egw_info']['setup']['stage']['db'] != 3)
{
throw new egw_exception_wrong_userinput(lang('eGroupWare is already installed!'),30);
throw new Api\Exception\WrongUserinput(lang('eGroupWare is already installed!'),30);
}
$setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info);
@ -111,7 +114,7 @@ class setup_cmd_install extends setup_cmd
$_POST['ConfigLang'] = $this->lang;
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,$this->config);
if (true) $setup_info = self::$egw_setup->process->pass($setup_info,'new',false,True,$this->config);
$this->restore_db();

View File

@ -45,7 +45,7 @@ use EGroupware\Api;
* attributes={smtp:}proxyAddresses=mail,{smtp:}proxyAddresses=mailalias,{quota:}proxyAddresses=mailuserquota,{forward:}proxyaddresses=maildrop
*
* - copies mail-attributes from ldap to AD (example is from Mandriva mailAccount schema, need to adapt to other schema!)
* (no_sid_check=1 uses all objectClass=posixAccount, not checking for having a SID and uid not ending in $ for computer accounts)
* (no_sid_check=1 uses all objectClass=posixAccount, not checking for having a SID and uid not ending in $ for computer Api\Accounts)
*
* setup/setup-cli.php [--dry-run] --setup-cmd-ldap <domain>,<config-user>,<config-pw> sub_command=passwords_to_sql \
* ldap_context=ou=accounts,dc=local ldap_root_dn=cn=admin,dc=local ldap_root_pw=secret ldap_host=localhost
@ -477,7 +477,7 @@ class setup_cmd_ldap extends setup_cmd
}
// invalidate cache: otherwise no migration takes place, if cached results says account already exists
accounts::cache_invalidate($account_id);
Api\Accounts::cache_invalidate($account_id);
if ($passwords2sql)
{
@ -658,7 +658,7 @@ class setup_cmd_ldap extends setup_cmd
}
// migrate addressbook data
$GLOBALS['egw_info']['user']['apps']['admin'] = true; // otherwise migration will not run in setup!
$addressbook = new addressbook_so();
$addressbook = new Api\Contacts\Storage();
foreach($this->as_array() as $name => $value)
{
if (substr($name, 5) == 'ldap_')
@ -757,16 +757,16 @@ class setup_cmd_ldap extends setup_cmd
$account['memberships'] = $accounts_obj->memberships($account_id,true);
}
}
accounts::cache_invalidate();
Api\Accounts::cache_invalidate();
return $accounts;
}
/**
* Instancate accounts object from either sql of ldap
* Instanciate accounts object from either sql of ldap
*
* @param string $type 'ldap', 'sql', 'univention'
* @return accounts
* @return Api\Accounts
*/
private function accounts_obj($type)
{
@ -862,7 +862,7 @@ class setup_cmd_ldap extends setup_cmd
$this->ldap_base => array(),
$this->ldap_context => array(),
$this->ldap_group_context => array(),
$this->ldap_root_dn => array('userPassword' => auth::encrypt_ldap($this->ldap_root_pw,'ssha')),
$this->ldap_root_dn => array('userPassword' => Api\Auth::encrypt_ldap($this->ldap_root_pw,'ssha')),
) as $dn => $extra)
{
if (!$this->_create_node($dn,$extra,$this->check_only) && $dn == $this->ldap_root_dn)

View File

@ -5,28 +5,30 @@
* @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>
* @copyright (c) 2007-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
* @version $Id$
*/
use EGroupware\Api;
/**
* setup command: show/return the header.inc.php
*
*
* Has no constructor, as we have no arguments beside the header admin user and password,
* which get set via setup_cmd::set_header_secret($user,$pw)
*/
class setup_cmd_showheader extends setup_cmd
class setup_cmd_showheader extends setup_cmd
{
/**
* Allow to run this command via setup-cli
*/
const SETUP_CLI_CALLABLE = true;
/**
* Constructor
*
* @param boolean $data=true true: send only the remote_hash, domain and webserver_url,
* @param boolean $data=true true: send only the remote_hash, domain and webserver_url,
* false: the complete header vars, plus install_id and webserver_url from the config table,
* null: only the header vars
*/
@ -46,8 +48,8 @@ class setup_cmd_showheader extends setup_cmd
/**
* show/return the header.inc.php
*
* @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
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!');
@ -55,7 +57,7 @@ class setup_cmd_showheader extends setup_cmd
function exec($check_only=false)
{
if ($this->remote_id && $check_only) return true; // cant check for the remote site locally!
$this->_check_header_access();
if ($check_only) return true;
@ -77,9 +79,9 @@ class setup_cmd_showheader extends setup_cmd
// include the api version of this instance
$GLOBALS['egw_info']['server']['versions']['phpgwapi'] = $egw_info_backup['server']['versions']['phpgwapi'];
// fetching the install id's stored in the database
foreach($GLOBALS['egw_domain'] as $domain => &$data)
foreach($GLOBALS['egw_domain'] as &$data)
{
if (!is_null($this->hash_only))
{
@ -99,7 +101,7 @@ class setup_cmd_showheader extends setup_cmd
'webserver_url' => $data['webserver_url'],
'install_id' => $data['install_id'],
)+($data['error'] ? array(
'error' => $data['error'],
'error' => $data['error'],
) : array());
}
}
@ -117,10 +119,10 @@ class setup_cmd_showheader extends setup_cmd
);
}
$GLOBALS['egw_info'] = $egw_info_backup;
return $ret;
}
/**
* Fetch the install_id, and webserver_url of a domain from the DB
*
@ -129,7 +131,7 @@ class setup_cmd_showheader extends setup_cmd
*/
private function _fetch_config(array $data)
{
$db = new egw_db();
$db = new Api\Db();
ob_start(); // not available db connection echos a lot grab ;-)
$err_rep = error_reporting(0);
@ -155,14 +157,14 @@ class setup_cmd_showheader extends setup_cmd
// restoring the db connection, seems to be necessary when we run via remote execution
$this->restore_db();
return $config;
}
/**
* Saving the object to the database, reimplemented to only the save the command if it runs remote
*
* @param boolean $set_modifier=true set the current user as modifier or 0 (= run by the system)
* @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system)
* @return boolean true on success, false otherwise
*/
function save($set_modifier=true)

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package setup
* @copyright (c) 2009-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2009-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -24,11 +24,11 @@ class setup_cmd_update extends setup_cmd
* Constructor
*
* @param string|array $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 boolean $verbose=false if true, echos out some status information during the run
* @param string $app=null single application to update or install
* @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 boolean $verbose =false if true, echos out some status information during the run
* @param string $app =null single application to update or install
*/
function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$verbose=false,$app=null)
{
@ -50,7 +50,7 @@ class setup_cmd_update extends setup_cmd
/**
* run the command: update or install/update a single app ($this->app)
*
* @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 success message
* @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2);
* @throws Exception('header.inc.php not found!');

View File

@ -1,6 +1,6 @@
<?php
/**
* Setup
* EGroupware Setup
*
* @link http://www.egroupware.org
* @package setup

View File

@ -1,6 +1,6 @@
<?php
/**
* Setup - Manage the eGW config file header.inc.php
* EGroupware Setup - Manage the eGW config file header.inc.php
*
* @link http://www.egroupware.org
* @package setup
@ -11,6 +11,9 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
/**
* Functions to manage the eGW config file header.inc.php
*
@ -58,7 +61,7 @@ class setup_header
* Sets $GLOBALS['egw_info'], $GLOBALS['egw_domains'] and the defines EGW_SERVER_ROOT and EGW_INCLUDE_ROOT,
* as if the header has been included
*
* @param string $domain='default' domain to set
* @param string $domain ='default' domain to set
*/
function defaults($domain='default')
{
@ -83,6 +86,7 @@ class setup_header
function domain_defaults($user='admin',$passwd='',$supported_db=null)
{
$null = null;
if (is_null($supported_db)) $supported_db = $this->check_db_support($null);
$default_db = count($supported_db) ? $supported_db[0] : 'mysqli';
@ -149,16 +153,17 @@ class setup_header
* should write an identical header.inc.php as the one include
*
* @param array $egw_info usual content (in server key) plus keys server_root and include_root
* @param array $egw_domains info about the existing eGW domains / DB instances
* @param array $egw_domain info about the existing eGW domains / DB instances
* @return string content of header.inc.php
*/
function generate($egw_info,$egw_domain)
{
$tpl = new Template('../', 'keep'); // 'keep' to not loose '{hash}' prefix of password-hashes!
$tpl = new Framework\Template('../', 'keep'); // 'keep' to not loose '{hash}' prefix of password-hashes!
$tpl->set_file(array('header' => 'header.inc.php.template'));
$tpl->set_block('header','domain','domain');
auth::passwdhashes($most_secure_pw_hash);
$most_secure_pw_hash = null;
Api\Auth::passwdhashes($most_secure_pw_hash);
foreach($egw_domain as $domain => $data)
{
@ -168,7 +173,7 @@ class setup_header
if ($name == 'db_port' && !$value) $value = $this->default_db_ports[$data['db_type']];
if ($name == 'config_passwd')
{
$var['CONFIG_PASS'] = self::is_hashed($value) ? $value : auth::encrypt_sql($value, $most_secure_pw_hash);
$var['CONFIG_PASS'] = self::is_hashed($value) ? $value : Api\Auth::encrypt_sql($value, $most_secure_pw_hash);
}
else
{
@ -183,7 +188,7 @@ class setup_header
$var = Array();
foreach($egw_info['server'] as $name => $value)
{
if ($name == 'header_admin_password' && $value && !self::is_hashed($value)) $value = auth::encrypt_sql($value, $most_secure_pw_hash);
if ($name == 'header_admin_password' && $value && !self::is_hashed($value)) $value = Api\Auth::encrypt_sql($value, $most_secure_pw_hash);
if ($name == 'versions')
{
$name = 'mcrypt_version';
@ -213,7 +218,7 @@ class setup_header
*/
function generate_mcyrpt_iv()
{
/*$mcrypt = mcrypt_module_open(egw_session::MCRYPT_ALGO, '', egw_session::MCRYPT_MODE, '');
/*$mcrypt = mcrypt_module_open(Api\Session::MCRYPT_ALGO, '', Api\Session::MCRYPT_MODE, '');
$size = mcrypt_enc_get_iv_size($mcrypt);
if (function_exists('mcrypt_create_iv')) // PHP 5.3+
{

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupWare Setup
* EGroupware Setup
*
* @link http://www.egroupware.org
* @package setup
@ -11,6 +11,8 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* Some static helper functions to generate html stuff in setup
*/
@ -246,7 +248,7 @@ class setup_html
*/
if (count($GLOBALS['egw_domain']) > 1)
{
foreach($GLOBALS['egw_domain'] as $domain => $data)
foreach(array_keys($GLOBALS['egw_domain']) as $domain)
{
$domains .= "<option value=\"$domain\" ".($domain == @$GLOBALS['egw_info']['setup']['LastDomain'] ? ' selected="selected"' : '').">$domain</option>\n";
}
@ -295,7 +297,7 @@ class setup_html
$ConfigLang = setup::get_lang();
if (empty($ConfigLang)) $ConfigLang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2);
}
return html::select('ConfigLang', $ConfigLang, translation::get_available_langs(false), true,
return Api\Html::select('ConfigLang', $ConfigLang, Api\Translation::get_available_langs(false), true,
$onChange ? ' onchange="this.form.submit();"' : '');
}
@ -303,6 +305,7 @@ class setup_html
{
$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
$list = array();
while($entry = $d->read())
{
if ($entry != 'CVS' && $entry != '.' && $entry != '..')

View File

@ -327,7 +327,7 @@ class setup_process
// so the default_records use the current data
$GLOBALS['egw_info']['server'] = array_merge((array)$GLOBALS['egw_info']['server'], $current_config);
Api\Cache::flush(); // flush whole instance cache
Api\Config::init_static(); // flush internal cache of config class
Api\Config::init_static(); // flush internal cache of Api\Config class
$GLOBALS['egw_setup']->setup_account_object($current_config);
}
@ -497,7 +497,7 @@ class setup_process
unset($appdata, $oProc);
// Clear categories cache in case app adds categories
categories::invalidate_cache();
Api\Categories::invalidate_cache();
/* Done, return current status */
return ($setup_info);

View File

@ -1,6 +1,6 @@
<?php
/**
* Setup translation class
* EGroupware Setup translation class
*
* @link http://www.egroupware.org
* @package setup
@ -11,6 +11,8 @@
* @version $Id$
*/
use EGroupware\Api;
if (!defined('MAX_MESSAGE_ID_LENGTH'))
{
define('MAX_MESSAGE_ID_LENGTH',128);
@ -52,10 +54,10 @@ class setup_translation
$lang = $ConfigLang;
}
$fn = '.' . SEP . 'lang' . SEP . EGW_LANGFILE_PREFIX . $lang . '.lang';
$fn = './lang/' . EGW_LANGFILE_PREFIX . $lang . '.lang';
if (!file_exists($fn))
{
$fn = '.' . SEP . 'lang' . SEP . EGW_LANGFILE_PREFIX .'en.lang';
$fn = './lang/' . EGW_LANGFILE_PREFIX .'en.lang';
}
if (file_exists($fn) && ($fp = fopen($fn,'r')))
{
@ -77,22 +79,22 @@ class setup_translation
/**
* Translate phrase to user selected lang
*
* @param $key phrase to translate
* @param $_key phrase to translate
* @param $vars vars sent to lang function, passed to us
*/
function translate($key, $vars=False)
function translate($_key, $vars=False)
{
static $placeholders = array('%1','%2','%3','%4','%5','%6','%7','%8','%9','%10');
$ret = $key . $this->no_translation_marker;
$key = strtolower(trim($key));
$ret = $_key . $this->no_translation_marker;
$key = strtolower(trim($_key));
if (isset($this->langarray[$key]))
{
$ret = $this->langarray[$key];
}
if ($GLOBALS['egw_setup']->system_charset != $this->langarray['charset'])
{
$ret = translation::convert($ret,$this->langarray['charset']);
$ret = Api\Translation::convert($ret,$this->langarray['charset']);
}
if (is_array($vars))
{
@ -104,7 +106,7 @@ class setup_translation
/**
* Languages we support (alphabetically sorted)
*
* @param boolean $array_values=true true: values are an array, false values are just the descriptiong
* @param boolean $array_values =true true: values are an array, false values are just the descriptiong
* @return array
*/
static function get_supported_langs($array_values=true)
@ -112,8 +114,8 @@ class setup_translation
$f = fopen(EGW_SERVER_ROOT.'/setup/lang/languages','rb');
while(($line = fgets($f)))
{
list($lang,$descr) = explode("\t",$line,2);
$lang = trim($lang);
list($lang2,$descr) = explode("\t",$line,2);
$lang = trim($lang2);
if ($array_values)
{
$languages[$lang]['lang'] = $lang;
@ -132,6 +134,7 @@ class setup_translation
$d = dir(EGW_SERVER_ROOT.'/setup/lang');
while(($file = $d->read()))
{
$matches = null;
if(preg_match('/^(php|e)gw_([-a-z]+).lang$/i',$file,$matches))
{
$languages[$matches[2]]['available'] = True;
@ -150,9 +153,9 @@ class setup_translation
/**
* List availible charsets and it's supported languages
* @param boolean/string $name=false name for selectbox or false to return an array
* @param boolean|string $name =false name for selectbox or false to return an array
* @param string $selected selected charset
* @return string/array html for a selectbox or array with charset / languages pairs
* @return string|array html for a selectbox or array with charset / languages pairs
*/
static function get_charsets($name=false,$selected='')
{
@ -189,6 +192,6 @@ class setup_translation
{
return $charsets;
}
return html::select($name,trim(strtolower($selected)),$charsets,true);
return Api\Html::select($name,trim(strtolower($selected)),$charsets,true);
}
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Setup
* EGroupware Setup
*
* @link http://www.egroupware.org
* @package setup

View File

@ -1,6 +1,6 @@
<?php
/**
* Setup
* EGroupware Setup
*
* @link http://www.egroupware.org
* @package setup
@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* Get the options for vfs_storage_mode, select the right one depending on vfs_fstab
*
@ -157,7 +159,7 @@ function passwdhashes($config,$return_hashes=false)
function sql_passwdhashes($config, $return_hashes=false, &$securest=null)
{
$hashes = auth::passwdhashes($securest);
$hashes = Api\Auth::passwdhashes($securest);
return $return_hashes ? $hashes : _options_from($hashes, $config['sql_encryption_type'] ? $config['sql_encryption_type'] : 'md5');
}

View File

@ -1,6 +1,6 @@
<?php
/**
* Setup
* EGroupware Setup
*
* @link http://www.egroupware.org
* @package setup
@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
/*
Set global flag to indicate for which config settings we have equally named validation methods
*/
@ -58,10 +60,10 @@ function vfs_storage_mode($settings)
switch($settings['vfs_storage_mode'])
{
case 'fs':
config::save_value('vfs_fstab','','phpgwapi');
Api\Config::save_value('vfs_fstab','','phpgwapi');
break;
case 'db':
config::save_value('vfs_fstab', array(
Api\Config::save_value('vfs_fstab', array(
'/' => 'sqlfs://$host/?storage=db',
'/apps' => 'links://$host/apps?storage=db',
),'phpgwapi');
@ -71,6 +73,7 @@ function vfs_storage_mode($settings)
function temp_dir($settings)
{
$error_msg = null;
if (!setup_detection::check_dir($settings['temp_dir'],$error_msg))
{
$GLOBALS['config_error'] = lang("Your temporary directory '%1' %2",$settings['temp_dir'],$error_msg);
@ -79,6 +82,7 @@ function temp_dir($settings)
function files_dir($settings)
{
$error_msg = null;
if ($settings['file_repository'] == 'sql' && $settings['file_store_contents'] == 'filesystem' &&
!setup_detection::check_dir($settings['files_dir'],$error_msg,true))
{
@ -92,6 +96,7 @@ function backup_dir(&$settings)
{
$settings['backup_dir'] = $settings['files_dir'].'/db_backup';
}
$error_msg = null;
if (!setup_detection::check_dir($settings['backup_dir'],$error_msg,true))
{
$GLOBALS['config_error'] = lang("Your backup directory '%1' %2",$settings['backup_dir'],$error_msg);
@ -101,7 +106,7 @@ function backup_dir(&$settings)
function _mcrypt_test_module_mode($module,$mode)
{
/* Data */
$key = 'this is a very long key, even too long for the cipher';
$key_in = 'this is a very long key, even too long for the cipher';
$plain_text = 'very important data';
/* Open module, and create IV */
@ -110,7 +115,7 @@ function _mcrypt_test_module_mode($module,$mode)
@mcrypt_module_close($GLOBALS['td']);
return False;
}
$key = substr($key, 0, mcrypt_enc_get_key_size($GLOBALS['td']));
$key = substr($key_in, 0, mcrypt_enc_get_key_size($GLOBALS['td']));
$iv_size = mcrypt_enc_get_iv_size($GLOBALS['td']);
$iv = @mcrypt_create_iv($iv_size, MCRYPT_RAND);

View File

@ -1,6 +1,6 @@
<?php
/**
* eGroupware Setup
* EGroupware Setup
*
* @link http://www.egroupware.org
* @package setup
@ -11,6 +11,7 @@
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
$GLOBALS['DEBUG'] = False;
include('./inc/functions.inc.php');
@ -18,7 +19,7 @@ include('./inc/functions.inc.php');
@set_time_limit(0);
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = new Template($tpl_root);
$setup_tpl = new Framework\Template($tpl_root);
$setup_tpl->set_file(array
(
'T_head' => 'head.tpl',
@ -254,7 +255,7 @@ switch($GLOBALS['egw_info']['setup']['stage']['db'])
$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
break;
case 4:
$setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',
isset($setup_info['api']['currentver']) ? $setup_info['api']['currentver'] : $setup_info['phpgwapi']['currentver']));
$setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['api']['version']));
@ -277,7 +278,7 @@ switch($GLOBALS['egw_info']['setup']['stage']['db'])
$setup_tpl->set_var('V_db_filled_block',$db_filled_block);
break;
case 5:
$setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('hidden_vars', Api\Html::input_hidden('csrf_token', Api\Csrf::token(__FILE__)));
$setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?'));
$setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications'));
$setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data'));

View File

@ -1,6 +1,6 @@
<?php
/**
* Setup - Manage the eGW config file header.inc.php
* EGroupware Setup - Manage the eGW config file header.inc.php
*
* @link http://www.egroupware.org
* @package setup
@ -10,12 +10,15 @@
* @version $Id$
*/
use EGroupware\Api;
use EGroupware\Api\Framework;
include('./inc/functions.inc.php');
require_once('./inc/class.setup_header.inc.php');
$GLOBALS['egw_setup']->header = new setup_header();
$setup_tpl = new Template('./templates/default', 'keep'); // 'keep' to keep our {hash} prefix of passwords
$setup_tpl = new Framework\Template('./templates/default', 'keep'); // 'keep' to keep our {hash} prefix of passwords
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',
@ -97,7 +100,7 @@ else
switch($action)
{
case 'download':
html::content_header('header.inc.php','application/octet-stream');
Api\Header\Content::type('header.inc.php','application/octet-stream');
echo $newheader;
break;
@ -232,6 +235,7 @@ function show_header_form($validation_errors)
$GLOBALS['egw_setup']->html->show_footer();
exit;
}
$detected = null;
$supported_db = $GLOBALS['egw_setup']->header->check_db_support($detected);
if (!count($supported_db))

View File

@ -11,6 +11,8 @@
* @version $Id$
*/
use EGroupware\Api;
chdir(dirname(__FILE__)); // to enable our relative pathes to work
if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page
@ -61,7 +63,7 @@ $GLOBALS['egw_setup']->system_charset = $charset;
if ((float) PHP_VERSION < $GLOBALS['egw_setup']->required_php_version)
{
throw new egw_exception_wrong_userinput(lang('You are using PHP version %1. EGroupware now requires %2 or later, recommended is PHP %3.',PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,$GLOBALS['egw_setup']->recommended_php_version),98);
throw new Api\Exception\WrongUserinput(lang('You are using PHP version %1. EGroupware now requires %2 or later, recommended is PHP %3.',PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,$GLOBALS['egw_setup']->recommended_php_version),98);
}
switch($action)
@ -132,7 +134,7 @@ switch($action)
list($name,$value) = explode('=',$arg,2);
if(property_exists('admin_cmd',$name)) // dont allow to overwrite admin_cmd properties
{
throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!",$arg),90);
throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
}
if (substr($name,-1) == ']') // allow 1-dim. arrays
{
@ -150,7 +152,7 @@ switch($action)
echo "$msg\n";
break;
}
throw new egw_exception_wrong_userinput(lang("Unknown option '%1' !!!",$action),90);
throw new Api\Exception\WrongUserinput(lang("Unknown option '%1' !!!",$action),90);
}
exit(0);
@ -255,7 +257,7 @@ function do_backup($arg,$quite_check=false)
}
else // backup failed ==> dont start the upgrade
{
throw new egw_exception_wrong_userinput(lang('Backup failed').': '.$f,50);
throw new Api\Exception\WrongUserinput(lang('Backup failed').': '.$f,50);
}
}
}

View File

@ -1,254 +1,254 @@
<?php
/**************************************************************************\
* eGroupWare - Setup *
* http://www.egroupware.org *
* -------------------------------------------- *
* 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. *
\**************************************************************************/
/**
* EGroupware Setup
*
* @link http://www.egroupware.org
* @package setup
* @copyright (c) 2006-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/* $Id$ */
use EGroupware\Api;
$GLOBALS['egw_info'] = array(
'flags' => array(
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'home',
'noapi' => True
$GLOBALS['egw_info'] = array(
'flags' => array(
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'home',
'noapi' => True
));
include('./inc/functions.inc.php');
/* Check header and authentication */
if(!$GLOBALS['egw_setup']->auth('Config'))
{
Header('Location: index.php');
exit;
}
// Does not return unless user is authorized
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
$cancel = get_var('cancel',Array('GET','POST'));
if($cancel)
{
Header('Location: applications.php');
exit;
}
$apps = get_var('apps',Array('GET','POST'));
$download = get_var('download',Array('GET','POST'));
$submit = get_var('submit',Array('GET','POST'));
$showall = get_var('showall',Array('GET','POST'));
$appname = get_var('appname',Array('GET','POST'));
if($download)
{
$setup_tpl->set_file(array(
'sqlarr' => 'arraydl.tpl'
));
include('./inc/functions.inc.php');
$setup_tpl->set_var('idstring',"/* \$Id" . ": tables_current.inc.php" . ",v 1.0" . " 2001/05/28 08:42:04 username " . "Exp \$ */");
$setup_tpl->set_block('sqlarr','sqlheader','sqlheader');
$setup_tpl->set_block('sqlarr','sqlbody','sqlbody');
$setup_tpl->set_block('sqlarr','sqlfooter','sqlfooter');
}
else
{
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',
'T_alert_msg' => 'msg_alert_msg.tpl',
'T_login_main' => 'login_main.tpl',
'T_login_stage_header' => 'login_stage_header.tpl',
'T_setup_main' => 'schema.tpl',
'applist' => 'applist.tpl',
'sqlarr' => 'sqltoarray.tpl',
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl'
));
$setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain');
$setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain');
$setup_tpl->set_block('T_setup_main','header','header');
$setup_tpl->set_block('applist','appheader','appheader');
$setup_tpl->set_block('applist','appitem','appitem');
$setup_tpl->set_block('applist','appfooter','appfooter');
$setup_tpl->set_block('sqlarr','sqlheader','sqlheader');
$setup_tpl->set_block('sqlarr','sqlbody','sqlbody');
$setup_tpl->set_block('sqlarr','sqlfooter','sqlfooter');
}
/* Check header and authentication */
if(!$GLOBALS['egw_setup']->auth('Config'))
$GLOBALS['egw_setup']->loaddb();
function parse_vars($table,$term)
{
$GLOBALS['setup_tpl']->set_var('table', $table);
$GLOBALS['setup_tpl']->set_var('term',$term);
list($arr,$pk,$fk,$ix,$uc) = $GLOBALS['egw_setup']->process->sql_to_array($table);
$GLOBALS['setup_tpl']->set_var('arr',$arr);
foreach(array('pk','fk','ix','uc') as $kind)
{
Header('Location: index.php');
exit;
$GLOBALS['setup_tpl']->set_var($kind.'s',_arr2str($$kind));
}
// Does not return unless user is authorized
unset($pk,$fk,$ix,$uc);
}
$tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root);
function _arr2str($arr)
{
if(!is_array($arr)) return $arr;
$cancel = get_var('cancel',Array('GET','POST'));
if($cancel)
$str = '';
foreach($arr as $key => $val)
{
Header('Location: applications.php');
exit;
if($str) $str .= ',';
if(!is_int($key))
{
$str .= "'$key' => ";
}
$str .= is_array($val) ? 'array('._arr2str($val).')' : "'$val'";
}
$apps = get_var('apps',Array('GET','POST'));
$download = get_var('download',Array('GET','POST'));
$submit = get_var('submit',Array('GET','POST'));
$showall = get_var('showall',Array('GET','POST'));
$appname = get_var('appname',Array('GET','POST'));
return $str;
}
function printout($template)
{
$download = get_var('download',array('POST','GET'));
$appname = get_var('appname',array('POST','GET'));
$showall = get_var('showall',array('POST','GET'));
$apps = $GLOBALS['apps'] ? $GLOBALS['apps'] : '';
if($download)
{
$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_block('sqlarr','sqlheader','sqlheader');
$setup_tpl->set_block('sqlarr','sqlbody','sqlbody');
$setup_tpl->set_block('sqlarr','sqlfooter','sqlfooter');
$GLOBALS['setup_tpl']->set_var('appname',$appname);
$GLOBALS['setup_tpl']->set_var('apps',$apps);
$string = $GLOBALS['setup_tpl']->parse('out',$template);
}
else
{
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',
'T_alert_msg' => 'msg_alert_msg.tpl',
'T_login_main' => 'login_main.tpl',
'T_login_stage_header' => 'login_stage_header.tpl',
'T_setup_main' => 'schema.tpl',
'applist' => 'applist.tpl',
'sqlarr' => 'sqltoarray.tpl',
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl'
));
$setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain');
$setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain');
$setup_tpl->set_block('T_setup_main','header','header');
$setup_tpl->set_block('applist','appheader','appheader');
$setup_tpl->set_block('applist','appitem','appitem');
$setup_tpl->set_block('applist','appfooter','appfooter');
$setup_tpl->set_block('sqlarr','sqlheader','sqlheader');
$setup_tpl->set_block('sqlarr','sqlbody','sqlbody');
$setup_tpl->set_block('sqlarr','sqlfooter','sqlfooter');
}
$GLOBALS['egw_setup']->loaddb();
function parse_vars($table,$term)
{
$GLOBALS['setup_tpl']->set_var('table', $table);
$GLOBALS['setup_tpl']->set_var('term',$term);
list($arr,$pk,$fk,$ix,$uc) = $GLOBALS['egw_setup']->process->sql_to_array($table);
$GLOBALS['setup_tpl']->set_var('arr',$arr);
foreach(array('pk','fk','ix','uc') as $kind)
{
$GLOBALS['setup_tpl']->set_var($kind.'s',_arr2str($$kind));
}
}
function _arr2str($arr)
{
if(!is_array($arr)) return $arr;
$str = '';
foreach($arr as $key => $val)
{
if($str) $str .= ',';
if(!is_int($key))
{
$str .= "'$key' => ";
}
$str .= is_array($val) ? 'array('._arr2str($val).')' : "'$val'";
}
return $str;
}
function printout($template)
{
$download = get_var('download',array('POST','GET'));
$appname = get_var('appname',array('POST','GET'));
$showall = get_var('showall',array('POST','GET'));
$apps = $GLOBALS['apps'] ? $GLOBALS['apps'] : '';
if($download)
{
$GLOBALS['setup_tpl']->set_var('appname',$appname);
$GLOBALS['setup_tpl']->set_var('apps',$apps);
$string = $GLOBALS['setup_tpl']->parse('out',$template);
}
else
{
// $url = $GLOBALS['appname'] ? 'applications.php' : 'sqltoarray.php';
$GLOBALS['setup_tpl']->set_var('appname',$appname);
$GLOBALS['setup_tpl']->set_var('lang_download',lang('Download'));
$GLOBALS['setup_tpl']->set_var('lang_cancel',lang('Cancel'));
$GLOBALS['setup_tpl']->set_var('showall',$showall);
$GLOBALS['setup_tpl']->set_var('apps',$apps);
$GLOBALS['setup_tpl']->set_var('action_url','sqltoarray.php');
$GLOBALS['setup_tpl']->pfp('out',$template);
}
return $string;
$GLOBALS['setup_tpl']->set_var('appname',$appname);
$GLOBALS['setup_tpl']->set_var('lang_download',lang('Download'));
$GLOBALS['setup_tpl']->set_var('lang_cancel',lang('Cancel'));
$GLOBALS['setup_tpl']->set_var('showall',$showall);
$GLOBALS['setup_tpl']->set_var('apps',$apps);
$GLOBALS['setup_tpl']->set_var('action_url','sqltoarray.php');
$GLOBALS['setup_tpl']->pfp('out',$template);
}
return $string;
}
function download_handler($dlstring,$fn='tables_current.inc.php')
{
html::content_header($fn);
echo $dlstring;
exit;
}
function download_handler($dlstring,$fn='tables_current.inc.php')
{
Api\Header\Content::type($fn);
echo $dlstring;
exit;
}
if($submit || $showall)
{
$dlstring = '';
$term = '';
if($submit || $showall)
{
$dlstring = '';
$term = '';
if(!$download)
{
$GLOBALS['egw_setup']->html->show_header();
}
if($showall)
{
$table = $appname = '';
}
if(!$table && !$appname)
{
$term = ',';
$dlstring .= printout('sqlheader');
$GLOBALS['egw_setup']->db->connect();
foreach($GLOBALS['egw_setup']->db->Link_ID->MetaTables() as $table)
{
parse_vars($table,$term);
$dlstring .= printout('sqlbody');
}
$dlstring .= printout('sqlfooter');
}
elseif($appname)
{
$dlstring .= printout('sqlheader');
$term = ',';
if(!$setup_info[$appname]['tables'])
{
$f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php';
if(file_exists($f))
{
include($f);
}
}
//$tables = explode(',',$setup_info[$appname]['tables']);
$tables = $setup_info[$appname]['tables'];
$i = 0;
$tbls = count($tables);
while(list($key,$table) = @each($tables))
{
$i++;
if($i == $tbls)
{
$term = '';
}
parse_vars($table,$term);
$dlstring .= printout('sqlbody');
/* $i++; */
}
$dlstring .= printout('sqlfooter');
}
elseif($table)
{
$term = ';';
parse_vars($table,$term);
$dlstring .= printout('sqlheader');
$dlstring .= printout('sqlbody');
$dlstring .= printout('sqlfooter');
}
if($download)
{
download_handler($dlstring);
}
}
else
if(!$download)
{
$GLOBALS['egw_setup']->html->show_header();
}
$setup_tpl->set_var('action_url','sqltoarray.php');
$setup_tpl->set_var('lang_submit','Show selected');
$setup_tpl->set_var('lang_showall','Show all');
$setup_tpl->set_var('title','SQL to schema_proc array util');
$setup_tpl->set_var('lang_applist','Applications');
$setup_tpl->set_var('select_to_download_file',lang('Select to download file'));
$setup_tpl->pfp('out','appheader');
if($showall)
{
$table = $appname = '';
}
$d = dir(EGW_SERVER_ROOT);
while($entry = $d->read())
if(!$table && !$appname)
{
$term = ',';
$dlstring .= printout('sqlheader');
$GLOBALS['egw_setup']->db->connect();
foreach($GLOBALS['egw_setup']->db->Link_ID->MetaTables() as $table)
{
$f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php';
parse_vars($table,$term);
$dlstring .= printout('sqlbody');
}
$dlstring .= printout('sqlfooter');
}
elseif($appname)
{
$dlstring .= printout('sqlheader');
$term = ',';
if(!$setup_info[$appname]['tables'])
{
$f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php';
if(file_exists($f))
{
include($f);
}
}
while(list($key,$data) = @each($setup_info))
//$tables = explode(',',$setup_info[$appname]['tables']);
$tables = $setup_info[$appname]['tables'];
$i = 0;
$tbls = count($tables);
while(list($key,$table) = @each($tables))
{
if($data['tables'])
$i++;
if($i == $tbls)
{
$setup_tpl->set_var('appname',$data['name']);
$setup_tpl->set_var('apptitle',$data['title']);
$setup_tpl->pfp('out','appitem');
$term = '';
}
parse_vars($table,$term);
$dlstring .= printout('sqlbody');
/* $i++; */
}
$setup_tpl->pfp('out','appfooter');
$dlstring .= printout('sqlfooter');
}
?>
elseif($table)
{
$term = ';';
parse_vars($table,$term);
$dlstring .= printout('sqlheader');
$dlstring .= printout('sqlbody');
$dlstring .= printout('sqlfooter');
}
if($download)
{
download_handler($dlstring);
}
}
else
{
$GLOBALS['egw_setup']->html->show_header();
$setup_tpl->set_var('action_url','sqltoarray.php');
$setup_tpl->set_var('lang_submit','Show selected');
$setup_tpl->set_var('lang_showall','Show all');
$setup_tpl->set_var('title','SQL to schema_proc array util');
$setup_tpl->set_var('lang_applist','Applications');
$setup_tpl->set_var('select_to_download_file',lang('Select to download file'));
$setup_tpl->pfp('out','appheader');
$d = dir(EGW_SERVER_ROOT);
while($entry = $d->read())
{
$f = EGW_SERVER_ROOT . '/' . $entry . '/setup/setup.inc.php';
if(file_exists($f))
{
include($f);
}
}
while(list($key,$data) = @each($setup_info))
{
if($data['tables'])
{
$setup_tpl->set_var('appname',$data['name']);
$setup_tpl->set_var('apptitle',$data['title']);
$setup_tpl->pfp('out','appitem');
}
}
$setup_tpl->pfp('out','appfooter');
}