26require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/user/class/usergroup.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/usergroups.lib.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/ldap.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
64$langs->loadLangs(array(
'users',
'companies',
'ldap',
'admin',
'hrm',
'stocks',
'other'));
67$action =
GETPOST(
'action',
'aZ09');
68$mode =
GETPOST(
'mode',
'alpha');
69$confirm =
GETPOST(
'confirm',
'alpha');
70$optioncss =
GETPOST(
'optioncss',
'aZ09');
71$cancel =
GETPOST(
'cancel',
'alpha');
72$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'usercredentials';
73$backtopage =
GETPOST(
'backtopage');
74$backtopageforcancel =
GETPOST(
'backtopageforcancel');
77$search_secret_key =
GETPOST(
'search_secret_key');
81$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
82$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
84if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
88$offset = $limit * $page;
93if (empty($id) && $action !=
'add' && $action !=
'create') {
101$extrafields->fetch_name_optionals_label(
$object->table_element);
104$hookmanager->initHooks(array(
'usercard',
'globalcard'));
109 $res =
$object->fetch($id,
'',
'', 1);
114if ($user->socid > 0) {
115 $socid = $user->socid;
121$permissiontoadd = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")) && (empty($user->socid) || $user->socid ==
$object->socid);
122$permissiontoread = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"read")) && (empty($user->socid) || $user->socid ==
$object->socid);
123$permissiontoedit = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"write")) && (empty($user->socid) || $user->socid ==
$object->socid);
124$permissiontodisable = (!empty($user->admin) || $user->hasRight(
"user",
"user",
"delete")) && (empty($user->socid) || $user->socid ==
$object->socid);
125$permissiontoreadgroup = $permissiontoread;
126$permissiontoeditgroup = $permissiontoedit;
128 $permissiontoreadgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"read")) && (empty($user->socid) || $user->socid ==
$object->socid);
129 $permissiontoeditgroup = (!empty($user->admin) || $user->hasRight(
"user",
"group_advance",
"write")) && (empty($user->socid) || $user->socid ==
$object->socid);
132$permissiontoclonesuperadmin = ($permissiontoadd && empty($user->entity));
133$permissiontocloneadmin = ($permissiontoadd && !empty($user->admin));
134$permissiontocloneuser = $permissiontoadd;
137 $permissiontoclonesuperadmin =
false;
138 $permissiontocloneadmin =
false;
139 $permissiontocloneuser =
false;
142if ($user->id != $id && !$permissiontoread) {
146$caneditpasswordandsee =
false;
147$caneditpasswordandsend =
false;
150$permissiontoeditpasswordandsee =
false;
151$permissiontoeditpasswordandsend =
false;
154 $permissiontoedit = ((($user->id ==
$id) && $user->hasRight(
"user",
"self",
"write")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"write"))) && (empty($user->socid) || $user->socid ==
$object->socid);
155 $permissiontoeditpasswordandsee = ((($user->id ==
$id) && $user->hasRight(
"user",
"self",
"password")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"password") && $user->admin)) && (empty($user->socid) || $user->socid ==
$object->socid);
156 $permissiontoeditpasswordandsend = ((($user->id ==
$id) && $user->hasRight(
"user",
"self",
"password")) || (($user->id != $id) && $user->hasRight(
"user",
"user",
"password"))) && (empty($user->socid) || $user->socid ==
$object->socid);
164$parameters = array(
'id' => $id,
'socid' => $socid,
'group' => $group,
'caneditgroup' => $permissiontoeditgroup);
165$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
170if (empty($reshook)) {
171 $backurlforlist = DOL_URL_ROOT.
'/user/list.php';
173 if (empty($backtopage) || ($cancel && empty($id))) {
174 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
175 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
176 $backtopage = $backurlforlist;
178 $backtopage = DOL_URL_ROOT.
'/user/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
184 if (!empty($backtopageforcancel)) {
185 header(
"Location: ".$backtopageforcancel);
187 } elseif (!empty($backtopage)) {
188 header(
"Location: ".$backtopage);
195 if ($action ==
'addtotp' && $permissiontoadd) {
212$form =
new Form($db);
215$title = $person_name.
" - ".$langs->trans(
'Credentials');
218llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-user page-credentials');
224print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
225print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
226print
'<input type="hidden" name="token" value="'.newToken().
'">';
227print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
228print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
229print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
230print
'<input type="hidden" name="page" value="'.$page.
'">';
231print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
232print
'<input type="hidden" name="page_y" value="">';
233print
'<input type="hidden" name="mode" value="'.$mode.
'">';
237$newcardbutton =
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=addtotp&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF']),
'', $permissiontoadd ? 1 : 0);
240$listoftotps = array();
241$sql =
"SELECT rowid, token, state, restricted_ips, datec, tms, lastaccess FROM ".$db->prefix().
"oauth_token";
242$sql .=
" WHERE fk_user = ".((int)
$object->id).
" AND service = 'dolibarr_totp'";
243$resql = $db->query($sql);
245 while ($obj = $db->fetch_object($resql)) {
246 $listoftotps = array(
'id' => $obj->rowid);
252$nbtotalofrecords = $num = count($listoftotps);
254$massactionbutton =
'';
256print_barre_liste($langs->trans(
"TOTP"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
$object->picto, 0, $newcardbutton,
'', $limit, -1, 0, 1);
267print
'<div class="div-table-responsive">';
268print
'<table class="tagtable nobottomiftotal liste">'.
"\n";
272print
'<tr class="liste_titre_filter">';
275 print
'<td class="liste_titre center maxwidthsearch">';
276 $searchpicto = $form->showFilterButtons(
'left');
280print
'<td class="liste_titre"><input type="text" name="search_secret_key" class="maxwidth50" value="'.$search_secret_key.
'"></td>';
283 print
'<td class="liste_titre maxwidthsearch">';
284 $searchpicto = $form->showFilterButtons();
295print
'<tr class="liste_titre">';
297 print
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
300print_liste_field_titre(
'TOTPSecretKey', $_SERVER[
'PHP_SELF'],
"u.rowid",
'', $param,
'', $sortfield, $sortorder);
304 print
getTitleFieldOfList(
'', 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
309foreach ($listoftotps as $totp) {
324if (empty($listoftotps)) {
325 print
'<tr><td colspan="2"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
328print
'</table>'.
"\n";
334include_once DOL_DOCUMENT_ROOT.
'/core/lib/security2.lib.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dolJSToSetRandomPassword($htmlname, $htmlnameofbutton='generate_token', $generic=1)
Output javascript to autoset a generated password using default module into a HTML element.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.