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:56:20 +00:00
parent f98770409a
commit f0a6c30faf
3 changed files with 21 additions and 17 deletions

View File

@ -220,13 +220,17 @@
if(!$errors) if(!$errors)
{ {
$new_user = !$userData['account_id'];
$passwd = $userData['account_passwd'];
$errors = $this->save_user($userData); $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( $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) ),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; return $errors ? $errors : true;
} }

View File

@ -1561,7 +1561,7 @@
// $menuClass =& CreateObject('admin.uimenuclass'); // $menuClass =& CreateObject('admin.uimenuclass');
// This is now using ExecMethod() // This is now using ExecMethod()
$GLOBALS['account_id'] = $_account_id; $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'); echo $t->fp('out','form');
} }

View File

@ -42,7 +42,7 @@
// 'Login History' => array('/index.php','menuaction=admin.uiaccess_history.list') // 'Login History' => array('/index.php','menuaction=admin.uiaccess_history.list')
// ); // );
// This allows extra data to be sent along // This allows extra data to be sent along
function display_section($_menuData) function display_section($_menuData, $_account_id)
{ {
$i=0; $i=0;
@ -53,11 +53,11 @@
{ {
if (!empty($value['extradata'])) 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 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']); $this->section_item($link,lang($value['description']),($i%2) ? "row_on": "row_off",$value['options']);
$i++; $i++;
@ -82,9 +82,12 @@
} }
// create the html code for the menu // 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) switch ($_hookname)
{ {
case 'edit_user': case 'edit_user':
@ -93,7 +96,6 @@
'url' => '/index.php', 'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.edit_user' '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; break;
case 'view_user': case 'view_user':
$GLOBALS['menuData'][] = array( $GLOBALS['menuData'][] = array(
@ -101,7 +103,6 @@
'url' => '/index.php', 'url' => '/index.php',
'extradata' => 'menuaction=admin.uiaccounts.view_user' '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; break;
case 'edit_group': case 'edit_group':
$GLOBALS['menuData'][] = array( $GLOBALS['menuData'][] = array(
@ -122,7 +123,7 @@
$GLOBALS['egw']->hooks->process($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 //clear $menuData
$GLOBALS['menuData'] = ''; $GLOBALS['menuData'] = '';
return $result; return $result;
@ -135,4 +136,3 @@
} }
} }
} }
?>