* Admin: accounts could not be deactivated

This commit is contained in:
Ralf Becker 2014-06-04 20:02:01 +00:00
parent 470cf39e94
commit 632a7cc18d
2 changed files with 19 additions and 4 deletions

View File

@ -132,7 +132,7 @@ class admin_account
'changepassword', 'anonymous', 'mustchangepassword', 'changepassword', 'anonymous', 'mustchangepassword',
'account_passwd', 'account_passwd2', 'account_passwd', 'account_passwd2',
'account_primary_group', 'account_primary_group',
'account_expires', 'account_status', 'account_expires'
) as $c_name => $a_name) ) as $c_name => $a_name)
{ {
if (is_int($c_name)) $c_name = $a_name; if (is_int($c_name)) $c_name = $a_name;
@ -140,7 +140,8 @@ class admin_account
switch($a_name) switch($a_name)
{ {
case 'account_expires': case 'account_expires':
$account[$a_name] = $content[$c_name] ? $content[$c_name] : 'never'; $account[$a_name] = $content[$c_name] ? $content[$c_name] :
($content['account_status'] ? 'never' : 'already');
break; break;
case 'changepassword': // boolean values: admin_cmd_edit_user understands '' as NOT set case 'changepassword': // boolean values: admin_cmd_edit_user understands '' as NOT set

View File

@ -88,8 +88,17 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
{ {
throw new egw_exception_wrong_userinput(lang('The two passwords are not the same'),0); throw new egw_exception_wrong_userinput(lang('The two passwords are not the same'),0);
} }
$data['account_expires'] = $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account); $expires = self::_parse_expired($data['account_expires'],(boolean)$this->account);
$data['account_status'] = is_null($expires) ? null : ($expires == -1 || $expires > time() ? 'A' : ''); if ($expires === 0) // deactivated
{
$data['account_expires'] = -1;
$data['account_status'] = '';
}
else
{
$data['account_expires'] = $expires;
$data['account_status'] = is_null($expires) ? null : ($expires == -1 || $expires > time() ? 'A' : '');
}
$data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'],$this->account ? null : true); $data['changepassword'] = admin_cmd::parse_boolean($data['changepassword'],$this->account ? null : true);
$data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'],$this->account ? null : false); $data['anonymous'] = admin_cmd::parse_boolean($data['anonymous'],$this->account ? null : false);
@ -138,6 +147,11 @@ class admin_cmd_edit_user extends admin_cmd_change_pw
if (is_null($value)) $value = $old[$name]; if (is_null($value)) $value = $old[$name];
} }
} }
// hook allowing apps to intercept adding/editing accounts before saving them
$GLOBALS['egw']->hooks->process($data+array(
'location' => $this->account ? 'pre_editaccount' : 'pre_addaccount',
),False,True); // called for every app now, not only enabled ones)
if (!($data['account_id'] = admin_cmd::$accounts->save($data))) if (!($data['account_id'] = admin_cmd::$accounts->save($data)))
{ {
//_debug_array($data); //_debug_array($data);