From dc01e804fa4161611e98bb22e55660b16b418daa Mon Sep 17 00:00:00 2001 From: yannis Date: Fri, 27 Jun 2025 15:46:01 +0200 Subject: [PATCH] feat: update fields and date format display --- htdocs/user/api_token/card.php | 16 ++++++++++++---- htdocs/user/api_token/list.php | 4 ++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/user/api_token/card.php b/htdocs/user/api_token/card.php index 64faf0f38d2..2cb7ce61873 100644 --- a/htdocs/user/api_token/card.php +++ b/htdocs/user/api_token/card.php @@ -208,7 +208,7 @@ if (empty($reshook)) { dol_print_error($db); } - $token->rights = $newrigths; + $reloadtoken = true; } if ($action == 'delrights' && $caneditperms && $confirm == 'yes') { @@ -232,7 +232,7 @@ if (empty($reshook)) { dol_print_error($db); } - $token->rights = $newrigths; + $reloadtoken = true; } if ($action == 'add') { @@ -277,6 +277,14 @@ if (empty($reshook)) { } } +if (isset($reloadtoken)) { // If we add or del rights, we want to refresh the token with its new updated fields + $sql = "SELECT ot.rowid as token_id, ot.token, ot.entity, ot.state as rights, ot.datec as date_creation, ot.tms as date_modification"; + $sql .= " FROM ".MAIN_DB_PREFIX."oauth_token as ot"; + $sql .= " WHERE ot.rowid = ".((int) $tokenid); + + $resql = $db->query($sql); + $token = $db->fetch_object($resql); +} /* * View @@ -393,14 +401,14 @@ if ($action == 'create') { // Creation date print ''.$langs->trans("DateCreation").''; print ''; - print $token->date_creation; + print dol_print_date($db->jdate($token->date_creation), 'day'); print ''; print ''."\n"; // Modification date print ''.$langs->trans("DateModification").''; print ''; - print $token->date_modification; + print dol_print_date($db->jdate($token->date_modification), 'day'); print ''; print ''."\n"; diff --git a/htdocs/user/api_token/list.php b/htdocs/user/api_token/list.php index b6d22fd67b6..1ea0ad969fe 100644 --- a/htdocs/user/api_token/list.php +++ b/htdocs/user/api_token/list.php @@ -472,10 +472,10 @@ if (empty($reshook)) { print $numperms; print ''; print ''; - print $obj->date_creation; + print dol_print_date($db->jdate($obj->date_creation), 'day'); print ''; print ''; - print $obj->date_modification; + print dol_print_date($db->jdate($obj->date_modification), 'day'); print ''; if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print '';