run addaccount hook for new accounts and set account_id in menuclass links (left menu) after account-creation

This commit is contained in:
Ralf Becker 2013-06-26 19:55:20 +00:00
parent 7142d632a5
commit c5246d90c9
3 changed files with 21 additions and 17 deletions

View File

@ -220,13 +220,17 @@
if(!$errors)
{
$new_user = !$userData['account_id'];
$passwd = $userData['account_passwd'];
$errors = $this->save_user($userData);
$GLOBALS['hook_values'] = $userData;
$GLOBALS['hook_values'] = $userData + ($new_user ? array(
'new_password' => $passwd,
) : array());
$GLOBALS['egw']->hooks->process($GLOBALS['hook_values']+array(
'location' => 'editaccount'
'location' => $new_user ? 'addaccount' : 'editaccount',
),False,True); // called for every app now, not only enabled ones)
}
error_log(__METHOD__."(".array2string($userData).") returning ".array2string($errors ? $errors : true));
//error_log(__METHOD__."(".array2string($userData).") returning ".array2string($errors ? $errors : true));
return $errors ? $errors : true;
}

View File

@ -1561,7 +1561,7 @@
// $menuClass =& CreateObject('admin.uimenuclass');
// This is now using ExecMethod()
$GLOBALS['account_id'] = $_account_id;
$t->set_var('rows', $_account_id ? ExecMethod('admin.uimenuclass.createHTMLCode','edit_user') : '');
$t->set_var('rows', $_account_id ? ExecMethod2('admin.uimenuclass.createHTMLCode','edit_user',$_account_id) : '');
echo $t->fp('out','form');
}

View File

@ -8,14 +8,14 @@
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class uimenuclass
{
var $t;
var $rowColor = Array();
function uimenuclass()
{
$this->t =& CreateObject('phpgwapi.Template',$GLOBALS['egw']->common->get_tpl_dir('admin'));
@ -42,7 +42,7 @@
// 'Login History' => array('/index.php','menuaction=admin.uiaccess_history.list')
// );
// This allows extra data to be sent along
function display_section($_menuData)
function display_section($_menuData, $_account_id)
{
$i=0;
@ -53,11 +53,11 @@
{
if (!empty($value['extradata']))
{
$link = $GLOBALS['egw']->link($value['url'],'account_id=' . get_var('account_id',array('GET','POST')) . '&' . $value['extradata']);
$link = egw::link($value['url'],'account_id=' . $_account_id . '&' . $value['extradata']);
}
else
{
$link = $GLOBALS['egw']->link($value['url'],'account_id=' . get_var('account_id',array('GET','POST')));
$link = egw::link($value['url'],'account_id=' . get_var('account_id',array('GET','POST')));
}
$this->section_item($link,lang($value['description']),($i%2) ? "row_on": "row_off",$value['options']);
$i++;
@ -77,14 +77,17 @@
$this->t->set_var('row_on',$this->rowColor[0]);
$this->t->parse('out','menu_links');
return $this->t->get('out','menu_links');
}
// create the html code for the menu
function createHTMLCode($_hookname)
function createHTMLCode($_hookname, $_account_id=null)
{
$hook['location'] = $_hookname;
$hook = array('location' => $_hookname);
if (!$_account_id) $_account_id = get_var('account_id',array('GET','POST'));
if ($_account_id) $hook['account_id'] = $_account_id;
switch ($_hookname)
{
case 'edit_user':
@ -93,7 +96,6 @@
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.edit_user'
);
if (get_var('account_id',array('GET','POST'))) $hook['account_id'] = get_var('account_id',array('GET','POST'));
break;
case 'view_user':
$GLOBALS['menuData'][] = array(
@ -101,7 +103,6 @@
'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.view_user'
);
//if (get_var('account_id',array('GET','POST'))) $hook['account_id'] = get_var('account_id',array('GET','POST'));
break;
case 'edit_group':
$GLOBALS['menuData'][] = array(
@ -120,9 +121,9 @@
}
//_debug_array($hook);
$GLOBALS['egw']->hooks->process($hook);
if (count($GLOBALS['menuData']) >= 1)
if (count($GLOBALS['menuData']) >= 1)
{
$result = $this->display_section($GLOBALS['menuData']);
$result = $this->display_section($GLOBALS['menuData'], $_account_id);
//clear $menuData
$GLOBALS['menuData'] = '';
return $result;
@ -135,4 +136,3 @@
}
}
}
?>