diff --git a/admin/src/Token.php b/admin/src/Token.php index 2d1887c23e..ee2f3ebb40 100644 --- a/admin/src/Token.php +++ b/admin/src/Token.php @@ -76,7 +76,7 @@ class Token !(new Api\Auth())->authenticate($GLOBALS['egw_info']['user']['account_lid'], $content['password'])) { Api\Etemplate::set_validation_error('password', lang('Password is invalid')); - unset($content['button']); + $button = null; } try { switch($button) @@ -127,6 +127,7 @@ class Token 'button[delete]' => !$content['token_id'], 'account_id' => empty($GLOBALS['egw_info']['user']['apps']['admin']) || static::APP !== 'admin', ]; + $GLOBALS['egw_info']['flags']['app_header'] = empty($content['token_id']) ? lang('Add token') : lang('Edit token'); $tmpl = new Api\Etemplate(self::APP.'.token.edit'); $tmpl->exec(static::APP.'.'.static::class.'.edit', $content, [], $readonlys, $content, 2); } @@ -191,7 +192,7 @@ class Token elseif(!empty($content['token']['action'])) { try { - Api\Framework::message($this->action($content['token']['action'], + Api\Framework::message(self::action($content['token']['action'], $content['token']['selected'], $content['token']['select_all'])); } catch (\Exception $ex) { @@ -285,7 +286,7 @@ class Token * @returns string with success message * @throws Api\Exception\AssertionFailed */ - protected function action($action, $selected, $select_all) + protected static function action($action, $selected, $select_all=false) { $success = 0; try { diff --git a/admin/templates/default/tokens.xet b/admin/templates/default/tokens.xet index 6ff4c90154..12e4616a24 100644 --- a/admin/templates/default/tokens.xet +++ b/admin/templates/default/tokens.xet @@ -5,7 +5,7 @@ - + diff --git a/preferences/src/Token.php b/preferences/src/Token.php index 01f8a415f8..71fc587c84 100644 --- a/preferences/src/Token.php +++ b/preferences/src/Token.php @@ -42,16 +42,26 @@ class Token extends Admin\Token 'prepend' => false, 'data' => [ 'token' => [ - 'default_cols' => '!account_id', 'add_action' => 'app.preferences.addToken', + 'no_account_id' => true, ]+self::get_nm_options(), ], 'preserve' => [ ], 'sel_options' => [ ], - 'save_callback' => __CLASS__.'::action', + 'save_callback' => __CLASS__.'::save_callback', ]; } + public static function save_callback(array &$content) + { + Api\Translation::add_app('admin'); + try { + Api\Framework::message(self::action($content['token']['action'], $content['token']['selected']), 'success'); + } + catch (\Exception $e) { + Api\Framework::message($e->getMessage(), 'error'); + } + } } \ No newline at end of file