diff --git a/admin/admin-cli.php b/admin/admin-cli.php index 1e3a74061b..e2da0c7e7d 100755 --- a/admin/admin-cli.php +++ b/admin/admin-cli.php @@ -6,7 +6,7 @@ * @link http://www.egroupware.org * @package admin * @author Ralf Becker - * @copyright (c) 2006/7 by Ralf Becker + * @copyright (c) 2006-10 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -54,6 +54,9 @@ switch($action) case '--edit-user': return do_edit_user($arg0s); + case '--add-user': // like --edit-account, but always runs addaccount hook + return do_edit_user($arg0s,true); + case '--change-pw': return do_change_pw($arg0s); @@ -280,8 +283,9 @@ function do_change_pw($args) * Edit or add a user to eGroupWare. If you specify groups, they *replace* the exiting memberships! * 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12 * @param array $args admin-account[@domain],admin-password,account[=new-account-name],first-name,last-name,password,email,expires{never(default)|YYYY-MM-DD|already},can-change-pw{true(default)|false},anon-user{true|false(default)},primary-group{Default(default)|...}[,groups,...][,homedirectory,loginshell] + * @param boolean $run_addaccount_hook=null default run hook depending on account existence, true=allways run addaccount hook */ -function do_edit_user($args) +function do_edit_user($args,$run_addaccount_hook=null) { array_shift($args); // admin-account array_shift($args); // admin-pw @@ -321,7 +325,7 @@ function do_edit_user($args) $data['account_lid'] = $account; $account = false; }; - run_command(new admin_cmd_edit_user($account,$data)); + run_command(new admin_cmd_edit_user($account,$data,null,$run_addaccount_hook)); } /** @@ -412,9 +416,7 @@ function do_subscribe_other($account_lid,$pw=null) 'account_lid' => $account_lid, 'passwd' => $pw, ); - include_once(EGW_INCLUDE_ROOT.'/emailadmin/inc/class.bo.inc.php'); - - $emailadmin = new bo(); + $emailadmin = new emailadmin_bo(); $user_profile = $emailadmin->getUserProfile('felamimail'); unset($emailadmin); diff --git a/admin/inc/class.admin_cmd_edit_user.inc.php b/admin/inc/class.admin_cmd_edit_user.inc.php index 9ab3d00c37..9fb4a0f941 100644 --- a/admin/inc/class.admin_cmd_edit_user.inc.php +++ b/admin/inc/class.admin_cmd_edit_user.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @author Ralf Becker * @package admin - * @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$ */ @@ -21,8 +21,9 @@ class admin_cmd_edit_user extends admin_cmd_change_pw * @param string/int/array $account account name or id (!$account to add a new account), or array with all parameters * @param array $set=null array with all data to change * @param string $password=null password + * @param boolean $run_addaccount_hook=null default run addaccount for new accounts and editaccount for existing ones */ - function __construct($account,$set=null,$password=null) + function __construct($account,$set=null,$password=null,$run_addaccount_hook=null) { if (!is_array($account)) { @@ -30,6 +31,7 @@ class admin_cmd_edit_user extends admin_cmd_change_pw 'account' => $account, 'set' => $set, 'password' => is_null($password) ? $set['account_passwd'] : $password, + 'run_addaccount_hook' => $run_addaccount_hook, ); } admin_cmd::__construct($account); @@ -167,7 +169,7 @@ class admin_cmd_edit_user extends admin_cmd_change_pw $data['account_passwd'] = $this->password; $GLOBALS['hook_values'] =& $data; $GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array( - 'location' => $this->account ? 'editaccount' : 'addaccount' + 'location' => $this->account && $this->run_addaccount_hook !== true ? 'editaccount' : 'addaccount' ),False,True); // called for every app now, not only enabled ones) return lang("Account %1 %2",$this->account ? $this->account : $data['account_lid'], diff --git a/setup/inc/class.setup_cmd_admin.inc.php b/setup/inc/class.setup_cmd_admin.inc.php index 620c05c2f2..06d2664cc9 100644 --- a/setup/inc/class.setup_cmd_admin.inc.php +++ b/setup/inc/class.setup_cmd_admin.inc.php @@ -103,9 +103,9 @@ class setup_cmd_admin extends setup_cmd } $this->restore_db(); - // run admin/admin-cli.php --edit-user to store the new accounts once in EGroupware + // run admin/admin-cli.php --add-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 '. + $cmd = EGW_SERVER_ROOT.'/admin/admin-cli.php --add-user '. escapeshellarg($this->admin_user.'@'.$this->domain.','.$this->admin_password.','.$this->admin_user); exec($cmd,$output,$ret); $output = implode("\n",$output);