From ec79241dc2caae23ba82cf788727e1a92d9431fc Mon Sep 17 00:00:00 2001 From: yannis Date: Tue, 1 Jul 2025 16:09:12 +0200 Subject: [PATCH] feat: multicompany display for token list --- htdocs/user/api_token/list.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/user/api_token/list.php b/htdocs/user/api_token/list.php index 9af1dabfd96..c5eef1e14df 100644 --- a/htdocs/user/api_token/list.php +++ b/htdocs/user/api_token/list.php @@ -117,7 +117,7 @@ if ($user->id != $id && !$canreaduser) { $arrayfields = array( 'oat.token' => array('label' => "ApiToken", 'checked' => '1'), - 'oat.entity' => array('label' => "Entity", 'checked' => '1'), + 'e.label' => array('label' => "Entity", 'checked' => '1'), 'oat.datec' => array('label' => "DateCreation", 'checked' => '1'), 'oat.tms' => array('label' => "DateModification", 'checked' => '1'), ); @@ -235,7 +235,13 @@ if (!getDolGlobalInt('MAIN_DISABLE_FULL_SCANLIST')) { } $sql = "SELECT oat.rowid as token_id, oat.token, oat.entity, oat.state as rights, oat.datec as date_creation, oat.tms as date_modification"; +if (isModEnabled('multicompany')) { + $sql .= ", e.label as entity_name"; +} $sql .= " FROM ".MAIN_DB_PREFIX."oauth_token as oat"; +if (isModEnabled('multicompany')) { + $sql .= " JOIN ".$db->prefix()."entity as e ON oat.entity = e.rowid"; +} $sql .= " WHERE oat.fk_user = ".((int) $object->id); $sql .= " AND entity IN (".$conf->entity.")"; $sql .= " AND service = 'dolibarr_rest_api'"; @@ -412,9 +418,9 @@ if (empty($reshook)) { } // Entity - if (!empty($arrayfields['oat.entity']['checked']) && isModEnabled('multicompany')) { + if (!empty($arrayfields['e.label']['checked']) && isModEnabled('multicompany')) { print ''; - print ' 0 ? " disabled" : "").'>'; + print ''; print ''; } @@ -466,8 +472,8 @@ if (empty($reshook)) { if (!empty($arrayfields['oat.token']['checked'])) { print_liste_field_titre($arrayfields['oat.token']['label'], $_SERVER["PHP_SELF"], 'oat.token', '', $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['oat.entity']['checked']) && isModEnabled('multicompany')) { - print_liste_field_titre($arrayfields['oat.entity']['label'], $_SERVER["PHP_SELF"], 'oat.entity', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['e.label']['checked']) && isModEnabled('multicompany')) { + print_liste_field_titre($arrayfields['e.label']['label'], $_SERVER["PHP_SELF"], 'e.label', '', $param, '', $sortfield, $sortorder); } print ''.$langs->trans("NumberOfPermissions").''; if (!empty($arrayfields['oat.datec']['checked'])) { @@ -514,7 +520,7 @@ if (empty($reshook)) { print ''; if (isModEnabled('multicompany')) { print ''; - print $obj->entity; + print $obj->entity_name; print ''; } print '';