1 | <%-- $Id: edit_user.jsp 7501 2018-08-09 06:40:57Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
5 | Copyright (C) 2007 Nicklas Nordborg, Martin Svensson |
---|
6 | |
---|
7 | This file is part of BASE - BioArray Software Environment. |
---|
8 | Available at http://base.thep.lu.se/ |
---|
9 | |
---|
10 | BASE is free software; you can redistribute it and/or |
---|
11 | modify it under the terms of the GNU General Public License |
---|
12 | as published by the Free Software Foundation; either version 3 |
---|
13 | of the License, or (at your option) any later version. |
---|
14 | |
---|
15 | BASE is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | |
---|
25 | @author Nicklas |
---|
26 | @version 2.0 |
---|
27 | --%> |
---|
28 | <%@ page pageEncoding="UTF-8" session="false" |
---|
29 | import="net.sf.basedb.core.SessionControl" |
---|
30 | import="net.sf.basedb.core.DbControl" |
---|
31 | import="net.sf.basedb.core.SystemItems" |
---|
32 | import="net.sf.basedb.core.Item" |
---|
33 | import="net.sf.basedb.core.Type" |
---|
34 | import="net.sf.basedb.core.ItemContext" |
---|
35 | import="net.sf.basedb.core.Permission" |
---|
36 | import="net.sf.basedb.core.Group" |
---|
37 | import="net.sf.basedb.core.User" |
---|
38 | import="net.sf.basedb.core.Quota" |
---|
39 | import="net.sf.basedb.core.Role" |
---|
40 | import="net.sf.basedb.core.Directory" |
---|
41 | import="net.sf.basedb.core.ExtendedProperties" |
---|
42 | import="net.sf.basedb.core.ExtendedProperty" |
---|
43 | import="net.sf.basedb.core.QuotaType" |
---|
44 | import="net.sf.basedb.core.Location" |
---|
45 | import="net.sf.basedb.core.Include" |
---|
46 | import="net.sf.basedb.core.ItemQuery" |
---|
47 | import="net.sf.basedb.core.ItemResultList" |
---|
48 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
49 | import="net.sf.basedb.core.query.Orders" |
---|
50 | import="net.sf.basedb.core.query.Hql" |
---|
51 | import="net.sf.basedb.core.query.Restrictions" |
---|
52 | import="net.sf.basedb.core.query.Expressions" |
---|
53 | import="net.sf.basedb.clients.web.Base" |
---|
54 | import="net.sf.basedb.clients.web.util.HTML" |
---|
55 | import="net.sf.basedb.util.Values" |
---|
56 | import="net.sf.basedb.util.formatter.Formatter" |
---|
57 | import="net.sf.basedb.util.json.JsonUtil" |
---|
58 | import="net.sf.basedb.util.json.JsonConverter" |
---|
59 | import="net.sf.basedb.util.json.NameableConverter" |
---|
60 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
61 | import="net.sf.basedb.clients.web.formatter.FormatterSettings" |
---|
62 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
63 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
64 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
65 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
66 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
67 | import="java.util.Date" |
---|
68 | import="java.util.List" |
---|
69 | import="org.json.simple.JSONArray" |
---|
70 | import="org.json.simple.JSONObject" |
---|
71 | %> |
---|
72 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
73 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
74 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
75 | <% |
---|
76 | final Item itemType = Item.USER; |
---|
77 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
78 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
79 | final int itemId = cc.getId(); |
---|
80 | final int cloneId = Values.getInt(request.getParameter("clone_id")); |
---|
81 | final String ID = sc.getId(); |
---|
82 | final float scale = Base.getScale(sc); |
---|
83 | final DbControl dc = sc.newDbControl(); |
---|
84 | try |
---|
85 | { |
---|
86 | String title = null; |
---|
87 | User user = null; |
---|
88 | |
---|
89 | List<ExtendedProperty> extendedProperties = ExtendedProperties.getProperties("UserData"); |
---|
90 | JSONArray jsonExtendedProperties = JsonUtil.toArray(extendedProperties, new JsonConverter<ExtendedProperty>() |
---|
91 | { |
---|
92 | public Object convert(ExtendedProperty ep) |
---|
93 | { |
---|
94 | JSONObject json = new JSONObject(); |
---|
95 | json.put("name", ep.getName()); |
---|
96 | json.put("valueType", ep.getType().name()); |
---|
97 | json.put("title", ep.getTitle()); |
---|
98 | json.put("nullable", ep.isNullable()); |
---|
99 | return json; |
---|
100 | } |
---|
101 | }); |
---|
102 | |
---|
103 | final QuotaType total = QuotaType.getById(dc, SystemItems.getId(QuotaType.TOTAL)); |
---|
104 | Quota currentQuota = null; |
---|
105 | Group currentQuotaGroup = null; |
---|
106 | Directory homeDirectory = null; |
---|
107 | |
---|
108 | // Query to retrieve group membership |
---|
109 | ItemQuery<Group> groupQuery = null; |
---|
110 | // Query to retrieve role membership |
---|
111 | ItemQuery<Role> roleQuery = null; |
---|
112 | |
---|
113 | if (itemId == 0 && cloneId == 0) |
---|
114 | { |
---|
115 | title = "Create user"; |
---|
116 | cc.removeObject("item"); |
---|
117 | if (cc.getPropertyFilter("quota.name") != null) |
---|
118 | { |
---|
119 | currentQuota = Base.getFirstMatching(dc, Quota.getQuery(), "name", cc.getPropertyFilter("quota.name")); |
---|
120 | } |
---|
121 | else |
---|
122 | { |
---|
123 | currentQuota = Quota.getById(dc, SystemItems.getId(Quota.DEFAULT)); |
---|
124 | } |
---|
125 | if (cc.getPropertyFilter("quotaGroup.name") != null) |
---|
126 | { |
---|
127 | currentQuotaGroup = Base.getFirstMatching(dc, Group.getQuery(), "name", cc.getPropertyFilter("quotaGroup.name")); |
---|
128 | } |
---|
129 | |
---|
130 | groupQuery = Group.getQuery(); |
---|
131 | groupQuery.restrict( |
---|
132 | Restrictions.eq( |
---|
133 | Hql.property("default"), |
---|
134 | Expressions.parameter("isDefault", true, Type.BOOLEAN) |
---|
135 | ) |
---|
136 | ); |
---|
137 | groupQuery.order(Orders.asc(Hql.property("name"))); |
---|
138 | roleQuery = Role.getQuery(); |
---|
139 | roleQuery.restrict( |
---|
140 | Restrictions.eq( |
---|
141 | Hql.property("default"), |
---|
142 | Expressions.parameter("isDefault", true, Type.BOOLEAN) |
---|
143 | ) |
---|
144 | ); |
---|
145 | roleQuery.order(Orders.asc(Hql.property("name"))); |
---|
146 | } |
---|
147 | else if (cloneId != 0) |
---|
148 | { |
---|
149 | cc.removeObject("item"); |
---|
150 | user = User.getById(dc, cloneId); |
---|
151 | title = "Create user -- cloned from " + HTML.encodeTags(user.getName()); |
---|
152 | try |
---|
153 | { |
---|
154 | currentQuota = user.getQuota(); |
---|
155 | } |
---|
156 | catch (PermissionDeniedException ex) |
---|
157 | {} |
---|
158 | try |
---|
159 | { |
---|
160 | currentQuotaGroup = user.getQuotaGroup(); |
---|
161 | } |
---|
162 | catch (PermissionDeniedException ex) |
---|
163 | {} |
---|
164 | groupQuery = user.getGroups(); |
---|
165 | groupQuery.include(Include.ALL); |
---|
166 | groupQuery.order(Orders.asc(Hql.property("name"))); |
---|
167 | roleQuery = user.getRoles(); |
---|
168 | roleQuery.include(Include.ALL); |
---|
169 | roleQuery.order(Orders.asc(Hql.property("name"))); |
---|
170 | } |
---|
171 | else |
---|
172 | { |
---|
173 | user = User.getById(dc, itemId); |
---|
174 | cc.setObject("item", user); |
---|
175 | title = "Edit user -- " + HTML.encodeTags(user.getName()); |
---|
176 | |
---|
177 | try |
---|
178 | { |
---|
179 | currentQuota = user.getQuota(); |
---|
180 | } |
---|
181 | catch (PermissionDeniedException ex) |
---|
182 | {} |
---|
183 | try |
---|
184 | { |
---|
185 | currentQuotaGroup = user.getQuotaGroup(); |
---|
186 | } |
---|
187 | catch (PermissionDeniedException ex) |
---|
188 | {} |
---|
189 | try |
---|
190 | { |
---|
191 | homeDirectory = user.getHomeDirectory(); |
---|
192 | } |
---|
193 | catch (PermissionDeniedException ex) |
---|
194 | {} |
---|
195 | |
---|
196 | groupQuery = user.getGroups(); |
---|
197 | groupQuery.include(Include.ALL); |
---|
198 | groupQuery.order(Orders.asc(Hql.property("name"))); |
---|
199 | roleQuery = user.getRoles(); |
---|
200 | roleQuery.include(Include.ALL); |
---|
201 | roleQuery.order(Orders.asc(Hql.property("name"))); |
---|
202 | user.checkPermission(Permission.WRITE); |
---|
203 | } |
---|
204 | |
---|
205 | final boolean readQuota = sc.hasPermission(Permission.READ, Item.QUOTA); |
---|
206 | final boolean useQuota = sc.hasPermission(Permission.USE, Item.QUOTA); |
---|
207 | final boolean createDirectories = sc.hasPermission(Permission.CREATE, Item.DIRECTORY); |
---|
208 | final boolean readDirectories = sc.hasPermission(Permission.READ, Item.DIRECTORY); |
---|
209 | final boolean readGroups = sc.hasPermission(Permission.READ, Item.GROUP); |
---|
210 | final boolean useGroups = sc.hasPermission(Permission.USE, Item.GROUP); |
---|
211 | final boolean writeGroups = sc.hasPermission(Permission.WRITE, Item.GROUP); |
---|
212 | final boolean writeRoles = sc.hasPermission(Permission.WRITE, Item.ROLE); |
---|
213 | final boolean writeMembership = writeGroups && writeRoles; |
---|
214 | |
---|
215 | // Query to retrieve quota |
---|
216 | final ItemQuery<Quota> quotaQuery = Quota.getQuery(); |
---|
217 | quotaQuery.include(Include.ALL); |
---|
218 | quotaQuery.order(Orders.asc(Hql.property("name"))); |
---|
219 | quotaQuery.setCacheResult(true); |
---|
220 | |
---|
221 | // Query to retrieve quota groups |
---|
222 | final ItemQuery<Group> quotaGroupQuery = Group.getQuery(); |
---|
223 | quotaGroupQuery.include(Include.ALL); |
---|
224 | quotaGroupQuery.order(Orders.asc(Hql.property("name"))); |
---|
225 | quotaGroupQuery.restrict(Restrictions.neq(Hql.property("quota"), null)); |
---|
226 | quotaGroupQuery.setCacheResult(true); |
---|
227 | |
---|
228 | // Query to retrieve home directories |
---|
229 | final ItemQuery<Directory> directoryQuery = Directory.getQuery(); |
---|
230 | directoryQuery.include(Include.ALL); |
---|
231 | directoryQuery.order(Orders.asc(Hql.property("name"))); |
---|
232 | directoryQuery.restrict( |
---|
233 | Restrictions.eq( |
---|
234 | Hql.property("parent"), |
---|
235 | Expressions.integer(SystemItems.getId(Directory.HOME)) |
---|
236 | ) |
---|
237 | ); |
---|
238 | directoryQuery.setCacheResult(true); |
---|
239 | |
---|
240 | // Load group membership as JSON objects |
---|
241 | JSONObject jsonGroups = new JSONObject(); |
---|
242 | jsonGroups.put("itemType", "GROUP"); |
---|
243 | jsonGroups.put("name", "Groups"); |
---|
244 | if (groupQuery != null) |
---|
245 | { |
---|
246 | jsonGroups.put("items", JsonUtil.toArray(groupQuery.iterate(dc), new NameableConverter())); |
---|
247 | } |
---|
248 | |
---|
249 | // Load role membership as JSON objects |
---|
250 | JSONObject jsonRoles = new JSONObject(); |
---|
251 | jsonRoles.put("itemType", "ROLE"); |
---|
252 | jsonRoles.put("name", "Roles"); |
---|
253 | if (roleQuery != null) |
---|
254 | { |
---|
255 | jsonRoles.put("items", JsonUtil.toArray(roleQuery.iterate(dc), new NameableConverter())); |
---|
256 | } |
---|
257 | |
---|
258 | JSONArray jsonMembers = new JSONArray(); |
---|
259 | jsonMembers.add(jsonGroups); |
---|
260 | jsonMembers.add(jsonRoles); |
---|
261 | |
---|
262 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
263 | String dateFormat = FormatterSettings.getDateFormat(sc); |
---|
264 | String htmlDateFormat = HTML.encodeTags(dateFormat); |
---|
265 | Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
266 | String dateTimeFormat = FormatterSettings.getDateTimeFormat(sc); |
---|
267 | String htmlDateTimeFormat = HTML.encodeTags(dateTimeFormat); |
---|
268 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), itemId == 0 ? null : user); |
---|
269 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
270 | %> |
---|
271 | <base:page type="popup" title="<%=title%>" id="edit-page"> |
---|
272 | <base:head scripts="tabcontrol-2.js,linkitems-2.js,~users.js" styles="tabcontrol.css"> |
---|
273 | <ext:scripts context="<%=jspContext%>" /> |
---|
274 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
275 | </base:head> |
---|
276 | <base:body> |
---|
277 | <h1><%=title%> <base:help tabcontrol="settings" /></h1> |
---|
278 | |
---|
279 | <div id="page-data" class="datacontainer" |
---|
280 | data-date-format="<%=htmlDateFormat%>" |
---|
281 | data-datetime-format="<%=htmlDateTimeFormat%>" |
---|
282 | data-extended-properties="<%=HTML.encodeTags(jsonExtendedProperties.toJSONString())%>" |
---|
283 | ></div> |
---|
284 | |
---|
285 | <form action="index.jsp?ID=<%=ID%>" method="post" name="user"> |
---|
286 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
287 | <input type="hidden" name="item_id" value="<%=itemId%>"> |
---|
288 | |
---|
289 | <t:tabcontrol id="settings" |
---|
290 | subclass="content dialogtabcontrol" |
---|
291 | position="bottom" remember="<%=itemId != 0%>" |
---|
292 | extensions="<%=invoker%>"> |
---|
293 | <t:tab id="info" title="User" helpid="user.edit"> |
---|
294 | <table class="fullform input100"> |
---|
295 | <tr> |
---|
296 | <th>Name</th> |
---|
297 | <td><input class="text required auto-init" data-auto-init="<%=user == null ? "focus-select" : "focus" %>" |
---|
298 | type="text" name="name" |
---|
299 | value="<%=HTML.encodeTags(itemId == 0 ? Values.getString(cc.getPropertyValue("name"), "New user") : user.getName())%>" |
---|
300 | size="40" maxlength="<%=User.MAX_NAME_LENGTH%>"></td> |
---|
301 | <td></td> |
---|
302 | </tr> |
---|
303 | <tr> |
---|
304 | <th>Login</th> |
---|
305 | <td><input class="text required" type="text" name="login" |
---|
306 | value="<%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("login") : user.getLogin())%>" |
---|
307 | maxlength="<%=User.MAX_LOGIN_LENGTH%>"></td> |
---|
308 | <td></td> |
---|
309 | </tr> |
---|
310 | <tr> |
---|
311 | <th>External ID</th> |
---|
312 | <td><input class="text" type="text" name="external_id" |
---|
313 | value="<%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("externalId") : user.getExternalId())%>" |
---|
314 | maxlength="<%=User.MAX_EXTERNAL_ID_LENGTH%>"></td> |
---|
315 | <td></td> |
---|
316 | </tr> |
---|
317 | <tr> |
---|
318 | <th>New password</th> |
---|
319 | <td><input class="text <%=itemId == 0 ? "required" : ""%>" type="password" name="new_password" value="" maxlength="30" style="max-width: 20em;" |
---|
320 | <%=itemId == 0 ? "" : "placeholder=\"leave empty to keep the password\"" %> |
---|
321 | ></td> |
---|
322 | <td></td> |
---|
323 | </tr> |
---|
324 | <tr> |
---|
325 | <th class="subprompt">Retype password</th> |
---|
326 | <td><input class="text <%=itemId == 0 ? "required" : ""%>" type="password" name="retype_password" value="" maxlength="30" style="max-width: 20em;"></td> |
---|
327 | <td></td> |
---|
328 | </tr> |
---|
329 | <tr> |
---|
330 | <th>Quota</th> |
---|
331 | <td> |
---|
332 | <select name="quota_id" <%=!useQuota ? "disabled readonly class=\"disabled\"" : "class=\"required selectionlist\""%>> |
---|
333 | <% |
---|
334 | if (!readQuota) |
---|
335 | { |
---|
336 | %> |
---|
337 | <option value="-1">- denied - |
---|
338 | <% |
---|
339 | } |
---|
340 | ItemResultList<Quota> quotas = quotaQuery.list(dc); |
---|
341 | for (Quota quota : quotas) |
---|
342 | { |
---|
343 | boolean current = quota.equals(currentQuota); |
---|
344 | if (!current && quota.isRemoved()) continue; |
---|
345 | int id = quota.getId(); |
---|
346 | long totalBytes = quota.getQuotaValue(total, Location.PRIMARY); |
---|
347 | String fTotal = totalBytes == Quota.UNLIMITED ? "unlimited" : Values.formatBytes(totalBytes); |
---|
348 | %> |
---|
349 | <option |
---|
350 | value="<%=current && itemId != 0 ? -id : id%>" |
---|
351 | <%=current ? "selected" : ""%> |
---|
352 | ><%=HTML.encodeTags(quota.getName())%> (<%=fTotal%> total) |
---|
353 | <% |
---|
354 | } |
---|
355 | %> |
---|
356 | </select> |
---|
357 | </td> |
---|
358 | <td></td> |
---|
359 | </tr> |
---|
360 | <tr> |
---|
361 | <th>Quota group</th> |
---|
362 | <td> |
---|
363 | <select name="quotagroup_id" <%=!useGroups ? "disabled readonly class=\"disabled\"" : "class=\"selectionlist\""%>> |
---|
364 | <% |
---|
365 | if (!readGroups) |
---|
366 | { |
---|
367 | %> |
---|
368 | <option value="-1">- denied - |
---|
369 | <% |
---|
370 | } |
---|
371 | else |
---|
372 | { |
---|
373 | %> |
---|
374 | <option value="0">- none - |
---|
375 | <% |
---|
376 | ItemResultList<Group> quotaGroups = quotaGroupQuery.list(dc); |
---|
377 | for (Group quotaGroup : quotaGroups) |
---|
378 | { |
---|
379 | boolean current = quotaGroup.equals(currentQuotaGroup); |
---|
380 | if (!current && quotaGroup.isRemoved()) continue; |
---|
381 | int id = quotaGroup.getId(); |
---|
382 | Quota quota = quotaGroup.getQuota(); |
---|
383 | long totalBytes = quota.getQuotaValue(total, Location.PRIMARY); |
---|
384 | String fTotal = totalBytes == Quota.UNLIMITED ? "unlimited" : Values.formatBytes(totalBytes); |
---|
385 | %> |
---|
386 | <option |
---|
387 | value="<%=current && itemId != 0 ? -id : id %>" |
---|
388 | <%=current ? "selected" : ""%> |
---|
389 | ><%=HTML.encodeTags(quotaGroup.getName())%> (<%=fTotal%> total) |
---|
390 | <% |
---|
391 | } |
---|
392 | } |
---|
393 | %> |
---|
394 | </select> |
---|
395 | </td> |
---|
396 | <td></td> |
---|
397 | </tr> |
---|
398 | <tr> |
---|
399 | <th>Home directory</th> |
---|
400 | <td> |
---|
401 | <select name="homedirectory_id" <%=!readDirectories ? "disabled readonly class=\"disabled\"" : "class=\"selectionlist\""%>> |
---|
402 | <% |
---|
403 | if (!readDirectories) |
---|
404 | { |
---|
405 | %> |
---|
406 | <option value="-1">- denied - |
---|
407 | <% |
---|
408 | } |
---|
409 | else |
---|
410 | { |
---|
411 | %> |
---|
412 | <option value="0">- none - |
---|
413 | <% |
---|
414 | if (createDirectories && itemId == 0) |
---|
415 | { |
---|
416 | %> |
---|
417 | <option value="new">- create new (empty) - |
---|
418 | <option value="template" selected>- create new from template - |
---|
419 | <% |
---|
420 | } |
---|
421 | ItemResultList<Directory> directories = directoryQuery.list(dc); |
---|
422 | for (Directory d : directories) |
---|
423 | { |
---|
424 | int id = d.getId(); |
---|
425 | boolean current = d.equals(homeDirectory); |
---|
426 | if (!current && d.isRemoved()) continue; |
---|
427 | %> |
---|
428 | <option |
---|
429 | value="<%=current && itemId != 0 ? -id : id%>" |
---|
430 | <%=current ? "selected" : ""%> |
---|
431 | ><%=HTML.encodeTags(d.getName())%> |
---|
432 | <% |
---|
433 | } |
---|
434 | } |
---|
435 | %> |
---|
436 | </select> |
---|
437 | </td> |
---|
438 | <td></td> |
---|
439 | </tr> |
---|
440 | <tr> |
---|
441 | <th>Expiration date</th> |
---|
442 | <td> |
---|
443 | <table> |
---|
444 | <tr> |
---|
445 | <td> |
---|
446 | <input class="text" type="text" name="expiration_date" id="expiration_date" style="width: 15em;" |
---|
447 | value="<%=HTML.encodeTags(dateFormatter.format( |
---|
448 | user == null ? (Date)cc.getPropertyObject("expirationDate") : user.getExpirationDate()) |
---|
449 | )%>" |
---|
450 | maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> |
---|
451 | </td> |
---|
452 | <td> |
---|
453 | <base:calendar textarea="expiration_date" title="Expiration date" /> |
---|
454 | </td> |
---|
455 | </tr> |
---|
456 | </table> |
---|
457 | </td> |
---|
458 | <td></td> |
---|
459 | </tr> |
---|
460 | <tr> |
---|
461 | <th><label for="use_device_verification">2-factor login</label></th> |
---|
462 | <td><input type="checkbox" name="use_device_verification" id="use_device_verification" value="1" |
---|
463 | <%=(user != null && user.getUseDeviceVerification()) || |
---|
464 | (user == null && Values.getBoolean(cc.getPropertyValue("useDeviceVerification"))) ? "checked" : ""%> |
---|
465 | >(Requires a valid email address) |
---|
466 | </td> |
---|
467 | <td></td> |
---|
468 | </tr> |
---|
469 | <tr> |
---|
470 | <th><label for="multiuser_account">Multi-user account</label></th> |
---|
471 | <td><input type="checkbox" name="multiuser_account" id="multiuser_account" value="1" |
---|
472 | <%=(user != null && user.isMultiuserAccount()) || |
---|
473 | (user == null && Values.getBoolean(cc.getPropertyValue("multiuserAccount"))) ? "checked" : ""%>></td> |
---|
474 | <td></td> |
---|
475 | </tr> |
---|
476 | <tr> |
---|
477 | <th><label for="disabled">Disabled</label></th> |
---|
478 | <td><input type="checkbox" name="disabled" id="disabled" value="1" |
---|
479 | <%=(itemId != 0 && user.isDisabled()) || |
---|
480 | (itemId == 0 && Values.getBoolean(cc.getPropertyValue("disabled"))) ? "checked" : ""%>></td> |
---|
481 | <td></td> |
---|
482 | </tr> |
---|
483 | <tr class="dynamic"> |
---|
484 | <th>Description</th> |
---|
485 | <td> |
---|
486 | <textarea class="text" rows="6" name="description" id="description" |
---|
487 | ><%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("description") : user.getDescription())%></textarea> |
---|
488 | </td> |
---|
489 | <td style="width: 20px;"> |
---|
490 | <base:zoom textarea="description" title="Description" /> |
---|
491 | </td> |
---|
492 | </tr> |
---|
493 | </table> |
---|
494 | </t:tab> |
---|
495 | |
---|
496 | <t:tab id="contact" title="Contact information" |
---|
497 | tooltip="Email, adress, organisation, etc." |
---|
498 | helpid="user.edit.contact"> |
---|
499 | <table class="fullform input100"> |
---|
500 | <tr> |
---|
501 | <th>Email</th> |
---|
502 | <td><input class="text" type="text" name="email" |
---|
503 | value="<%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("email") : user.getEmail())%>" |
---|
504 | maxlength="<%=User.MAX_EMAIL_LENGTH%>"></td> |
---|
505 | <td></td> |
---|
506 | </tr> |
---|
507 | <tr> |
---|
508 | <th>Organisation</th> |
---|
509 | <td><input class="text" type="text" name="organisation" |
---|
510 | value="<%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("organisation") : user.getOrganisation())%>" |
---|
511 | maxlength="<%=User.MAX_ORGANISATION_LENGTH%>"></td> |
---|
512 | <td></td> |
---|
513 | </tr> |
---|
514 | <tr class="big"> |
---|
515 | <th>Address</th> |
---|
516 | <td> |
---|
517 | <textarea class="text" rows="6" name="address" id="address" |
---|
518 | wrap="off"><%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("address") : user.getAddress())%></textarea> |
---|
519 | </td> |
---|
520 | <td style="width: 20px;"> |
---|
521 | <base:zoom textarea="address" title="Address" /> |
---|
522 | </td> |
---|
523 | </tr> |
---|
524 | <tr> |
---|
525 | <th>Phone</th> |
---|
526 | <td><input class="text" type="text" name="phone" |
---|
527 | value="<%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("phone") : user.getPhone())%>" |
---|
528 | maxlength="<%=User.MAX_PHONE_LENGTH%>"></td> |
---|
529 | <td></td> |
---|
530 | </tr> |
---|
531 | <tr> |
---|
532 | <th>Fax</th> |
---|
533 | <td><input class="text" type="text" name="fax" |
---|
534 | value="<%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("fax") : user.getFax())%>" |
---|
535 | maxlength="<%=User.MAX_FAX_LENGTH%>"></td> |
---|
536 | <td></td> |
---|
537 | </tr> |
---|
538 | <tr> |
---|
539 | <th>Url</th> |
---|
540 | <td><input class="text" type="text" name="url" |
---|
541 | value="<%=HTML.encodeTags(itemId == 0 ? cc.getPropertyValue("url") : user.getUrl())%>" |
---|
542 | maxlength="<%=User.MAX_URL_LENGTH%>"></td> |
---|
543 | <td></td> |
---|
544 | </tr> |
---|
545 | <tr class="dynamic"> |
---|
546 | <th></th> |
---|
547 | <td colspan="2"></td> |
---|
548 | </tr> |
---|
549 | </table> |
---|
550 | </t:tab> |
---|
551 | <% |
---|
552 | if (extendedProperties != null) |
---|
553 | { |
---|
554 | %> |
---|
555 | <t:tab id="extended" title="Additional info" |
---|
556 | helpid="user.edit.additional"> |
---|
557 | <table class="fullform input100"> |
---|
558 | <% |
---|
559 | for (ExtendedProperty ep : extendedProperties) |
---|
560 | { |
---|
561 | String name = ep.getName(); |
---|
562 | String fieldName = "ep."+name; |
---|
563 | Type type = ep.getType(); |
---|
564 | boolean required = !ep.isNullable(); |
---|
565 | Object value = itemId == 0 ? cc.getPropertyValue(name) : user.getExtended(name); |
---|
566 | String theClazz = required ? "text required" : "text"; |
---|
567 | boolean addZoom = false; |
---|
568 | %> |
---|
569 | <tr> |
---|
570 | <th><%=HTML.encodeTags(ep.getTitle())%></th> |
---|
571 | <td> |
---|
572 | <% |
---|
573 | if (type == Type.INT || type == Type.LONG) |
---|
574 | { |
---|
575 | %> |
---|
576 | <input class="<%=theClazz%>" type="text" name="<%=fieldName%>" id="<%=fieldName%>" |
---|
577 | style="width: 15m;" value="<%=value == null ? "" : value%>" maxlength="20"> |
---|
578 | <% |
---|
579 | } |
---|
580 | else if (type == Type.FLOAT || type == Type.DOUBLE) |
---|
581 | { |
---|
582 | %> |
---|
583 | <input class="<%=theClazz%>" type="text" name="<%=fieldName%>" id="<%=fieldName%>" |
---|
584 | value="<%=value == null ? "" : value%>" style="width: 15m;" maxlength="20"> |
---|
585 | <% |
---|
586 | } |
---|
587 | else if (type == Type.STRING) |
---|
588 | { |
---|
589 | %> |
---|
590 | <input class="<%=theClazz%>" type="text" name="<%=fieldName%>" id="<%=fieldName%>" |
---|
591 | value="<%=HTML.encodeTags((String)value)%>" |
---|
592 | maxlength="<%=ep.getLength()%>" |
---|
593 | > |
---|
594 | <% |
---|
595 | } |
---|
596 | else if (type == Type.TEXT) |
---|
597 | { |
---|
598 | addZoom = true; |
---|
599 | %> |
---|
600 | <textarea class="<%=theClazz%>" name="<%=fieldName%>" id="<%=fieldName%>" rows="6" |
---|
601 | ><%=HTML.encodeTags((String)value)%></textarea> |
---|
602 | <% |
---|
603 | } |
---|
604 | else if (type == Type.BOOLEAN) |
---|
605 | { |
---|
606 | Boolean b = (Boolean)value; |
---|
607 | if (!required) |
---|
608 | { |
---|
609 | %> |
---|
610 | <input type="radio" name="<%=fieldName%>" id="<%=fieldName%>.null" value="" |
---|
611 | <%=b == null ? "checked" : ""%> |
---|
612 | ><label for="<%=fieldName%>.null"><i>- not specified -</i></label><br> |
---|
613 | <% |
---|
614 | } |
---|
615 | %> |
---|
616 | <input type="radio" name="<%=fieldName%>" id="<%=fieldName%>.true" value="true" |
---|
617 | <%=b != null && b == true ? "checked" : ""%> |
---|
618 | ><label for="<%=fieldName%>.true">true</label> |
---|
619 | <input type="radio" name="<%=fieldName%>" id="<%=fieldName%>.false" value="false" |
---|
620 | <%=b != null && b == false || required && b == null ? "checked" : ""%> |
---|
621 | ><label for="<%=fieldName%>.false">false</label> |
---|
622 | <% |
---|
623 | } |
---|
624 | else if (type == Type.DATE) |
---|
625 | { |
---|
626 | %> |
---|
627 | <table> |
---|
628 | <tr> |
---|
629 | <td> |
---|
630 | <input class="<%=theClazz%>" type="text" name="<%=fieldName%>" id="<%=fieldName%>" |
---|
631 | value="<%=dateFormatter.format((Date)value)%>" style="width: 15em;" |
---|
632 | maxlength="20" title="Enter date in format: <%=htmlDateFormat%>" |
---|
633 | > |
---|
634 | </td> |
---|
635 | <td> |
---|
636 | <base:calendar textarea="<%=fieldName%>" title="<%=HTML.encodeTags(ep.getTitle())%>" /> |
---|
637 | </td> |
---|
638 | </tr> |
---|
639 | </table> |
---|
640 | <% |
---|
641 | } |
---|
642 | else if (type == Type.TIMESTAMP) |
---|
643 | { |
---|
644 | %> |
---|
645 | <table> |
---|
646 | <tr> |
---|
647 | <td> |
---|
648 | <input class="<%=theClazz%>" type="text" name="<%=fieldName%>" id="<%=fieldName%>" |
---|
649 | value="<%=dateTimeFormatter.format((Date)value)%>" style="width: 15em;" |
---|
650 | maxlength="20" title="Enter timestamp in format: <%=htmlDateTimeFormat%>" |
---|
651 | > |
---|
652 | </td> |
---|
653 | <td> |
---|
654 | <base:calendar textarea="<%=fieldName%>" title="<%=HTML.encodeTags(ep.getTitle()) %>" |
---|
655 | data-use-time="1" |
---|
656 | tooltip="Select a timestamp from a calendar" |
---|
657 | /> |
---|
658 | </td> |
---|
659 | </tr> |
---|
660 | </table> |
---|
661 | <% |
---|
662 | } |
---|
663 | %> |
---|
664 | </td> |
---|
665 | <td style="width: 20px;"> |
---|
666 | <%if (addZoom) |
---|
667 | { |
---|
668 | %> |
---|
669 | <base:zoom textarea="<%=fieldName%>" title="<%=HTML.encodeTags(ep.getTitle()) %>" /> |
---|
670 | <% |
---|
671 | } |
---|
672 | %> |
---|
673 | </td> |
---|
674 | </tr> |
---|
675 | <% |
---|
676 | } |
---|
677 | %> |
---|
678 | <tr class="dynamic"> |
---|
679 | <th></th> |
---|
680 | <td colspan="2"></td> |
---|
681 | </tr> |
---|
682 | </table> |
---|
683 | </t:tab> |
---|
684 | <% |
---|
685 | } |
---|
686 | %> |
---|
687 | <t:tab id="members" title="Membership" tooltip="Manage group and role membership" |
---|
688 | helpid="user.edit.membership"> |
---|
689 | <table class="fullform input100"> |
---|
690 | <tr class="dynamic"> |
---|
691 | <th>Member in</th> |
---|
692 | <td> |
---|
693 | <div class="selectionlist"> |
---|
694 | <table> |
---|
695 | <tr> |
---|
696 | <td> |
---|
697 | <select name="membership" id="membership" |
---|
698 | class="auto-init" |
---|
699 | data-auto-init="link-container" |
---|
700 | data-initial-items="<%=HTML.encodeTags(jsonMembers.toJSONString()) %>" |
---|
701 | data-initial-action="<%=itemId == 0 ? 1 : 0 %>" |
---|
702 | size="15" multiple <%=!writeMembership ? "disabled readonly class=\"disabled\"" : ""%>> |
---|
703 | </select> |
---|
704 | </td> |
---|
705 | <td style="vertical-align: top;"> |
---|
706 | <base:buttongroup vertical="true"> |
---|
707 | <base:button |
---|
708 | id="btnAddGroups" |
---|
709 | subclass="leftaligned auto-init" |
---|
710 | data-auto-init="add-link" |
---|
711 | data-list-id="membership" |
---|
712 | data-item-type="GROUP" |
---|
713 | title="Add groups…" |
---|
714 | tooltip="Add groups to this user" |
---|
715 | disabled="<%=!writeMembership %>" |
---|
716 | /> |
---|
717 | <base:button |
---|
718 | id="btnAddRoles" |
---|
719 | subclass="leftaligned auto-init" |
---|
720 | data-auto-init="add-link" |
---|
721 | data-list-id="membership" |
---|
722 | data-item-type="ROLE" |
---|
723 | title="Add roles…" |
---|
724 | tooltip="Add roles to this user" |
---|
725 | disabled="<%=!writeMembership %>" |
---|
726 | /> |
---|
727 | <base:button |
---|
728 | id="btnRemoveMembership" |
---|
729 | subclass="leftaligned auto-init" |
---|
730 | data-auto-init="remove-link" |
---|
731 | data-list-id="membership" |
---|
732 | title="Remove" |
---|
733 | tooltip="Remove the user from the selected items" |
---|
734 | disabled="<%=!writeMembership%>" |
---|
735 | /> |
---|
736 | </base:buttongroup> |
---|
737 | </td> |
---|
738 | </tr> |
---|
739 | </table> |
---|
740 | </div> |
---|
741 | </td> |
---|
742 | </tr> |
---|
743 | </table> |
---|
744 | |
---|
745 | </t:tab> |
---|
746 | </t:tabcontrol> |
---|
747 | </form> |
---|
748 | |
---|
749 | <div class="legend"> |
---|
750 | <base:icon image="required.png" />= required information |
---|
751 | </div> |
---|
752 | |
---|
753 | <base:buttongroup subclass="dialogbuttons"> |
---|
754 | <base:button id="btnSave" title="Save" /> |
---|
755 | <base:button id="close" title="Cancel" /> |
---|
756 | </base:buttongroup> |
---|
757 | </base:body> |
---|
758 | </base:page> |
---|
759 | <% |
---|
760 | } |
---|
761 | finally |
---|
762 | { |
---|
763 | if (dc != null) dc.close(); |
---|
764 | } |
---|
765 | %> |
---|