diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index 19402459a7a..56c4f99a6cb 100644 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -148,3 +148,5 @@ ApiToken=Api token ListOfTokensForUser=List of tokens for this user ListOfRightsForToken=List of rights for this token NumberOfPermissions=Number of permissions +DeleteToken=Delete token +ConfirmDeleteToken=Are you sure you want to delete this token? diff --git a/htdocs/user/api_token/card.php b/htdocs/user/api_token/card.php index f8668b85051..50a3ac1fa12 100644 --- a/htdocs/user/api_token/card.php +++ b/htdocs/user/api_token/card.php @@ -223,6 +223,21 @@ if (empty($reshook)) { $token->rights = $newrigths; } + + elseif ($action == 'confirm_delete' && $confirm == 'yes' && $caneditfield) { + // Remove token + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token"; + $sql .= " WHERE rowid = '".$tokenid."'"; + + $resql = $db->query($sql); + + if ($resql) { + header('Location: list.php?id='.$object->id); + exit; + } else { + dol_print_error($db); + } + } } @@ -236,6 +251,14 @@ $help_url = ''; llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-user page-card_param_ihm'); +$formconfirm = ''; + +if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&tokenid='.$token->token_id, $langs->trans('DeleteToken'), $langs->trans('ConfirmDeleteToken'), 'confirm_delete', '', 0, 1); +} + +print $formconfirm; + $arrayofselected = is_array($toselect) ? $toselect : array(); $head = user_prepare_head($object); @@ -255,11 +278,7 @@ $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->tra dol_banner_tab($object, 'id', $linkback, $user->hasRight("user", "user", "read") || $user->admin, 'rowid', 'ref', $morehtmlref); -print '