1{* $Id$ *}
2{if !$ts.ajax}
3	{title help="Users Management" admpage="login" url="tiki-adminusers.php"}{tr}Admin Users{/tr}{/title}
4
5	<div class="t_navbar mb-4">
6		{if $tiki_p_admin eq 'y'} {* only full admins can manage groups, not tiki_p_admin_users *}
7			{button href="tiki-admingroups.php" class="btn btn-primary" _type="link" _icon_name="group" _text="{tr}Admin Groups{/tr}"}
8		{/if}
9		{if $tiki_p_admin eq 'y'}
10			{permission_link mode=button_link}
11		{/if}
12		{if isset($userinfo.userId)}
13			{button href="?add=1" class="btn btn-primary" _text="{tr}Add a New User{/tr}"}
14		{/if}
15		{if $prefs.feature_invite eq 'y' and $tiki_p_invite eq 'y'}
16			{button href="tiki-list_invite.php" _type="link" _icon_name="thumbs-up" _text="{tr}Invitation List{/tr}"}
17		{/if}
18	</div>
19
20	{if $prefs.feature_intertiki eq 'y' and ($prefs.feature_intertiki_import_groups eq 'y' or $prefs.feature_intertiki_import_preferences eq 'y')}
21		{remarksbox type="warning" title="{tr}Warning{/tr}"}
22			{if $prefs.feature_intertiki_import_groups eq 'y'}{tr}Since this Tiki site is in slave mode and imports groups, the master groups will be automatically reimported at each login{/tr}{/if}
23			{if $prefs.feature_intertiki_import_preferences eq 'y'}{tr}Since this Tiki site is in slave mode and imports preferences, the master user preferences will be automatically reimported at each login{/tr}{/if}
24		{/remarksbox}
25	{/if}
26{/if}
27{tabset name='tabs_adminusers'}
28
29	{* ---------------------- tab with list -------------------- *}
30	{tab name="{tr}Users{/tr}"}
31		{if !$ts.ajax}
32			<h2>{tr}Users{/tr}</h2>
33			{if !$ts.enabled}
34				<form method="get" action="tiki-adminusers.php">
35					<div class="form-group row">
36						<label class="col-form-label col-sm-5" for="find">{tr}Find{/tr}</label>
37						<div class="col-sm-7">
38							<input type="text" class="form-control form-control-sm" id="find" name="find" value="{$find|escape}">
39						</div>
40					</div>
41					<div class="form-group row">
42						<label class="col-form-label col-sm-5" for="numrows">{tr}Number of displayed rows{/tr}</label>
43						<div class="col-sm-7">
44							<input class="form-control form-control-sm" type="number" id="numrows" name="numrows" value="{$numrows|escape}">
45						</div>
46					</div>
47					<div class="form-group row">
48						<div class="col-sm-7 offset-sm-5">
49							<a href="javascript:toggleBlock('search')" class="link">
50								{icon name='add' alt="{tr}more{/tr}"}&nbsp;{tr}More Criteria{/tr}
51							</a>
52						</div>
53					</div>
54					{autocomplete element='#find' type='username'}
55					<div class="col-sm-12" id="search" {if $filterGroup or $filterEmail}style="display:block;"{else}style="display:none;"{/if}>
56						<div class="form-group row">
57							<label class="col-form-label col-sm-5" for="filterGroup">{tr}Group (direct){/tr}</label>
58							<div class="col-sm-7">
59								<select class="form-control form-control-sm" name="filterGroup" id="filterGroup">
60									<option value=""></option>
61									{section name=ix loop=$all_groups}
62										{if $all_groups[ix] != 'Registered' && $all_groups[ix] != 'Anonymous'}
63											<option value="{$all_groups[ix]|escape}" {if $filterGroup eq $all_groups[ix]}selected{/if}>{$all_groups[ix]|escape}</option>
64										{/if}
65									{/section}
66								</select>
67							</div>
68						</div>
69						<div class="form-group row">
70							<div class="offset-sm-5 col-sm-7">
71								<div class="form-check">
72									<label class="form-check-label">
73										<input id="filterEmailNotConfirmed" class="form-check-input" name="filterEmailNotConfirmed" type="checkbox"{if !empty($smarty.request.filterEmailNotConfirmed)} checked="checked"{/if}>{tr}Email not confirmed{/tr}
74									</label>
75								</div>
76							</div>
77						</div>
78						<div class="form-group row">
79							<div class="offset-sm-5 col-sm-7">
80								<div class="form-check">
81									<label class="form-check-label">
82										<input class="form-check-input" id="filterNeverLoggedIn" name="filterNeverLoggedIn" type="checkbox"{if !empty($smarty.request.filterNeverLoggedIn)} checked="checked"{/if}>{tr}Never logged in{/tr}
83									</label>
84								</div>
85							</div>
86						</div>
87						<div class="form-group row">
88							<div class="offset-sm-5 col-sm-7">
89								<div class="form-check">
90									<label class="form-check-label">
91										<input class="form-check-input" id="filterNotValidated" name="filterNotValidated" type="checkbox"{if !empty($smarty.request.filterNotValidated)} checked="checked"{/if}>{tr}User not validated{/tr}
92									</label>
93								</div>
94							</div>
95						</div>
96					</div>
97					<div class="form-group row">
98						<div class="col-sm-7 offset-sm-5">
99							<input type="hidden" name="sort_mode" value="{$sort_mode|escape}">
100							<input type="submit" class="btn btn-primary btn-sm" value="{tr}Find{/tr}" name="search">
101						</div>
102					</div>
103				</form>
104			{/if}
105			{if ($cant > $numrows or !empty($initial)) && !$ts.enabled}
106				{initials_filter_links}
107			{/if}
108			<form name="checkform" id="checkform" method="post">
109				<div id="{$ts.tableid}-div" {if $ts.enabled}style="visibility:hidden;"{/if}>
110					<div class="{if $js}table-responsive{/if} user-table ts-wrapperdiv">
111		{/if}
112						{* Use css menus as fallback for item dropdown action menu if javascript is not being used *}
113						<table id="{$ts.tableid}" class="table normal table-striped table-hover" data-count="{$cant|escape}">
114							{* Note: th element ids here need to match those at /lib/core/Table/Settings/TikiAdminusers.php
115							for tablesorter to work properly *}
116							{if !$ts.ajax}
117								<thead>
118									<tr>
119										<th id="checkbox">
120											{if $users}
121												{select_all checkbox_names='checked[]'}
122											{/if}
123										</th>
124										<th id="user">{self_link _sort_arg='sort_mode' _sort_field='login'}{tr}User{/tr}{/self_link}</th>
125										{if $prefs.login_is_email neq 'y'}
126											<th id="email">{self_link _sort_arg='sort_mode' _sort_field='email'}{tr}Email{/tr}{/self_link}</th>
127										{/if}
128										{if $prefs.auth_method eq 'openid'}
129											<th id="openid">{self_link _sort_arg='sort_mode' _sort_field='openID'}{tr}OpenID{/tr}{/self_link}</th>
130										{/if}
131										<th id="lastlogin">{self_link _sort_arg='sort_mode' _sort_field='currentLogin'}{tr}Last login{/tr}{/self_link}</th>
132										<th id="registered">{self_link _sort_arg='sort_mode' _sort_field='created'}{tr}Registered{/tr}{/self_link}</th>
133										<th id="groups">{tr}Groups{/tr}</th>
134										<th id="actions"></th>
135									</tr>
136								</thead>
137							{/if}
138							<tbody>
139							{section name=user loop=$users}
140								{if $users[user].editable}
141									{capture assign=username}{$users[user].user|escape}{/capture}
142										<tr>
143											<td class="checkbox-cell">
144												<div class="form-check">
145													{if $users[user].user ne 'admin'}
146														<input type="checkbox" name="checked[]" value="{$users[user].user|escape}" {if isset($users[user].checked) && $users[user].checked eq 'y'}checked="checked" {/if}>
147													{/if}
148												</div>
149											</td>
150
151											<td class="username">
152												{capture name=username}{$users[user].user|username}{/capture}
153												<a
154													class="link tips"
155													href="tiki-adminusers.php?offset={$offset}&amp;numrows={$numrows}&amp;sort_mode={$sort_mode}&amp;user={$users[user].userId}{if $prefs.feature_tabs ne 'y'}#2{/if}"
156													title="{$username}:{tr}Edit account settings{/tr}" {if $users[user].itemId}data-itemid="{$users[user].itemId}"{/if}>
157														{$users[user].user|escape}
158												</a>
159												{if $prefs.user_show_realnames eq 'y' and $smarty.capture.username ne $users[user].user}
160													<div class="subcomment">
161														{$smarty.capture.username|escape}
162													</div>
163												{/if}
164											</td>
165
166											{if $prefs.login_is_email ne 'y'}
167												<td class="email">{$users[user].email}</td>
168											{/if}
169											{if $prefs.auth_method eq 'openid'}
170												<td class="text">{$users[user].openid_url|default:"{tr}N{/tr}"}</td>
171											{/if}
172											<td class="text">
173												{if $users[user].currentLogin eq ''}
174													{capture name=when}{$users[user].age|duration_short}{/capture}
175													{tr}Never{/tr} <em>({tr _0=$smarty.capture.when}Registered %0 ago{/tr})</em>
176												{else}
177													{$users[user].currentLogin|tiki_short_datetime}
178												{/if}
179
180												{if $users[user].waiting eq 'u'}
181													<br>
182													{tr}Need to validate email{/tr}
183												{/if}
184											</td>
185											<td class="text">
186												{$users[user].registrationDate|tiki_short_datetime}
187											</td>
188
189											<td class="text">
190												{foreach from=$users[user].groups key=grs item=what name=gr}
191													<div style="white-space:nowrap">
192														{if $grs != "Anonymous" and ($tiki_p_admin eq 'y' || in_array($grs, $all_groups))}
193															{if $tiki_p_admin eq 'y'}
194																<a
195																	class="link tips" {if isset($link_style)}{$link_style}{/if}
196																	href="tiki-admingroups.php?group={$grs|escape:"url"}"
197																	title="{$grs|escape}:{if $what eq 'included'}{tr}Edit this included group{/tr}"{else}{tr}Edit group{/tr}"{/if}>
198																		{$grs|escape}
199																</a>
200															{else}
201																{$grs|escape}
202															{/if}
203															{if $what eq 'included'}<span class="label label-info">{tr}Included{/tr}</span>{/if}
204															{if $grs eq $users[user].default_group}<small>({tr}default{/tr})</small>{/if}
205															{if $what ne 'included' and $grs != "Registered"}
206																{* keep link code on one line to avoid stray underlining *}
207																<a href="{bootstrap_modal controller=user action=manage_groups checked=$username groupremove=$grs offset=$offset sort_mode=$sort_mode numrows=$numrows}">{icon name="remove"}</a>
208															{/if}
209															{if !$smarty.foreach.gr.last}<br>{/if}
210														{/if}
211													</div>
212												{/foreach}
213											</td>
214
215											<td class="action">
216												{actions}
217													{strip}
218														<action>
219															<a href="{bootstrap_modal controller=user action=manage_groups checked=$username all_groups=$all_groups offset=$offset sort_mode=$sort_mode numrows=$numrows}">
220																{icon name="group" _menu_text='y' _menu_icon='y' alt="{tr}Add or remove from a group{/tr}"}
221															</a>
222														</action>
223														<action>
224															<a class="link" href="tiki-assignuser.php?assign_user={$users[user].user|escape:url}" title="{tr}Edit group expiry{/tr}">
225																{icon name='time' _menu_text='y' _menu_icon='y' alt='{tr}Edit group expiry{/tr}'}
226															</a>
227														</action>
228														<action>
229															<a href="{query _type='relative' user=$users[user].userId}">
230																{icon name="edit" _menu_text='y' _menu_icon='y' alt="{tr}Edit account settings{/tr}"}
231															</a>
232														</action>
233														{if $prefs.feature_userPreferences eq 'y' || $user eq 'admin'}
234															<action>
235																<a href="tiki-user_preferences.php?userId={$users[user].userId}">
236																	{icon name="settings" _menu_text='y' _menu_icon='y' alt="{tr}Change user preferences{/tr}"}
237																</a>
238															</action>
239														{/if}
240														{if $users[user].user eq $user or $users[user].user_information neq 'private' or $tiki_p_admin eq 'y'}
241															<action>
242																<a href="tiki-user_information.php?userId={$users[user].userId}"{if $users[user].user_information eq 'private'}
243																	style="opacity:0.5;"{/if}
244																>
245																	{icon name="help" _menu_text='y' _menu_icon='y' alt="{tr}User information{/tr}"}
246																</a>
247															</action>
248														{/if}
249														{if $users[user].user ne 'admin' and $users[user].user ne $user and $tiki_p_admin eq 'y'}
250															<action>
251																<a href='#' onClick="$('#login-switchuser_1').val('{$users[user].user|username|escape:javascript}'); $('#form_switch_user').submit(); return false;">
252																	{icon name="user" _menu_text='y' _menu_icon='y' alt="{tr}Switch to this user{/tr}"}
253																</a>
254															</action>
255														{/if}
256														{if $users[user].user ne 'admin'}
257															{if $users[user].waiting eq 'a'}
258																<action>
259																	<a href="tiki-login_validate.php?user={$users[user].user|escape:url}&amp;pass={$users[user].valid|escape:url}">
260																		{icon name="ok" _menu_text='y' _menu_icon='y' alt="{tr}Validate user{/tr}"}
261																	</a>
262																</action>
263															{/if}
264															{* Use a form for the next two actions since they change the database but can easily be undone so no confirm needed*}
265															{if $users[user].waiting eq 'u'}
266																<action>
267																	<form action="tiki-confirm_user_email.php" method="post">
268																		{ticket}
269																		<input type="hidden" name="user" value="{$users[user].user|escape:'attr'}">
270																		<input type="hidden" name="pass" value="{$users[user].provpass|md5|escape:'attr'}">
271																		<button type="submit" class="btn btn-link link-list" onclick="checkTimeout()">
272																			{icon name="thumbs-up"} {tr}Validate user{/tr}
273																		</button>
274																	</form>
275																</action>
276															{/if}
277															{if $prefs.email_due > 0 and $users[user].waiting ne 'u' and $users[user].waiting ne 'a'}
278																<action>
279																	<form action="tiki-adminusers.php" method="post">
280																		{ticket}
281																		<input type="hidden" name="user" value="{$users[user].user|escape:'attr'}">
282																		<button type="submit" name="action" value="email_due" class="btn btn-link link-list" onclick="checkTimeout()">
283																			{icon name="thumbs-down"} {tr}Invalidate user{/tr}
284																		</button>
285																	</form>
286																</action>
287															{/if}
288															<action>
289																<a href="{bootstrap_modal controller=user action=remove_users checked=$username offset=$offset sort_mode=$sort_mode numrows=$numrows}">
290																	{icon name="remove" _menu_text='y' _menu_icon='y' alt="{tr}Delete{/tr}"}
291																</a>
292															</action>
293														{/if}
294														{* Use a confirm here since action cannot easily be undone *}
295														{if !empty($users[user].openid_url)}
296															<action>
297																<a href="tiki-adminusers.php?userId={$userId=$users[user].userId|escape:url}&amp;action=remove_openid" onclick="confirmSimple(event, '{tr}Remove link with OpenID for this user?{/tr}', '{ticket mode=get}')">
298																	{icon name="link" _menu_text='y' _menu_icon='y' alt="{tr}Remove link with OpenID account{/tr}"}
299																</a>
300															</action>
301														{/if}
302													{/strip}
303												{/actions}
304										</tr>
305									{/if}
306								{sectionelse}
307									{norecords _colspan=8 _text="No user records found"}
308								{/section}
309							</tbody>
310						</table>
311						{jq}
312							$document.on("show.bs.popover", function ( e ) {
313								var itemId = $(e.target).data("itemid");
314								if (itemId) {
315									$.get($.service("tracker", "view", {id: itemId}), function (data) {
316										data = data.replace(/<h[\s\S]*?<\/h.*?>/mgi, "");	// remove headings
317										$(".popover-body", ".popover.show").empty().append(data);
318									});
319								}
320							});
321						{/jq}
322					{if !$ts.ajax}
323					</div>
324					{if $users}
325						<div class="input-group col-sm-8">
326							<select class="form-control" name="action">
327								<option value="no_action" selected="selected">
328									{tr}Select action to perform with checked{/tr}...
329								</option>
330								<option value="remove_users">
331									{tr}Remove users...{/tr}
332								</option>
333								{if $prefs.feature_banning == 'y'}
334									<option value="ban_ips">
335										{tr}Ban IPs{/tr}
336									</option>
337								{/if}
338								<option value="manage_groups">
339									{tr}Change group assignments{/tr}
340								</option>
341								<option value="default_groups">
342									{tr}Set default groups{/tr}
343								</option>
344								{if $prefs.feature_wiki == 'y'}
345									<option value="email_wikipage">
346										{tr}Send wiki page content by email{/tr}
347									</option>
348								{/if}
349							</select>
350							<span class="input-group-append">
351								<button
352									type="submit"
353									formaction="{bootstrap_modal controller=user}"
354									class="btn btn-primary"
355									onclick="confirmAjax(event)"
356								>
357									{tr}OK{/tr}
358								</button>
359							</span>
360						</div>
361					{/if}
362				</div>
363				<input type="hidden" name="find" value="{$find|escape}">
364				<input type="hidden" name="numrows" value="{$numrows|escape}">
365				<input type="hidden" name="sort_mode" value="{$sort_mode|escape}">
366			</form>
367
368			<form id='form_switch_user' action='tiki-login.php' method='post'>
369				{ticket}
370				<input type="hidden" name="su" value="1" class="form-control" />
371				<input type="hidden" name="username" id="login-switchuser_1" value="" class="form-control" />
372			</form>
373
374
375		{if !$ts.enabled}
376			{pagination_links cant=$cant step=$numrows offset=$offset}{/pagination_links}
377		{/if}
378	{/if}
379		{/tab}
380	{if !$ts.ajax}
381
382		{* ---------------------- tab with form -------------------- *}
383		<a id="tab2" ></a>
384		{if isset($userinfo.userId) && $userinfo.userId}
385			{capture assign=add_edit_user_tablabel}{tr}Edit user{/tr} <i>{$userinfo.login|escape}</i>{/capture}
386		{else}
387			{assign var=add_edit_user_tablabel value="{tr}Add a New User{/tr}"}
388		{/if}
389
390		{tab name="{$add_edit_user_tablabel}"}
391			{if $prefs.feature_user_encryption eq 'y'}
392				{remarksbox type="warning" title="{tr}Warning: User Encryption is Active{/tr}"}
393				{tr}The feature User Encryption stores encrypted user information, such as password used to connect to externalsystems.
394					If the password is changed, it will destroy the user's decryption key, and make the data unreadable.
395					The user will be forced to re-enter the passwords and other data that may be encrypted.{/tr}</a>.
396				{/remarksbox}
397			{/if}
398			{if isset($userinfo.userId) && $userinfo.userId}
399				<h2>{tr}Edit user{/tr} {$userinfo.login|escape}</h2>
400				{if $userinfo.login ne 'admin' and $userinfo.editable}
401					{assign var=thisloginescaped value=$userinfo.login|escape:'url'}
402					{button href="tiki-assignuser.php?assign_user=$thisloginescaped" _text="{tr}Assign user to Groups{/tr}" _icon_name='group'}
403				{/if}
404				{if $userinfo.waiting eq 'a'}
405					{button href='tiki-login_validate.php?user='|cat:$thisloginescaped|cat:'&pass='|cat:$userinfo.valid _text="{tr}Validate user{/tr}" _icon_name='ok'}
406				{/if}
407			{else}
408				<h2>{tr}Add a New User{/tr}</h2>
409			{/if}
410			{if $prefs.feature_intertiki eq 'y' and not empty($prefs.feature_intertiki_mymaster)}
411				{remarksbox type="info" title="{tr}Intertiki Enabled{/tr}"}
412				{tr _0=$prefs.feature_intertiki_mymaster|escape}This Tiki is an Intertiki Client so user information must be edited on the Intertiki Master "%0"{/tr}</a>.
413				{/remarksbox}
414			{elseif $userinfo.editable}
415				<form action="tiki-adminusers.php" method="post" enctype="multipart/form-data" name="RegForm" autocomplete="off">
416					{ticket}
417					<div class="form-group row">
418						<label class="col-sm-3 col-md-2 col-form-label" for="login">{if $prefs.login_is_email eq 'y'}{tr}Email{/tr}{else}{tr}User{/tr}{/if}</label>
419						<div class="col-sm-7 col-md-6">
420							{if $userinfo.login neq 'admin'}
421								<input type="text" id='login' class="form-control" name='login' value="{$userinfo.login|escape}">
422								{if $prefs.login_is_email eq 'y'}
423									<br>
424									<em>{tr}Use the email as username{/tr}.</em>
425								{elseif $prefs.lowercase_username eq 'y'}
426									<br>
427									<em>{tr}Lowercase only{/tr}</em>.
428								{elseif $prefs.login_autogenerate eq 'y'}
429									<br>
430
431									{icon name='warning' alt="{tr}Warning{/tr}" style="vertical-align:middle"}
432									<em>{tr}The username will be an autogenerated number based on the user ID if no actual username is provided when the user is created. Do not change these numeric usernames.{/tr}</em>
433								{/if}
434								{if not empty($userinfo.userId) and $prefs.feature_intertiki eq 'y'}
435									<p>
436										{icon name='warning' alt="{tr}Warning{/tr}" style="vertical-align:middle"}
437										<em>{tr}Changing username is disabled for Intertiki sites{/tr}</em>
438									</p>
439								{/if}
440							{else}
441								<input type="hidden" class="form-control" name='login' value="{$userinfo.login|escape}">{$userinfo.login}
442							{/if}
443						</div>
444					</div>
445
446					{*
447						No need to specify user password or to ask him to change it, if :
448						--> Tiki is using the Tiki + PEAR Auth systems
449						--> AND Tiki won't create the user in the Tiki auth system
450						--> AND Tiki won't create the user in the ldap
451					*}
452					{if $prefs.auth_method eq 'ldap' and ( $prefs.ldap_create_user_tiki eq 'n' or $prefs.ldap_skip_admin eq 'y' ) and $prefs.ldap_create_user_ldap eq 'n' and $userinfo.login neq 'admin' and $auth_ldap_permit_tiki_users eq 'n'}
453						<div class="form-group row">
454							<div class="offset-sm-2">
455								<b>{tr}No password is required{/tr}</b>
456								<br>
457								<i>{tr}Tiki is configured to delegate the password managment to LDAP.{/tr}</i>
458							</div>
459						</div>
460					{else}
461						{include file='password_jq.tpl' ignorejq='y'}
462						<div class="form-group row">
463							<label class="col-sm-3 col-md-2 col-form-label" for="pass1">{if isset($userinfo.userId)}{tr}New password{/tr}{else}{tr}Password{/tr}{/if}</label>
464							<div class="col-sm-7 col-md-6">
465								<input type="password" class="form-control" placeholder="{tr}Password{/tr}" name="pass" id="pass1" autocomplete="new-password">
466								<div style="margin-left:5px;">
467									<div id="mypassword_text">{icon name='ok' istyle='display:none'}{icon name='error' istyle='display:none' } <span id="mypassword_text_inner"></span></div>
468									<div id="mypassword_bar" style="font-size: 5px; height: 2px; width: 0px;"></div>
469								</div>
470								<div style="margin-top:5px">
471									{include file='password_help.tpl'}
472								</div>
473							</div>
474						</div>
475						<div class="form-group row">
476							<label class="col-sm-3 col-md-2 col-form-label" for="pass2">{if isset($userinfo.userId)}{tr}Confirm new password{/tr}{else}{tr}Confirm password{/tr}{/if}</label>
477							<div class="col-sm-7 col-md-6">
478								<input type="password" class="form-control" name="passAgain" id="pass2" placeholder="{tr}Password{/tr}" autocomplete="new-password">
479								<div id="mypassword2_text">
480									<div id="match" style="display:none">
481										{icon name='ok' istyle='color:#0ca908'} {tr}Passwords match{/tr}
482									</div>
483									<div id="nomatch" style="display:none">
484										{icon name='error' istyle='color:#ff0000'} {tr}Passwords do not match{/tr}
485									</div>
486								</div>
487							</div>
488						</div>
489						{if $prefs.generate_password eq 'y' and not ( $prefs.auth_method eq 'ldap' and ( $prefs.ldap_create_user_tiki eq 'n' or $prefs.ldap_skip_admin eq 'y' ) and $prefs.ldap_create_user_ldap eq 'n')}
490							<div class="form-group row">
491								<div class="col-sm-3 offset-sm-3 col-md-3 offset-md-2">
492									<span id="genPass">{button href="#" _text="{tr}Generate a password{/tr}"}</span>
493								</div>
494								<div class="col-sm-3 col-md-3">
495									<input id='genepass' class="form-control" name="genepass" type="text" tabindex="0" style="display:none">
496								</div>
497							</div>
498						{/if}
499						{if $userinfo.login neq 'admin' && $prefs.change_password neq 'n'}
500							<div class="form-group row">
501								<div class="col-sm-9 offset-sm-3 col-md-10 offset-md-2">
502									<div class="form-check">
503										<label class="form-check-label">
504											<input class="form-check-input" type="checkbox" name="pass_first_login"{if isset($userinfo.pass_confirm) && $userinfo.pass_confirm eq '0'} checked="checked"{/if}>
505											{tr}User must change password at next login{/tr}
506										</label>
507									</div>
508								</div>
509							</div>
510						{/if}
511					{/if}
512					{if $prefs.login_is_email neq 'y'}
513						<div class="form-group row">
514							<label class="col-sm-3 col-md-2 col-form-label" for="pass1">{tr}Email{/tr}</label>
515							<div class="col-sm-7 col-md-6">
516								<input type="text" class="form-control" id="email" name="email" size="30" value="{$userinfo.email|escape}">
517							</div>
518						</div>
519					{/if}
520					{if $userinfo.login neq 'admin' and ($prefs.validateUsers eq 'y' or $prefs.validateRegistration eq 'y')}
521						<div class="form-group row">
522							<div class="col-sm-9 offset-sm-3 col-md-10 offset-md-2">
523								<div class="form-check">
524									<label class="form-check-label">
525										<input class="form-check-input" type="checkbox" name="need_email_validation" {if ($userinfo.login eq '' and ($prefs.validateUsers eq 'y' or $prefs.validateRegistration eq 'y')) or $userinfo.provpass neq '' or $userinfo.valid neq ''}checked="checked"{/if}>
526										{tr}Send an email to the user to enable him or her to validate their account.{/tr}
527									</label>
528									{if empty($prefs.sender_email)}
529										<div class="alert alert-warning highlight">{tr}You need to set <a href="tiki-admin.php?page=general" class="alert-link">Sender Email</a>{/tr}</div>
530									{/if}
531								</div>
532							</div>
533						</div>
534					{/if}
535					{if $prefs.userTracker eq 'y' and $userinfo.login eq ''}
536						<div class="form-group row">
537							<div class="col-sm-9 offset-sm-3 col-md-10 offset-md-2">
538								<div class="form-check">
539									<label class="form-check-label">
540										<input class="form-check-input" type="checkbox" name="insert_user_tracker_item">
541										{tr}Add a user tracker item for this user{/tr}
542									</label>
543								</div>
544							</div>
545						</div>
546					{/if}
547
548					{if $prefs.userTracker eq 'y' and $userstrackerid}
549						<div class="form-group row">
550							<label class="col-md-2 col-form-label">
551								{tr}User tracker{/tr}
552							</label>
553
554							<div class="col-md-10">
555								{if $usersitemid}
556									<a href="{bootstrap_modal controller=tracker action=update_item trackerId=$userstrackerid itemId=$usersitemid}" onclick="$('[data-toggle=popover]').popover('hide');" class="btn btn-primary edit-usertracker">
557										{tr}Edit Item{/tr}
558									</a>
559									<a href="{bootstrap_modal controller=tracker action=view id=$usersitemid}" class="btn btn-info">
560										{tr}View item{/tr}
561									</a>
562								{else}
563									<a href="{bootstrap_modal controller=tracker action=insert_item trackerId=$userstrackerid forced=$usersTrackerForced}" onclick="$('[data-toggle=popover]').popover('hide');" class="btn btn-primary insert-usertracker">
564										{tr}Create Item{/tr}
565									</a>
566								{/if}
567							</div>
568						</div>
569					{/if}
570
571					<div class="form-group row">
572						<div class="col-sm-9 offset-sm-3 col-md-10 offset-md-2">
573							{if isset($userinfo.userId) && $userinfo.userId}
574								<input type="hidden" name="user" value="{$userinfo.userId|escape}">
575								<input type="hidden" name="edituser" value="1">
576								<input
577									type="submit"
578									class="btn btn-primary"
579									name="save"
580									value="{tr}Save{/tr}"
581									onclick="confirmSimple(event, '{tr}Modify this user\'s data?{/tr}')"
582								>
583							{else}
584								<input
585									type="submit"
586									class="btn btn-primary"
587									name="newuser"
588									value="{tr}Add{/tr}"
589									onclick="checkTimeout()"
590								>
591							{/if}
592						</div>
593					</div>
594					{if isset($userinfo.userId) && $userinfo.userId != 0}
595						<table class="table table-striped table-condensed small">
596
597							{if $userinfo.created neq $userinfo.registrationDate}
598								<tr>
599									<td>{tr}Created{/tr}</td>
600									<td>{$userinfo.created|tiki_long_datetime}</td>
601								</tr>
602							{/if}
603							<tr>
604								<td>{tr}Registered{/tr}</td><td>{if $userinfo.registrationDate}{$userinfo.registrationDate|tiki_long_datetime}{/if}</td>
605							</tr>
606							<tr>
607								<td>{tr}Pass confirmed{/tr}</td><td>{if isset($userinfo.pass_confirm) && $userinfo.pass_confirm}{$userinfo.pass_confirm|tiki_long_datetime|default:'Never'}{/if}</td>
608							</tr>
609
610							{if $prefs.email_due > 0}
611								<tr>
612									<td style="white-space: nowrap;">{tr}Email confirmed{/tr}</td>
613									<td>
614										{if $userinfo.email_confirm}
615											({tr _0=$userinfo.daysSinceEmailConfirm}%0 days ago{/tr})
616										{else}
617											{tr}Never{/tr}
618										{/if}
619									</td>
620								</tr>
621							{/if}
622							<tr>
623								<td>{tr}Current Login{/tr}</td>
624								<td>{if $userinfo.currentLogin}{$userinfo.currentLogin|tiki_long_datetime|default:'Never'}{/if}</td>
625							</tr>
626							<tr>
627								<td>{tr}Last Login{/tr}</td>
628								<td>{if $userinfo.lastLogin}{$userinfo.lastLogin|tiki_long_datetime|default:'Never'}{/if}</td>
629							</tr>
630						</table>
631					{/if}
632
633				</form>
634			{else}
635				{tr}You do not have permission to edit this user{/tr}
636			{/if}
637		{/tab}
638
639		{* ---------------------- tab with upload -------------------- *}
640		{tab name="{tr}Import{/tr}"}
641			<h2>{tr}Batch upload (CSV file){/tr}</h2>
642
643			<form action="tiki-adminusers.php" method="post" enctype="multipart/form-data">
644				{ticket}
645				<div class="form-group row">
646					<label for="csvlist" class="col-form-label col-md-3">{tr}CSV File{/tr}</label>
647					<div class="col-md-9">
648						<input type="file" id="csvlist" name="csvlist" class="form-control">
649						<small class="form-text">
650							{tr}Your file should contain in the first row (first entry) the following fields:{/tr}
651							<span class="font-weight-bold">login</span>, <span class="font-weight-bold">password</span>, <span class="font-weight-bold">email</span>, groups, default_group,realName.<br><br>
652							<span class="font-italic">{tr}Example{/tr}:</span><br>
653							login,password,email,groups,default_group,realName<br>
654							{tr}user1,pass1,email1,group1,group1{/tr}<br>
655							{tr}user2,pass2,email2,"group1,group2",group1{/tr}<br><br>
656							{tr}Only login, password, email are mandatory. Use an empty password for automatic password generation. Use same login and email if the login use email. Groups are separated by comma. With group name with comma, double the comma.{/tr}<br>
657							{tr}On most server with default setting importing 250 users should be fine. If you have a long list you can split it or change the server settings to allow longer execution time.{/tr}
658							{tr}Please also note that the data should match your Tiki setting. IE: if special characters or space are not permit for the username of your Tiki then your data in the CSV file for username should not contain any.{/tr}
659						</small>
660					</div>
661				</div>
662				<div class="form-group row">
663					<label class="col-md-3 col-form-label">{tr}Existing Users{/tr}</label>
664					<div class="col-md-9">
665						<label>
666							<input type="radio" name="overwrite" value="y">
667							{tr}Overwrite{/tr}
668						</label>
669						<label>
670							<input type="radio" name="overwrite" value="n" checked>
671							{tr}Don't overwrite{/tr}
672						</label>
673					</div>
674				</div>
675				<div class="form-group row">
676					<div class="col-md-9 offset-md-3">
677						<div class="form-check">
678							<label class="form-check-label">
679								<input class="form-check-input" type="checkbox" name="overwriteGroup">
680								{tr}Overwrite groups{/tr}
681							</label>
682						</div>
683					</div>
684				</div>
685				<div class="form-group row">
686					<div class="col-md-9 offset-md-3">
687						<div class="form-check">
688							<label class="form-check-label">
689								<input class="form-check-input" type="checkbox" name="createGroup">
690								{tr}Create groups{/tr}
691							</label>
692						</div>
693					</div>
694				</div>
695				{if $prefs.change_password neq 'n'}
696					<div class="form-group row">
697						<div class="col-md-9 offset-md-3">
698							<div class="form-check">
699								<label class="form-check-label">
700									<input class="form-check-input" type="checkbox" name="forcePasswordChange">
701									{tr}The user must change his or her password the first time they log in{/tr}
702								</label>
703							</div>
704						</div>
705					</div>
706				{/if}
707				<div class="form-group row">
708					<div class="col-md-9 offset-md-3">
709						<div class="form-check">
710							<label class="form-check-label">
711								<input class="form-check-input" type="checkbox" name="notification">
712								{tr}Send an email to the user to enable him or her to validate their account.{/tr}
713							</label>
714						</div>
715					</div>
716				</div>
717				<div class="form-group row">
718					<div class="col-md-9 offset-md-3">
719						<input type="submit" class="btn btn-secondary" name="batch" value="{tr}Add{/tr}" onclick="checkTimeout()">
720					</div>
721				</div>
722			</form>
723			{if $tiki_p_admin eq 'y'} {* only full admins can manage groups, not tiki_p_admin_users *}
724				{remarksbox type="tip" title="{tr}Tip{/tr}"}{tr}You can export users of a group by clicking on that group at <a href="tiki-admingroups.php" class="alert-link">admin->groups</a>{/tr}{/remarksbox}
725			{/if}
726		{/tab}
727
728		{tab name="{tr}Temporary Users{/tr}"}
729			<h2>Invite new temporary user(s)</h2>
730			{$temp_users_enabled = true}
731			{if $prefs['auth_token_access'] != 'y'}
732				{remarksbox type="warning" title="{tr}Token Access Feature Dependency{/tr}"}
733					{tr}The token access feature is needed for Temporary Users to login.{/tr}
734					<a href="tiki-admin.php?lm_criteria=auth_token_access&exact" class="alert-link">{tr}Turn it on here.{/tr}</a>
735				{/remarksbox}
736				{$temp_users_enabled = false}
737			{/if}
738			{if $prefs['login_is_email'] === 'y'}
739				{remarksbox type="warning" title="{tr}Feature Conflict{/tr}"}
740					{tr}This feature currently is incompatible with the "Use email as username" feature{/tr}
741					<a href="tiki-admin.php?lm_criteria=login_is_email&exact" class="alert-link">{tr}Turn it off here.{/tr}</a>
742				{/remarksbox}
743				{$temp_users_enabled = false}
744			{/if}
745			{if $prefs['user_unique_email'] === 'y'}
746				{remarksbox type="warning" title="{tr}Feature Conflict{/tr}"}
747					{tr}This feature currently is incompatible with the "The email address of each user must be unique." feature{/tr}
748					<a href="tiki-admin.php?lm_criteria=user_unique_email&exact" class="alert-link">{tr}Turn it off here.{/tr}</a>
749				{/remarksbox}
750				{$temp_users_enabled = false}
751			{/if}
752			{if $temp_users_enabled}
753				{remarksbox type="info" title="Temporary Users"}
754					<p>{tr}Temporary users cannot login the usual way but instead do so via an autologin URL that is associated with a token.{/tr} {tr}An email will be sent out to invited users containing this URL. You will receive a copy of the email yourself.{/tr}</p>
755					<p>{tr}These temporary users will be deleted (but can be set to be preserved in Admin Tokens) once the validity period is over. Normally, these users should have read-only access. Nevertheless, if you are allowing these users to submit information, e.g. fill in a tracker form, make sure to ask for their information again in those forms.{/tr}</p>
756					<p>{tr}Please do not assign temporary users to Groups that can access any security sensitive information, since access to these accounts is relatively easy to obtain, for example by intercepting or otherwise getting access to these emails.{/tr}</p>
757				{/remarksbox}
758				{remarksbox type="info" title="Revoking Access"}
759					{tr}To revoke access before validity expires or to review who has access, please see:{/tr} <a href="tiki-admin_tokens.php" class="alert-link">{tr}Admin Tokens{/tr}</a>
760				{/remarksbox}
761				<form name="tempuser" id="tempuser" method="post" action="{service controller=user action=invite_tempuser}">
762					<div class="form-group row">
763						<label class="col-sm-4 col-md-4 col-form-label" for="tempuser_emails">{tr}Email addresses (comma-separated){/tr}</label>
764						<div class="col-sm-8 col-md-8">
765							<input type="text" class="form-control" name="tempuser_emails" id="tempuser_emails" />
766						</div>
767					</div>
768					<div class="form-group row">
769						<label class="col-sm-4 col-md-4 col-form-label" for="tempuser_groups">{tr}Groups (comma-separated){/tr}</label>
770						<div class="col-sm-8 col-md-8">
771							<input type="text" class="form-control" name="tempuser_groups" id="tempuser_groups" />
772							{autocomplete element='#tempuser_groups' type='groupname'}
773						</div>
774					</div>
775					<div class="form-group row">
776						<label class="col-sm-4 col-md-4 col-form-label" for="tempuser_expiry">{tr}Valid for days (use -1 for forever){/tr}</label>
777						<div class="col-sm-8 col-md-8">
778							<input type="text" class="form-control" name="tempuser_expiry" id="tempuser_expiry" />
779						</div>
780					</div>
781					<div class="form-group row">
782						<label class="col-sm-4 col-md-4 col-form-label" for="tempuser_prefix">{tr}Username prefix{/tr}</label>
783						<div class="col-sm-8 col-md-8">
784							<input type="text" class="form-control" name="tempuser_prefix" id="tempuser_prefix" placeholder="guest"/>
785						</div>
786					</div>
787					<div class="form-group row">
788						<label class="col-sm-4 col-md-4 col-form-label" for="tempuser_path">{tr}Autologin (non-SEFURL) path{/tr}</label>
789						<div class="col-sm-8 col-md-8">
790							<input type="text" class="form-control" name="tempuser_path" id="tempuser_path" placeholder="index.php"/>
791						</div>
792					</div>
793					<div class="form-group row">
794						<div class="col-sm-10 offset-sm-4 col-md-10 offset-md-4">
795							<input
796								type="submit"
797								class="btn btn-secondary"
798								value="{tr}Invite{/tr}"
799								onclick="postForm(event)"
800							>
801						</div>
802					</div>
803				</form>
804			{/if}
805		{/tab}
806	{/if}
807{/tabset}
808