dolibarr 24.0.0-beta
apitoken_list.tpl.php
1<?php
2/* Copyright (C) 2014-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
47'
48@phan-var-force Propal|Contrat|Commande|Facture|Expedition|Delivery|FactureFournisseur|FactureFournisseur|SupplierProposal $object
49@phan-var-force array<string,array{label:string,checked?:string,position?:int,help?:string,enabled?:string}> $arrayfields
50@phan-var-force int $num
51@phan-var-force string $search_user
52@phan-var-force string $search_entity
53@phan-var-force string $search_datec_start
54@phan-var-force string $search_datec_end
55@phan-var-force string $search_tms_start
56@phan-var-force string $search_tms_end
57@phan-var-force int $colspan
58';
59
60echo "<!-- BEGIN PHP TEMPLATE apitoken_list.tpl.php -->\n";
61
62print '<table class="noborder centpercent">';
63
64print '<tr class="liste_titre_filter">';
65
66// Action buttons
67if ($conf->main_checkbox_left_column) {
68 print '<td class="liste_titre center">';
69 $searchpicto = $form->showFilterButtons('left');
70 print $searchpicto;
71 print '</td>';
72}
73
74// Token string
75// We don't search out tokens because it is encrypted in database
76print '<td class="liste_titre"></td>';
77
78// User
79if (!empty($arrayfields['u.login']['checked'])) {
80 print '<td class="liste_titre">';
81 print '<input class="flat maxwidth100" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
82 print '</td>';
83}
84
85// Number of perms
86// We don't search out number of perms because it is a string field,
87// and we don't want to count into it with sql query
88print '<td class="liste_titre"></td>';
89
90// Date creation
91if (!empty($arrayfields['oat.datec']['checked'])) {
92 print '<td class="liste_titre center">';
93 print '<div class="nowrapfordate">';
94 print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
95 print '</div>';
96 print '<div class="nowrapfordate">';
97 print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
98 print '</div>';
99 print '</td>';
100}
101
102// Date modification
103if (!empty($arrayfields['oat.tms']['checked'])) {
104 print '<td class="liste_titre center">';
105 print '<div class="nowrapfordate">';
106 print $form->selectDate($search_tms_start ? $search_tms_start : -1, 'search_tms_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
107 print '</div>';
108 print '<div class="nowrapfordate">';
109 print $form->selectDate($search_tms_end ? $search_tms_end : -1, 'search_tms_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
110 print '</div>';
111 print '</td>';
112}
113
114// Action buttons
115if (!$conf->main_checkbox_left_column) {
116 print '<td class="liste_titre center">';
117 $searchpicto = $form->showFilterButtons('left');
118 print $searchpicto;
119 print '</td>';
120}
121
122print "</tr>";
123
124print '<tr class="liste_titre">';
125if ($conf->main_checkbox_left_column) {
126 print '<th class="wrapcolumntitle center maxwidthsearch liste_titre">';
127 print $form->showCheckAddButtons('checkforselect', 1);
128 print '</th>';
129}
130print '<th class="liste_titre">'.$langs->trans("Token").'</th>';
131if (!empty($arrayfields['u.login']['checked'])) {
132 // @phan-suppress-next-line PhanTypeInvalidDimOffset
133 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder);
134}
135print '<th class="liste_titre right">'.$langs->trans("LastAccess").'</th>';
136if (!empty($arrayfields['oat.datec']['checked'])) {
137 print_liste_field_titre($arrayfields['oat.datec']['label'], $_SERVER["PHP_SELF"], 'oat.datec', '', $param, '', $sortfield, $sortorder, 'center ');
138}
139if (!empty($arrayfields['oat.tms']['checked'])) {
140 print_liste_field_titre($arrayfields['oat.tms']['label'], $_SERVER["PHP_SELF"], 'oat.tms', '', $param, '', $sortfield, $sortorder, 'center ');
141}
142if (!$conf->main_checkbox_left_column) {
143 print '<th class="wrapcolumntitle center maxwidthsearch liste_titre">';
144 print $form->showCheckAddButtons('checkforselect', 1);
145 print '</th>';
146}
147print '</tr>';
148
149// List of tokens of user
150$i = 0;
151$imaxinloop = ($limit ? min($num, $limit) : $num);
152if ($num > 0) {
153 while ($i < $imaxinloop) {
154 // Compute number of perms
155 $obj = $db->fetch_object($resql);
156
157 $useridparam = isset($obj->fk_user) ? $obj->fk_user : $object->id;
158
159 if (isset($obj->fk_user)) {
160 $currentuser = new User($db);
161 $currentuser->fetch($obj->fk_user);
162 } else {
163 $currentuser = $object;
164 }
165
166 /*
167 $numperms = 0;
168 if (!empty($obj->rights)) {
169 $numperms = count(explode(",", $obj->rights));
170 } elseif (!(strlen($obj->rights) == 1 && substr($obj->rights, 0, 1) == 0)) {
171 $currentuser->loadRights();
172 $numperms = $currentuser->nb_rights;
173 }
174 */
175
176 print '<tr class="oddeven">';
177 // Action column
178 if ($conf->main_checkbox_left_column) {
179 print '<td class="nowrap center">';
180 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
181 $selected = 0;
182 if (in_array($obj->rowid, $arrayofselected)) {
183 $selected = 1;
184 }
185 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
186 }
187 print '</td>';
188 }
189 print '<td>';
190 print '<a href="'.DOL_URL_ROOT.'/user/api_token/card.php?id='.$useridparam.'&tokenid='.$obj->rowid.'">';
191 print dolDecrypt($obj->tokenstring);
192 print '</a>';
193 print '</td>';
194 if (!empty($arrayfields['u.login']['checked'])) {
195 print '<td>';
196 print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->fk_user.'">';
197 print $currentuser->getNomUrl(1);
198 print '</a>';
199 print '</td>';
200 }
201 print '<td class="right">';
202 print dol_print_date($db->jdate($obj->lastaccess));
203 print '</td>';
204 print '<td class="center">';
205 print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
206 print '</td>';
207 print '<td class="center">';
208 print dol_print_date($db->jdate($obj->date_modification), 'dayhour');
209 print '</td>';
210 if (!$conf->main_checkbox_left_column) {
211 print '<td class="nowrap center">';
212 if ($massactionbutton || $massaction) {
213 $selected = 0;
214 if (in_array($obj->rowid, $arrayofselected)) {
215 $selected = 1;
216 }
217 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
218 }
219 print '</td>';
220 }
221 print '</tr>';
222 $i++;
223 }
224} else {
225 if (isModEnabled('multicompany')) {
226 $colspan++;
227 }
228 print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
229}
230
231print "</table>";
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage Dolibarr users.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
isModEnabled($module)
Is Dolibarr module enabled.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.