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 '
'."\n"; -print ''; -print ''; -print ''; - +// Tokens info print '
'; print '
'; print ''; @@ -285,46 +304,39 @@ if (!empty($object->ldap_sid) && $object->status == 0) { } print ''."\n"; -//var_dump(showValueWithClipboardCPButton($token->token, 1, $token->token)); - // Token print ''; print ''; print ''."\n"; // Entity print ''; print ''; print ''."\n"; // Creation date print ''; print ''; print ''."\n"; // Modification date print ''; print ''; print ''."\n"; print '
'.$langs->trans("ApiToken").''; -print ''; -if (!empty($conf->use_javascript_ajax)) { - print img_picto($langs->transnoentities('Generate'), 'refresh', 'id="generate_api_key" class="linkobject paddingleft"'); -} +print showValueWithClipboardCPButton($token->token, 1, $token->token); print '
'.$langs->trans("Entity").''; -print ''; +print $token->entity; print '
'.$langs->trans("DateCreation").''; -print ''; +print $token->date_creation; print '
'.$langs->trans("DateModification").''; -print ''; +print $token->date_modification; print '
'; -print '
'; -print ''; -print ''.$langs->trans("Delete").''; +print '
'; +print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&tokenid='.$token->token_id.'&action=delete&token='.newToken(), '', $caneditperms); print '
'; print '
'; -print ''; print dol_get_fiche_end();