dolibarr 23.0.3
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
45'
46@phan-var-force Propal|Contrat|Commande|Facture|Expedition|Delivery|FactureFournisseur|FactureFournisseur|SupplierProposal $object
47@phan-var-force array<string,array{label:string,checked?:string,position?:int,help?:string,enabled?:string}> $arrayfields
48@phan-var-force int $num
49@phan-var-force string $search_user
50@phan-var-force string $search_entity
51@phan-var-force string $search_datec_start
52@phan-var-force string $search_datec_end
53@phan-var-force string $search_tms_start
54@phan-var-force string $search_tms_end
55@phan-var-force int $colspan
56';
57
58echo "<!-- BEGIN PHP TEMPLATE apitoken_list.tpl.php -->\n";
59
60print '<table class="noborder centpercent">';
61
62print '<tr class="liste_titre_filter">';
63
64// Action buttons
65if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
66 print '<td class="liste_titre center">';
67 $searchpicto = $form->showFilterButtons('left');
68 print $searchpicto;
69 print '</td>';
70}
71
72// Token string
73// We don't search out tokens because it is encrypted in database
74print '<td class="liste_titre"></td>';
75
76// User
77if (!empty($arrayfields['u.login']['checked'])) {
78 print '<td class="liste_titre">';
79 print '<input class="flat maxwidth100" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
80 print '</td>';
81}
82
83// Number of perms
84// We don't search out number of perms because it is a string field,
85// and we don't want to count into it with sql query
86print '<td class="liste_titre"></td>';
87
88// Date creation
89if (!empty($arrayfields['oat.datec']['checked'])) {
90 print '<td class="liste_titre center">';
91 print '<div class="nowrapfordate">';
92 print $form->selectDate($search_datec_start ? $search_datec_start : -1, 'search_datec_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
93 print '</div>';
94 print '<div class="nowrapfordate">';
95 print $form->selectDate($search_datec_end ? $search_datec_end : -1, 'search_datec_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
96 print '</div>';
97 print '</td>';
98}
99
100// Date modification
101if (!empty($arrayfields['oat.tms']['checked'])) {
102 print '<td class="liste_titre center">';
103 print '<div class="nowrapfordate">';
104 print $form->selectDate($search_tms_start ? $search_tms_start : -1, 'search_tms_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
105 print '</div>';
106 print '<div class="nowrapfordate">';
107 print $form->selectDate($search_tms_end ? $search_tms_end : -1, 'search_tms_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
108 print '</div>';
109 print '</td>';
110}
111
112// Action buttons
113if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
114 print '<td class="liste_titre center">';
115 $searchpicto = $form->showFilterButtons('left');
116 print $searchpicto;
117 print '</td>';
118}
119
120print "</tr>";
121
122print '<tr class="liste_titre">';
123if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
124 print '<th class="wrapcolumntitle center maxwidthsearch liste_titre">';
125 print $form->showCheckAddButtons('checkforselect', 1);
126 print '</th>';
127}
128print '<th class="liste_titre">'.$langs->trans("Token").'</th>';
129if (!empty($arrayfields['u.login']['checked'])) {
130 // @phan-suppress-next-line PhanTypeInvalidDimOffset
131 print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, '', $sortfield, $sortorder);
132}
133print '<th class="liste_titre right">'.$langs->trans("LastAccess").'</th>';
134if (!empty($arrayfields['oat.datec']['checked'])) {
135 print_liste_field_titre($arrayfields['oat.datec']['label'], $_SERVER["PHP_SELF"], 'oat.datec', '', $param, '', $sortfield, $sortorder, 'center ');
136}
137if (!empty($arrayfields['oat.tms']['checked'])) {
138 print_liste_field_titre($arrayfields['oat.tms']['label'], $_SERVER["PHP_SELF"], 'oat.tms', '', $param, '', $sortfield, $sortorder, 'center ');
139}
140if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
141 print '<th class="wrapcolumntitle center maxwidthsearch liste_titre">';
142 print $form->showCheckAddButtons('checkforselect', 1);
143 print '</th>';
144}
145print '</tr>';
146
147// List of tokens of user
148$i = 0;
149$imaxinloop = ($limit ? min($num, $limit) : $num);
150if ($num > 0) {
151 while ($i < $imaxinloop) {
152 // Compute number of perms
153 $obj = $db->fetch_object($resql);
154
155 $useridparam = isset($obj->fk_user) ? $obj->fk_user : $object->id;
156
157 if (isset($obj->fk_user)) {
158 $currentuser = new User($db);
159 $currentuser->fetch($obj->fk_user);
160 } else {
161 $currentuser = $object;
162 }
163
164 /*
165 $numperms = 0;
166 if (!empty($obj->rights)) {
167 $numperms = count(explode(",", $obj->rights));
168 } elseif (!(strlen($obj->rights) == 1 && substr($obj->rights, 0, 1) == 0)) {
169 $currentuser->loadRights();
170 $numperms = $currentuser->nb_rights;
171 }
172 */
173
174 print '<tr class="oddeven">';
175 // Action column
176 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
177 print '<td class="nowrap center">';
178 if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
179 $selected = 0;
180 if (in_array($obj->rowid, $arrayofselected)) {
181 $selected = 1;
182 }
183 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
184 }
185 print '</td>';
186 }
187 print '<td>';
188 print '<a href="'.DOL_URL_ROOT.'/user/api_token/card.php?id='.$useridparam.'&tokenid='.$obj->rowid.'">';
189 print dolDecrypt($obj->tokenstring);
190 print '</a>';
191 print '</td>';
192 if (!empty($arrayfields['u.login']['checked'])) {
193 print '<td>';
194 print '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->fk_user.'">';
195 print $currentuser->getNomUrl(1);
196 print '</a>';
197 print '</td>';
198 }
199 print '<td class="right">';
200 print dol_print_date($db->jdate($obj->lastaccess));
201 print '</td>';
202 print '<td class="center">';
203 print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
204 print '</td>';
205 print '<td class="center">';
206 print dol_print_date($db->jdate($obj->date_modification), 'dayhour');
207 print '</td>';
208 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
209 print '<td class="nowrap center">';
210 if ($massactionbutton || $massaction) {
211 $selected = 0;
212 if (in_array($obj->rowid, $arrayofselected)) {
213 $selected = 1;
214 }
215 print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
216 }
217 print '</td>';
218 }
219 print '</tr>';
220 $i++;
221 }
222} else {
223 if (isModEnabled('multicompany')) {
224 $colspan++;
225 }
226 print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
227}
228
229print "</table>";
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage Dolibarr users.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.