From ba1b0762bd45f70dde77385d9f3efe05cdbdc154 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 20 Aug 2010 19:28:49 +0000 Subject: [PATCH] setup_cmd_admin execs "admin/admin-cli.php --edit-user" to run all hooks, which can NOT run in setup --- setup/inc/class.setup.inc.php | 16 +++++++++++++++- setup/inc/class.setup_cmd_admin.inc.php | 22 +++++++++++++++++++--- setup/inc/functions.inc.php | 7 +++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/setup/inc/class.setup.inc.php b/setup/inc/class.setup.inc.php index adbb41c5d8..cc5765fc3c 100644 --- a/setup/inc/class.setup.inc.php +++ b/setup/inc/class.setup.inc.php @@ -1053,14 +1053,28 @@ class setup error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') failed! accountid=$accountid"); return false; } - // call add{account|group} hook to create the vfs-home-dirs + // call vfs_home_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) { vfs_home_hooks::addAccount($account); +/* + $GLOBALS['hook_values'] = $account + array('new_passwd' => $account['account_passwd']); + $GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array( + 'location' => 'addaccount' + ),False,True); // called for every app now, not only enabled ones +*/ } else { vfs_home_hooks::addGroup($account+array('account_name' => $account['account_lid'])); +/* + $GLOBALS['hook_values'] = $account+(array('account_name' => $account['account_lid'])); + $GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array( + 'location' => 'addgroup' + ),False,True); // called for every app now, not only enabled ones) +*/ } } if ($primary_group) // only for users, NOT groups diff --git a/setup/inc/class.setup_cmd_admin.inc.php b/setup/inc/class.setup_cmd_admin.inc.php index 99ef65e997..620c05c2f2 100644 --- a/setup/inc/class.setup_cmd_admin.inc.php +++ b/setup/inc/class.setup_cmd_admin.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @author Ralf Becker * @package setup - * @copyright (c) 2007 by Ralf Becker + * @copyright (c) 2007-10 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -76,7 +76,12 @@ class setup_cmd_admin extends setup_cmd 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'); - + if (strpos($this->admin_email,'$') !== false) + { + $this->set_defaults['email'] = $this->admin_email = str_replace( + array('$domain','$uid','$account_lid'), + array($this->domain,$this->admin_user,$this->admin_user),$this->admin_email); + } $_POST['username'] = $this->admin_user; $_POST['passwd2'] = $_POST['passwd'] = $this->admin_password; $_POST['fname'] = $this->admin_firstname; @@ -97,7 +102,18 @@ class setup_cmd_admin extends setup_cmd throw new egw_exception_wrong_userinput(lang('Error in group-creation !!!'),42); } $this->restore_db(); - + + // run admin/admin-cli.php --edit-user to store the new accounts once in EGroupware + // to run all hooks (some of them can NOT run inside setup) + $cmd = EGW_SERVER_ROOT.'/admin/admin-cli.php --edit-user '. + escapeshellarg($this->admin_user.'@'.$this->domain.','.$this->admin_password.','.$this->admin_user); + exec($cmd,$output,$ret); + $output = implode("\n",$output); + //echo "ret=$ret\n".$output; + if ($ret) + { + throw new egw_exception ($output,$ret); + } return lang('Admin account successful created.'); } } diff --git a/setup/inc/functions.inc.php b/setup/inc/functions.inc.php index 62aad93fa8..91f06e3040 100644 --- a/setup/inc/functions.inc.php +++ b/setup/inc/functions.inc.php @@ -59,6 +59,13 @@ if(!defined('EGW_SERVER_ROOT') && !defined('EGW_INCLUDE_ROOT')) require_once(EGW_INCLUDE_ROOT . '/phpgwapi/inc/common_functions.inc.php'); +// check if eGW's pear repository is installed and prefer it over the regular one +if (is_dir(EGW_SERVER_ROOT.'/egw-pear')) +{ + set_include_path(EGW_SERVER_ROOT.'/egw-pear'.PATH_SEPARATOR.get_include_path()); + //echo "

include_path='".get_include_path()."'

\n"; +} + define('SEP',filesystem_separator()); /**