502 |
02 May 05 |
nicklas |
1 |
<%-- $Id$ |
502 |
02 May 05 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2005 Nicklas Nordborg |
5425 |
23 Sep 10 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg, Martin Svensson |
502 |
02 May 05 |
nicklas |
6 |
|
2304 |
22 May 06 |
jari |
7 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
8 |
Available at http://base.thep.lu.se/ |
502 |
02 May 05 |
nicklas |
9 |
|
502 |
02 May 05 |
nicklas |
10 |
BASE is free software; you can redistribute it and/or |
502 |
02 May 05 |
nicklas |
11 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
12 |
as published by the Free Software Foundation; either version 3 |
502 |
02 May 05 |
nicklas |
13 |
of the License, or (at your option) any later version. |
502 |
02 May 05 |
nicklas |
14 |
|
502 |
02 May 05 |
nicklas |
15 |
BASE is distributed in the hope that it will be useful, |
502 |
02 May 05 |
nicklas |
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
502 |
02 May 05 |
nicklas |
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
502 |
02 May 05 |
nicklas |
18 |
GNU General Public License for more details. |
502 |
02 May 05 |
nicklas |
19 |
|
502 |
02 May 05 |
nicklas |
20 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
21 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
502 |
02 May 05 |
nicklas |
22 |
------------------------------------------------------------------ |
502 |
02 May 05 |
nicklas |
23 |
|
502 |
02 May 05 |
nicklas |
24 |
@author Nicklas |
502 |
02 May 05 |
nicklas |
25 |
@version 2.0 |
502 |
02 May 05 |
nicklas |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
502 |
02 May 05 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
502 |
02 May 05 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
502 |
02 May 05 |
nicklas |
30 |
import="net.sf.basedb.core.Item" |
1968 |
10 Feb 06 |
nicklas |
31 |
import="net.sf.basedb.core.Include" |
1968 |
10 Feb 06 |
nicklas |
32 |
import="net.sf.basedb.core.Group" |
502 |
02 May 05 |
nicklas |
33 |
import="net.sf.basedb.core.User" |
1968 |
10 Feb 06 |
nicklas |
34 |
import="net.sf.basedb.core.Role" |
1968 |
10 Feb 06 |
nicklas |
35 |
import="net.sf.basedb.core.Quota" |
1968 |
10 Feb 06 |
nicklas |
36 |
import="net.sf.basedb.core.Directory" |
1418 |
07 Oct 05 |
nicklas |
37 |
import="net.sf.basedb.core.ItemQuery" |
502 |
02 May 05 |
nicklas |
38 |
import="net.sf.basedb.core.Permission" |
1968 |
10 Feb 06 |
nicklas |
39 |
import="net.sf.basedb.core.ItemContext" |
3535 |
28 Jun 07 |
martin |
40 |
import="net.sf.basedb.core.ExtendedProperties" |
3535 |
28 Jun 07 |
martin |
41 |
import="net.sf.basedb.core.ExtendedProperty" |
1968 |
10 Feb 06 |
nicklas |
42 |
import="net.sf.basedb.core.MultiPermissions" |
1968 |
10 Feb 06 |
nicklas |
43 |
import="net.sf.basedb.core.PermissionDeniedException" |
1968 |
10 Feb 06 |
nicklas |
44 |
import="net.sf.basedb.core.ItemAlreadyExistsException" |
2211 |
03 May 06 |
martin |
45 |
import="net.sf.basedb.core.DatabaseException" |
4906 |
24 Apr 09 |
martin |
46 |
import="net.sf.basedb.core.query.Expressions" |
4906 |
24 Apr 09 |
martin |
47 |
import="net.sf.basedb.core.query.Hql" |
4906 |
24 Apr 09 |
martin |
48 |
import="net.sf.basedb.core.query.Orders" |
4906 |
24 Apr 09 |
martin |
49 |
import="net.sf.basedb.core.query.Restrictions" |
4906 |
24 Apr 09 |
martin |
50 |
import="net.sf.basedb.util.RemovableUtil" |
4906 |
24 Apr 09 |
martin |
51 |
import="net.sf.basedb.util.Values" |
502 |
02 May 05 |
nicklas |
52 |
import="net.sf.basedb.clients.web.Base" |
1968 |
10 Feb 06 |
nicklas |
53 |
import="net.sf.basedb.clients.web.WebException" |
502 |
02 May 05 |
nicklas |
54 |
import="net.sf.basedb.clients.web.util.HTML" |
2942 |
22 Nov 06 |
nicklas |
55 |
import="net.sf.basedb.util.formatter.Formatter" |
4906 |
24 Apr 09 |
martin |
56 |
import="net.sf.basedb.util.formatter.NameableFormatter" |
2942 |
22 Nov 06 |
nicklas |
57 |
import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
4906 |
24 Apr 09 |
martin |
58 |
import="net.sf.basedb.clients.web.plugins.ItemQueryLoader" |
5506 |
19 Nov 10 |
nicklas |
59 |
import="net.sf.basedb.core.plugin.GuiContext" |
5506 |
19 Nov 10 |
nicklas |
60 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
5506 |
19 Nov 10 |
nicklas |
61 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5506 |
19 Nov 10 |
nicklas |
62 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5506 |
19 Nov 10 |
nicklas |
63 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
64 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveAction" |
5506 |
19 Nov 10 |
nicklas |
65 |
import="net.sf.basedb.clients.web.extensions.edit.OnSaveRenderer" |
6030 |
28 Mar 12 |
nicklas |
66 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnExportRenderer" |
7604 |
25 Feb 19 |
nicklas |
67 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnAction" |
6030 |
28 Mar 12 |
nicklas |
68 |
import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil" |
2942 |
22 Nov 06 |
nicklas |
69 |
import="java.util.Date" |
1968 |
10 Feb 06 |
nicklas |
70 |
import="java.util.Enumeration" |
1968 |
10 Feb 06 |
nicklas |
71 |
import="java.util.Set" |
1968 |
10 Feb 06 |
nicklas |
72 |
import="java.util.HashSet" |
1968 |
10 Feb 06 |
nicklas |
73 |
import="java.util.List" |
1968 |
10 Feb 06 |
nicklas |
74 |
import="java.util.ArrayList" |
1968 |
10 Feb 06 |
nicklas |
75 |
import="java.util.Collections" |
7496 |
11 Jul 18 |
nicklas |
76 |
import="java.util.Map" |
502 |
02 May 05 |
nicklas |
77 |
%> |
502 |
02 May 05 |
nicklas |
78 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
502 |
02 May 05 |
nicklas |
79 |
<%! |
2434 |
27 Jun 06 |
nicklas |
80 |
private static final ItemContext defaultContext = Base.createDefaultContext("name", "name,login,expirationDate,groups,roles,email,description"); |
1968 |
10 Feb 06 |
nicklas |
81 |
private static final Item itemType = Item.USER; |
4906 |
24 Apr 09 |
martin |
82 |
|
4906 |
24 Apr 09 |
martin |
83 |
private static void registerExportUtils(ItemContext cc) |
4906 |
24 Apr 09 |
martin |
84 |
{ |
4906 |
24 Apr 09 |
martin |
85 |
// Register formatters |
4906 |
24 Apr 09 |
martin |
86 |
cc.setObject("export.formatter.&groups(name)", new NameableFormatter()); |
4906 |
24 Apr 09 |
martin |
87 |
cc.setObject("export.formatter.&roles(name)", new NameableFormatter()); |
4906 |
24 Apr 09 |
martin |
88 |
|
4906 |
24 Apr 09 |
martin |
89 |
// Register dataloaders |
4906 |
24 Apr 09 |
martin |
90 |
String userParameter = "user"; |
4906 |
24 Apr 09 |
martin |
91 |
// Groups |
4906 |
24 Apr 09 |
martin |
92 |
ItemQuery<Group> groupQuery = Group.getQuery(); |
4906 |
24 Apr 09 |
martin |
93 |
groupQuery.include(cc.getInclude()); |
4906 |
24 Apr 09 |
martin |
94 |
groupQuery.join(Hql.innerJoin("users", "usr")); |
4906 |
24 Apr 09 |
martin |
95 |
groupQuery.restrict(Restrictions.eq(Hql.alias("usr"), Expressions.parameter(userParameter))); |
4906 |
24 Apr 09 |
martin |
96 |
groupQuery.order(Orders.asc(Hql.property("name"))); |
7604 |
25 Feb 19 |
nicklas |
97 |
cc.setObject("export.dataloader.&groups(name)", new ItemQueryLoader<User>(groupQuery, userParameter)); |
4906 |
24 Apr 09 |
martin |
98 |
// Roles |
4906 |
24 Apr 09 |
martin |
99 |
ItemQuery<Role> roleQuery = Role.getQuery(); |
4906 |
24 Apr 09 |
martin |
100 |
roleQuery.include(cc.getInclude()); |
4906 |
24 Apr 09 |
martin |
101 |
roleQuery.join(Hql.innerJoin("users", "usr")); |
4906 |
24 Apr 09 |
martin |
102 |
roleQuery.restrict(Restrictions.eq(Hql.alias("usr"), Expressions.parameter(userParameter))); |
4906 |
24 Apr 09 |
martin |
103 |
roleQuery.order(Orders.asc(Hql.property("name"))); |
7604 |
25 Feb 19 |
nicklas |
104 |
cc.setObject("export.dataloader.&roles(name)", new ItemQueryLoader<User>(roleQuery, userParameter)); |
4906 |
24 Apr 09 |
martin |
105 |
} |
502 |
02 May 05 |
nicklas |
106 |
%> |
502 |
02 May 05 |
nicklas |
107 |
<% |
1968 |
10 Feb 06 |
nicklas |
108 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
502 |
02 May 05 |
nicklas |
109 |
final String ID = sc.getId(); |
1968 |
10 Feb 06 |
nicklas |
110 |
final String cmd = request.getParameter("cmd"); |
1968 |
10 Feb 06 |
nicklas |
111 |
final String root = request.getContextPath()+"/"; |
1968 |
10 Feb 06 |
nicklas |
112 |
final String mode = request.getParameter("mode"); |
1968 |
10 Feb 06 |
nicklas |
113 |
final String callback = request.getParameter("callback"); |
1968 |
10 Feb 06 |
nicklas |
114 |
final String itemId = request.getParameter("item_id"); |
1968 |
10 Feb 06 |
nicklas |
115 |
final String listPage = "list_users.jsp?ID="+ID |
1968 |
10 Feb 06 |
nicklas |
116 |
+(mode == null ? "" : "&mode="+mode) |
1968 |
10 Feb 06 |
nicklas |
117 |
+(callback == null ? "" : "&callback="+callback) |
1968 |
10 Feb 06 |
nicklas |
118 |
+(itemId == null ? "" : "&item_id="+itemId); |
1968 |
10 Feb 06 |
nicklas |
119 |
final String viewPage = "view_user.jsp?ID="+ID; |
1968 |
10 Feb 06 |
nicklas |
120 |
final String editPage = "edit_user.jsp?ID="+ID; |
502 |
02 May 05 |
nicklas |
121 |
|
1968 |
10 Feb 06 |
nicklas |
122 |
String forward = null; |
1968 |
10 Feb 06 |
nicklas |
123 |
String redirect = null; |
1968 |
10 Feb 06 |
nicklas |
124 |
String message = null; |
1968 |
10 Feb 06 |
nicklas |
125 |
DbControl dc = null; |
1968 |
10 Feb 06 |
nicklas |
126 |
|
502 |
02 May 05 |
nicklas |
127 |
try |
502 |
02 May 05 |
nicklas |
128 |
{ |
1968 |
10 Feb 06 |
nicklas |
129 |
if (cmd == null || "List".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
130 |
{ |
1968 |
10 Feb 06 |
nicklas |
131 |
// Display the list page without updatinging the current context |
2811 |
26 Oct 06 |
nicklas |
132 |
Base.getAndSetCurrentContext(sc, itemType, null, defaultContext, true); |
1968 |
10 Feb 06 |
nicklas |
133 |
redirect = listPage; |
1968 |
10 Feb 06 |
nicklas |
134 |
} |
1968 |
10 Feb 06 |
nicklas |
135 |
else if ("UpdateContext".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
136 |
{ |
1968 |
10 Feb 06 |
nicklas |
137 |
// Display the list page after updating the current context from the request parameters |
1968 |
10 Feb 06 |
nicklas |
138 |
Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
139 |
redirect = listPage; |
1968 |
10 Feb 06 |
nicklas |
140 |
} |
1968 |
10 Feb 06 |
nicklas |
141 |
else if ("LoadContext".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
142 |
{ |
1968 |
10 Feb 06 |
nicklas |
143 |
// Display the list page after loading a saved context |
1968 |
10 Feb 06 |
nicklas |
144 |
int contextId = Values.getInt(request.getParameter("context")); |
1968 |
10 Feb 06 |
nicklas |
145 |
Base.loadContext(sc, contextId, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
146 |
redirect = listPage; |
1968 |
10 Feb 06 |
nicklas |
147 |
} |
1968 |
10 Feb 06 |
nicklas |
148 |
|
1968 |
10 Feb 06 |
nicklas |
149 |
else if ("ViewItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
150 |
{ |
1968 |
10 Feb 06 |
nicklas |
151 |
// Display the view page for a single item |
1968 |
10 Feb 06 |
nicklas |
152 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
153 |
forward = viewPage; |
1968 |
10 Feb 06 |
nicklas |
154 |
} |
1968 |
10 Feb 06 |
nicklas |
155 |
else if ("EditItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
156 |
{ |
1968 |
10 Feb 06 |
nicklas |
157 |
// Display the edit page for a single item (should be opened in a popup) |
1968 |
10 Feb 06 |
nicklas |
158 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
159 |
redirect = editPage; |
1968 |
10 Feb 06 |
nicklas |
160 |
} |
1968 |
10 Feb 06 |
nicklas |
161 |
else if ("NewItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
162 |
{ |
1968 |
10 Feb 06 |
nicklas |
163 |
// Display the edit page for a new item (should be opened in a popup) |
1968 |
10 Feb 06 |
nicklas |
164 |
if (!sc.hasPermission(Permission.CREATE, itemType)) |
502 |
02 May 05 |
nicklas |
165 |
{ |
1968 |
10 Feb 06 |
nicklas |
166 |
throw new PermissionDeniedException(Permission.CREATE, itemType.toString()); |
502 |
02 May 05 |
nicklas |
167 |
} |
1968 |
10 Feb 06 |
nicklas |
168 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
169 |
cc.setId(0); |
6174 |
17 Oct 12 |
nicklas |
170 |
forward = editPage; |
1968 |
10 Feb 06 |
nicklas |
171 |
} |
1968 |
10 Feb 06 |
nicklas |
172 |
else if ("UpdateItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
173 |
{ |
1968 |
10 Feb 06 |
nicklas |
174 |
// Update the properties on an item (will close the popup) |
1968 |
10 Feb 06 |
nicklas |
175 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); |
7954 |
12 May 21 |
nicklas |
176 |
dc = sc.newDbControl(":Edit "+itemType); |
1968 |
10 Feb 06 |
nicklas |
177 |
|
1968 |
10 Feb 06 |
nicklas |
178 |
final String email = Values.getStringOrNull(request.getParameter("email")); |
1968 |
10 Feb 06 |
nicklas |
179 |
if (email != null && !HTML.isValidEmail(email)) |
502 |
02 May 05 |
nicklas |
180 |
{ |
1968 |
10 Feb 06 |
nicklas |
181 |
throw new WebException("popup", "Invalid email address", |
1968 |
10 Feb 06 |
nicklas |
182 |
"The email address {1} is not a valid email address.", |
1968 |
10 Feb 06 |
nicklas |
183 |
HTML.encodeTags(email) |
1968 |
10 Feb 06 |
nicklas |
184 |
); |
502 |
02 May 05 |
nicklas |
185 |
} |
1968 |
10 Feb 06 |
nicklas |
186 |
final String login = Values.getStringOrNull(request.getParameter("login")); |
1968 |
10 Feb 06 |
nicklas |
187 |
final String password = Values.getStringOrNull(request.getParameter("new_password")); |
3089 |
29 Jan 07 |
martin |
188 |
String oldLogin = null; |
3089 |
29 Jan 07 |
martin |
189 |
String oldExternalId = null; |
3089 |
29 Jan 07 |
martin |
190 |
boolean loginHasChanged = true; |
3089 |
29 Jan 07 |
martin |
191 |
boolean externalIdHasChanged = false; |
1968 |
10 Feb 06 |
nicklas |
192 |
|
7605 |
26 Feb 19 |
nicklas |
193 |
User user = cc.getObject("item"); |
1968 |
10 Feb 06 |
nicklas |
194 |
if (user == null) |
502 |
02 May 05 |
nicklas |
195 |
{ |
1968 |
10 Feb 06 |
nicklas |
196 |
user = User.getNew(dc, login, password); |
1968 |
10 Feb 06 |
nicklas |
197 |
message = "User created"; |
1968 |
10 Feb 06 |
nicklas |
198 |
dc.saveItem(user); |
502 |
02 May 05 |
nicklas |
199 |
} |
1968 |
10 Feb 06 |
nicklas |
200 |
else |
502 |
02 May 05 |
nicklas |
201 |
{ |
5060 |
19 Aug 09 |
nicklas |
202 |
dc.reattachItem(user, false); |
3089 |
29 Jan 07 |
martin |
203 |
oldLogin = user.getLogin(); |
1968 |
10 Feb 06 |
nicklas |
204 |
user.setLogin(login); |
3089 |
29 Jan 07 |
martin |
205 |
loginHasChanged = oldLogin != login; |
1968 |
10 Feb 06 |
nicklas |
206 |
if (password != null) user.setPassword(password); |
1968 |
10 Feb 06 |
nicklas |
207 |
message = "User updated"; |
502 |
02 May 05 |
nicklas |
208 |
} |
5506 |
19 Nov 10 |
nicklas |
209 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(Item.USER), user); |
7604 |
25 Feb 19 |
nicklas |
210 |
ExtensionsInvoker<OnSaveAction> invoker = EditUtil.useOnSaveExtensions(jspContext); |
5506 |
19 Nov 10 |
nicklas |
211 |
try |
502 |
02 May 05 |
nicklas |
212 |
{ |
5506 |
19 Nov 10 |
nicklas |
213 |
user.setName(Values.getStringOrNull(request.getParameter("name"))); |
5506 |
19 Nov 10 |
nicklas |
214 |
oldExternalId = user.getExternalId(); |
5506 |
19 Nov 10 |
nicklas |
215 |
user.setExternalId(Values.getStringOrNull(request.getParameter("external_id"))); |
5506 |
19 Nov 10 |
nicklas |
216 |
externalIdHasChanged = oldExternalId != user.getExternalId(); |
5506 |
19 Nov 10 |
nicklas |
217 |
|
5506 |
19 Nov 10 |
nicklas |
218 |
int quotaId = Values.getInt(request.getParameter("quota_id"), -1); |
5506 |
19 Nov 10 |
nicklas |
219 |
if (quotaId >= 0) // < 0 = denied or unchanged |
585 |
13 May 05 |
nicklas |
220 |
{ |
5506 |
19 Nov 10 |
nicklas |
221 |
user.setQuota(quotaId == 0 ? null : Quota.getById(dc, quotaId)); |
585 |
13 May 05 |
nicklas |
222 |
} |
5506 |
19 Nov 10 |
nicklas |
223 |
int quotaGroupId = Values.getInt(request.getParameter("quotagroup_id"), -1); |
5506 |
19 Nov 10 |
nicklas |
224 |
if (quotaGroupId >= 0) // < 0 = denied or unchanged |
3535 |
28 Jun 07 |
martin |
225 |
{ |
5506 |
19 Nov 10 |
nicklas |
226 |
user.setQuotaGroup(quotaGroupId == 0 ? null : Group.getById(dc, quotaGroupId)); |
3535 |
28 Jun 07 |
martin |
227 |
} |
5506 |
19 Nov 10 |
nicklas |
228 |
String homeDirectory = request.getParameter("homedirectory_id"); |
5506 |
19 Nov 10 |
nicklas |
229 |
if ("new".equals(homeDirectory)) |
5506 |
19 Nov 10 |
nicklas |
230 |
{ |
5506 |
19 Nov 10 |
nicklas |
231 |
Directory.createHomeDirectory(dc, user, false); |
5506 |
19 Nov 10 |
nicklas |
232 |
} |
5506 |
19 Nov 10 |
nicklas |
233 |
else if ("template".equals(homeDirectory)) |
5506 |
19 Nov 10 |
nicklas |
234 |
{ |
5506 |
19 Nov 10 |
nicklas |
235 |
Directory.createHomeDirectory(dc, user, true); |
5506 |
19 Nov 10 |
nicklas |
236 |
} |
5506 |
19 Nov 10 |
nicklas |
237 |
else |
5506 |
19 Nov 10 |
nicklas |
238 |
{ |
5506 |
19 Nov 10 |
nicklas |
239 |
int homeDirectoryId = Values.getInt(homeDirectory, -1); |
5506 |
19 Nov 10 |
nicklas |
240 |
if (homeDirectoryId >= 0) // < 0 = denied or unchanged |
5506 |
19 Nov 10 |
nicklas |
241 |
{ |
5506 |
19 Nov 10 |
nicklas |
242 |
user.setHomeDirectory(homeDirectoryId == 0 ? null : Directory.getById(dc, homeDirectoryId)); |
5506 |
19 Nov 10 |
nicklas |
243 |
} |
5506 |
19 Nov 10 |
nicklas |
244 |
} |
5506 |
19 Nov 10 |
nicklas |
245 |
|
5506 |
19 Nov 10 |
nicklas |
246 |
Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
5506 |
19 Nov 10 |
nicklas |
247 |
user.setExpirationDate(dateFormatter.parseString(Values.getStringOrNull(request.getParameter("expiration_date")))); |
5506 |
19 Nov 10 |
nicklas |
248 |
user.setMultiuserAccount(Values.getBoolean(request.getParameter("multiuser_account"))); |
5506 |
19 Nov 10 |
nicklas |
249 |
user.setDisabled(Values.getBoolean(request.getParameter("disabled"))); |
5506 |
19 Nov 10 |
nicklas |
250 |
|
5506 |
19 Nov 10 |
nicklas |
251 |
// Contact information |
5506 |
19 Nov 10 |
nicklas |
252 |
user.setEmail(email); |
7404 |
04 Oct 17 |
nicklas |
253 |
// NOTE!! Important that this is done in this order since setEmail() resets the device verification flag |
7404 |
04 Oct 17 |
nicklas |
254 |
user.setUseDeviceVerification(Values.getBoolean(request.getParameter("use_device_verification"))); |
5506 |
19 Nov 10 |
nicklas |
255 |
user.setOrganisation(Values.getStringOrNull(request.getParameter("organisation"))); |
5506 |
19 Nov 10 |
nicklas |
256 |
user.setAddress(Values.getStringOrNull(request.getParameter("address"))); |
5506 |
19 Nov 10 |
nicklas |
257 |
user.setPhone(Values.getStringOrNull(request.getParameter("phone"))); |
5506 |
19 Nov 10 |
nicklas |
258 |
user.setFax(Values.getStringOrNull(request.getParameter("fax"))); |
5506 |
19 Nov 10 |
nicklas |
259 |
user.setUrl(Values.getStringOrNull(request.getParameter("url"))); |
5506 |
19 Nov 10 |
nicklas |
260 |
user.setDescription(Values.getStringOrNull(request.getParameter("description"))); |
5506 |
19 Nov 10 |
nicklas |
261 |
|
5506 |
19 Nov 10 |
nicklas |
262 |
// Extended properties |
7496 |
11 Jul 18 |
nicklas |
263 |
List<ExtendedProperty> extendedProperties = ExtendedProperties.getProperties("UserData", true); |
5506 |
19 Nov 10 |
nicklas |
264 |
if (extendedProperties != null) |
5506 |
19 Nov 10 |
nicklas |
265 |
{ |
7496 |
11 Jul 18 |
nicklas |
266 |
Map<String, String[]> parameters = request.getParameterMap(); |
5506 |
19 Nov 10 |
nicklas |
267 |
for (ExtendedProperty ep : extendedProperties) |
5506 |
19 Nov 10 |
nicklas |
268 |
{ |
5506 |
19 Nov 10 |
nicklas |
269 |
String name = ep.getName(); |
7496 |
11 Jul 18 |
nicklas |
270 |
if (parameters.containsKey("ep."+name)) |
7496 |
11 Jul 18 |
nicklas |
271 |
{ |
7604 |
25 Feb 19 |
nicklas |
272 |
@SuppressWarnings("rawtypes") |
7496 |
11 Jul 18 |
nicklas |
273 |
Formatter formatter = FormatterFactory.getExtendedPropertyFormatter(sc, ep); |
7496 |
11 Jul 18 |
nicklas |
274 |
Object value = formatter.parseString(Values.getStringOrNull(request.getParameter("ep."+name))); |
7496 |
11 Jul 18 |
nicklas |
275 |
user.setExtended(name, value); |
7496 |
11 Jul 18 |
nicklas |
276 |
} |
5506 |
19 Nov 10 |
nicklas |
277 |
} |
5506 |
19 Nov 10 |
nicklas |
278 |
} |
5506 |
19 Nov 10 |
nicklas |
279 |
|
5506 |
19 Nov 10 |
nicklas |
280 |
// Membership |
6291 |
11 Jun 13 |
nicklas |
281 |
String[] removeGroups = Values.getString(request.getParameter("-GROUP")).split(","); |
5506 |
19 Nov 10 |
nicklas |
282 |
for (int i = 0; i < removeGroups.length; ++i) |
5506 |
19 Nov 10 |
nicklas |
283 |
{ |
5506 |
19 Nov 10 |
nicklas |
284 |
int groupId = Values.getInt(removeGroups[i], -1); |
5506 |
19 Nov 10 |
nicklas |
285 |
if (groupId != -1) Group.getById(dc, groupId).removeUser(user); |
5506 |
19 Nov 10 |
nicklas |
286 |
} |
5506 |
19 Nov 10 |
nicklas |
287 |
|
6291 |
11 Jun 13 |
nicklas |
288 |
String[] addGroups = Values.getString(request.getParameter("+GROUP")).split(","); |
5506 |
19 Nov 10 |
nicklas |
289 |
for (int i = 0; i < addGroups.length; ++i) |
5506 |
19 Nov 10 |
nicklas |
290 |
{ |
5506 |
19 Nov 10 |
nicklas |
291 |
int groupId = Values.getInt(addGroups[i], -1); |
5506 |
19 Nov 10 |
nicklas |
292 |
if (groupId != -1) Group.getById(dc, groupId).addUser(user); |
5506 |
19 Nov 10 |
nicklas |
293 |
} |
5506 |
19 Nov 10 |
nicklas |
294 |
|
6291 |
11 Jun 13 |
nicklas |
295 |
String[] removeRoles = Values.getString(request.getParameter("-ROLE")).split(","); |
5506 |
19 Nov 10 |
nicklas |
296 |
for (int i = 0; i < removeRoles.length; ++i) |
5506 |
19 Nov 10 |
nicklas |
297 |
{ |
5506 |
19 Nov 10 |
nicklas |
298 |
int roleId = Values.getInt(removeRoles[i], -1); |
5506 |
19 Nov 10 |
nicklas |
299 |
if (roleId != -1) Role.getById(dc, roleId).removeUser(user); |
5506 |
19 Nov 10 |
nicklas |
300 |
} |
5506 |
19 Nov 10 |
nicklas |
301 |
|
6291 |
11 Jun 13 |
nicklas |
302 |
String[] addRoles = Values.getString(request.getParameter("+ROLE")).split(","); |
5506 |
19 Nov 10 |
nicklas |
303 |
for (int i = 0; i < addRoles.length; ++i) |
5506 |
19 Nov 10 |
nicklas |
304 |
{ |
5506 |
19 Nov 10 |
nicklas |
305 |
int roleId = Values.getInt(addRoles[i], -1); |
5506 |
19 Nov 10 |
nicklas |
306 |
if (roleId != -1) Role.getById(dc, roleId).addUser(user); |
5506 |
19 Nov 10 |
nicklas |
307 |
} |
5506 |
19 Nov 10 |
nicklas |
308 |
|
5506 |
19 Nov 10 |
nicklas |
309 |
// OnSave extensions |
5506 |
19 Nov 10 |
nicklas |
310 |
invoker.render(OnSaveRenderer.ON_SAVE); |
5506 |
19 Nov 10 |
nicklas |
311 |
try |
5506 |
19 Nov 10 |
nicklas |
312 |
{ |
5506 |
19 Nov 10 |
nicklas |
313 |
dc.commit(); |
5506 |
19 Nov 10 |
nicklas |
314 |
invoker.render(OnSaveRenderer.ON_COMMIT); |
5506 |
19 Nov 10 |
nicklas |
315 |
} |
5506 |
19 Nov 10 |
nicklas |
316 |
catch (DatabaseException dbex) |
5506 |
19 Nov 10 |
nicklas |
317 |
{ |
7954 |
12 May 21 |
nicklas |
318 |
dc = sc.newDbControl(":Check login/external id for user"); |
5506 |
19 Nov 10 |
nicklas |
319 |
if (loginHasChanged && login != null && !login.equals(oldLogin) && User.loginIsUsed(dc, login)) |
5506 |
19 Nov 10 |
nicklas |
320 |
{ |
5506 |
19 Nov 10 |
nicklas |
321 |
throw new ItemAlreadyExistsException("User[login=" + login + "]"); |
5506 |
19 Nov 10 |
nicklas |
322 |
} |
5506 |
19 Nov 10 |
nicklas |
323 |
String externalId = Values.getStringOrNull(request.getParameter("external_id")); |
5506 |
19 Nov 10 |
nicklas |
324 |
if (externalIdHasChanged && externalId != null && !externalId.equals(oldExternalId) && User.externalIdIsUsed(dc, externalId)) |
5506 |
19 Nov 10 |
nicklas |
325 |
{ |
5506 |
19 Nov 10 |
nicklas |
326 |
throw new ItemAlreadyExistsException("User[externalId=" + externalId + "]"); |
5506 |
19 Nov 10 |
nicklas |
327 |
} |
5506 |
19 Nov 10 |
nicklas |
328 |
throw dbex; |
5506 |
19 Nov 10 |
nicklas |
329 |
} |
3535 |
28 Jun 07 |
martin |
330 |
} |
5506 |
19 Nov 10 |
nicklas |
331 |
catch (Exception ex) |
1968 |
10 Feb 06 |
nicklas |
332 |
{ |
5506 |
19 Nov 10 |
nicklas |
333 |
invoker.render(OnSaveRenderer.onRollback(ex)); |
5506 |
19 Nov 10 |
nicklas |
334 |
throw ex; |
1968 |
10 Feb 06 |
nicklas |
335 |
} |
5506 |
19 Nov 10 |
nicklas |
336 |
finally |
1968 |
10 Feb 06 |
nicklas |
337 |
{ |
5506 |
19 Nov 10 |
nicklas |
338 |
cc.removeObject("item"); |
1968 |
10 Feb 06 |
nicklas |
339 |
} |
1968 |
10 Feb 06 |
nicklas |
340 |
} |
1968 |
10 Feb 06 |
nicklas |
341 |
else if ("DeleteItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
342 |
{ |
1968 |
10 Feb 06 |
nicklas |
343 |
// Delete a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
344 |
dc = sc.newDbControl(":Delete "+itemType); |
1968 |
10 Feb 06 |
nicklas |
345 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
346 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), true); |
1968 |
10 Feb 06 |
nicklas |
347 |
dc.commit(); |
1968 |
10 Feb 06 |
nicklas |
348 |
redirect = viewPage; |
1968 |
10 Feb 06 |
nicklas |
349 |
} |
1968 |
10 Feb 06 |
nicklas |
350 |
else if ("DeleteItems".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
351 |
{ |
1968 |
10 Feb 06 |
nicklas |
352 |
// Delete all selected items on the list page |
7954 |
12 May 21 |
nicklas |
353 |
dc = sc.newDbControl(":Delete "+itemType); |
1968 |
10 Feb 06 |
nicklas |
354 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
355 |
int numTotal = cc.getSelected().size(); |
1968 |
10 Feb 06 |
nicklas |
356 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), true); |
1968 |
10 Feb 06 |
nicklas |
357 |
dc.commit(); |
1968 |
10 Feb 06 |
nicklas |
358 |
if (numTotal != numRemoved) |
1968 |
10 Feb 06 |
nicklas |
359 |
{ |
1968 |
10 Feb 06 |
nicklas |
360 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be deleted, because you have no DELETE permission"; |
1968 |
10 Feb 06 |
nicklas |
361 |
} |
6192 |
31 Oct 12 |
nicklas |
362 |
redirect = listPage; |
1968 |
10 Feb 06 |
nicklas |
363 |
} |
1968 |
10 Feb 06 |
nicklas |
364 |
else if ("RestoreItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
365 |
{ |
1968 |
10 Feb 06 |
nicklas |
366 |
// Restore a single item and then return to the view page |
7954 |
12 May 21 |
nicklas |
367 |
dc = sc.newDbControl(":Restore "+itemType); |
1968 |
10 Feb 06 |
nicklas |
368 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
369 |
RemovableUtil.setRemoved(dc, itemType, Collections.singleton(cc.getId()), false); |
1968 |
10 Feb 06 |
nicklas |
370 |
dc.commit(); |
1968 |
10 Feb 06 |
nicklas |
371 |
redirect = viewPage; |
1968 |
10 Feb 06 |
nicklas |
372 |
} |
1968 |
10 Feb 06 |
nicklas |
373 |
else if ("RestoreItems".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
374 |
{ |
1968 |
10 Feb 06 |
nicklas |
375 |
// Restore all selected items on the list page |
7954 |
12 May 21 |
nicklas |
376 |
dc = sc.newDbControl(":Restore "+itemType); |
1968 |
10 Feb 06 |
nicklas |
377 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
378 |
int numTotal = cc.getSelected().size(); |
1968 |
10 Feb 06 |
nicklas |
379 |
int numRemoved = RemovableUtil.setRemoved(dc, itemType, cc.getSelected(), false); |
1968 |
10 Feb 06 |
nicklas |
380 |
dc.commit(); |
1968 |
10 Feb 06 |
nicklas |
381 |
if (numTotal != numRemoved) |
1968 |
10 Feb 06 |
nicklas |
382 |
{ |
2528 |
15 Aug 06 |
martin |
383 |
message = (numRemoved == 0 ? "No" : "Only "+numRemoved+" of "+numTotal) + " items could be restored, because you have no WRITE permission"; |
1968 |
10 Feb 06 |
nicklas |
384 |
} |
6192 |
31 Oct 12 |
nicklas |
385 |
redirect = listPage; |
1968 |
10 Feb 06 |
nicklas |
386 |
} |
1968 |
10 Feb 06 |
nicklas |
387 |
else if ("ExportItems".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
388 |
{ |
1968 |
10 Feb 06 |
nicklas |
389 |
// Run an export plugin in a list context |
1968 |
10 Feb 06 |
nicklas |
390 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
391 |
final ItemQuery<User> query = User.getQuery(); |
7954 |
12 May 21 |
nicklas |
392 |
dc = sc.newDbControl(":Export "+itemType); |
7914 |
23 Feb 21 |
nicklas |
393 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
394 |
cc.configureQuery(dc, query, jspContext, true); |
1968 |
10 Feb 06 |
nicklas |
395 |
cc.setQuery(query); |
4906 |
24 Apr 09 |
martin |
396 |
registerExportUtils(cc); |
7604 |
25 Feb 19 |
nicklas |
397 |
ExtensionsInvoker<ListColumnAction<User,?>> listInvoker = ListColumnUtil.useExtensions(jspContext); |
7604 |
25 Feb 19 |
nicklas |
398 |
listInvoker.render(new ListColumnExportRenderer<User>(cc)); |
6030 |
28 Mar 12 |
nicklas |
399 |
dc.close(); |
1968 |
10 Feb 06 |
nicklas |
400 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Export+users"; |
1968 |
10 Feb 06 |
nicklas |
401 |
} |
1968 |
10 Feb 06 |
nicklas |
402 |
else if ("ExportItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
403 |
{ |
1968 |
10 Feb 06 |
nicklas |
404 |
// Run an export plugin in single-item context |
1968 |
10 Feb 06 |
nicklas |
405 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
4906 |
24 Apr 09 |
martin |
406 |
registerExportUtils(cc); |
1968 |
10 Feb 06 |
nicklas |
407 |
redirect = "../../common/export/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Export+user"; |
1968 |
10 Feb 06 |
nicklas |
408 |
} |
1968 |
10 Feb 06 |
nicklas |
409 |
else if ("ImportItems".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
410 |
{ |
1968 |
10 Feb 06 |
nicklas |
411 |
// Run an import plugin in a list context |
1968 |
10 Feb 06 |
nicklas |
412 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
413 |
final ItemQuery<User> query = User.getQuery(); |
7954 |
12 May 21 |
nicklas |
414 |
dc = sc.newDbControl(":Import "+itemType); |
7914 |
23 Feb 21 |
nicklas |
415 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
416 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
417 |
dc.close(); |
1968 |
10 Feb 06 |
nicklas |
418 |
cc.setQuery(query); |
1968 |
10 Feb 06 |
nicklas |
419 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&title=Import+users"; |
1968 |
10 Feb 06 |
nicklas |
420 |
} |
1968 |
10 Feb 06 |
nicklas |
421 |
else if ("ImportItem".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
422 |
{ |
1968 |
10 Feb 06 |
nicklas |
423 |
// Run an import plugin in single-item context |
1968 |
10 Feb 06 |
nicklas |
424 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
425 |
redirect = "../../common/import/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&title=Import+user"; |
1968 |
10 Feb 06 |
nicklas |
426 |
} |
1968 |
10 Feb 06 |
nicklas |
427 |
else if ("RunListPlugin".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
428 |
{ |
1968 |
10 Feb 06 |
nicklas |
429 |
// Run another plugin in a list context |
1968 |
10 Feb 06 |
nicklas |
430 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
431 |
final ItemQuery<User> query = User.getQuery(); |
7954 |
12 May 21 |
nicklas |
432 |
dc = sc.newDbControl(":Run plugin "+itemType); |
7914 |
23 Feb 21 |
nicklas |
433 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.list(itemType), null); |
7914 |
23 Feb 21 |
nicklas |
434 |
cc.configureQuery(dc, query, jspContext, true); |
5590 |
16 Mar 11 |
nicklas |
435 |
dc.close(); |
1968 |
10 Feb 06 |
nicklas |
436 |
cc.setQuery(query); |
1968 |
10 Feb 06 |
nicklas |
437 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=LIST&main_type=OTHER&title=Run+plugin"; |
1968 |
10 Feb 06 |
nicklas |
438 |
} |
1968 |
10 Feb 06 |
nicklas |
439 |
else if ("RunPlugin".equals(cmd)) |
1968 |
10 Feb 06 |
nicklas |
440 |
{ |
1968 |
10 Feb 06 |
nicklas |
441 |
// Run another plugin in single-item context |
1968 |
10 Feb 06 |
nicklas |
442 |
ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); |
1968 |
10 Feb 06 |
nicklas |
443 |
redirect = "../../common/plugin/index.jsp?ID="+ID+"&cmd=SelectPlugin&item_type="+itemType.name()+"&context_type=ITEM&main_type=OTHER&title=Run+plugin"; |
1968 |
10 Feb 06 |
nicklas |
444 |
} |
3467 |
08 Jun 07 |
nicklas |
445 |
else if ("EditDefaultMembership".equals(cmd)) |
3467 |
08 Jun 07 |
nicklas |
446 |
{ |
3467 |
08 Jun 07 |
nicklas |
447 |
// Display the edit page for a single item (should be opened in a popup) |
3467 |
08 Jun 07 |
nicklas |
448 |
forward = "edit_default_membership.jsp"; |
3467 |
08 Jun 07 |
nicklas |
449 |
} |
3467 |
08 Jun 07 |
nicklas |
450 |
else if ("UpdateDefaultMembership".equals(cmd)) |
3467 |
08 Jun 07 |
nicklas |
451 |
{ |
7954 |
12 May 21 |
nicklas |
452 |
dc = sc.newDbControl(":Set default groups and roles"); |
3467 |
08 Jun 07 |
nicklas |
453 |
// Membership |
6291 |
11 Jun 13 |
nicklas |
454 |
String[] removeGroups = Values.getString(request.getParameter("-GROUP")).split(","); |
3467 |
08 Jun 07 |
nicklas |
455 |
for (int i = 0; i < removeGroups.length; ++i) |
3467 |
08 Jun 07 |
nicklas |
456 |
{ |
3467 |
08 Jun 07 |
nicklas |
457 |
int groupId = Values.getInt(removeGroups[i], -1); |
3467 |
08 Jun 07 |
nicklas |
458 |
if (groupId != -1) Group.getById(dc, groupId).setDefault(false); |
3467 |
08 Jun 07 |
nicklas |
459 |
} |
3467 |
08 Jun 07 |
nicklas |
460 |
|
6291 |
11 Jun 13 |
nicklas |
461 |
String[] addGroups = Values.getString(request.getParameter("+GROUP")).split(","); |
3467 |
08 Jun 07 |
nicklas |
462 |
for (int i = 0; i < addGroups.length; ++i) |
3467 |
08 Jun 07 |
nicklas |
463 |
{ |
3467 |
08 Jun 07 |
nicklas |
464 |
int groupId = Values.getInt(addGroups[i], -1); |
3467 |
08 Jun 07 |
nicklas |
465 |
if (groupId != -1) Group.getById(dc, groupId).setDefault(true); |
3467 |
08 Jun 07 |
nicklas |
466 |
} |
3467 |
08 Jun 07 |
nicklas |
467 |
|
6291 |
11 Jun 13 |
nicklas |
468 |
String[] removeRoles = Values.getString(request.getParameter("-ROLE")).split(","); |
3467 |
08 Jun 07 |
nicklas |
469 |
for (int i = 0; i < removeRoles.length; ++i) |
3467 |
08 Jun 07 |
nicklas |
470 |
{ |
3467 |
08 Jun 07 |
nicklas |
471 |
int roleId = Values.getInt(removeRoles[i], -1); |
3467 |
08 Jun 07 |
nicklas |
472 |
if (roleId != -1) Role.getById(dc, roleId).setDefault(false); |
3467 |
08 Jun 07 |
nicklas |
473 |
} |
3467 |
08 Jun 07 |
nicklas |
474 |
|
6291 |
11 Jun 13 |
nicklas |
475 |
String[] addRoles = Values.getString(request.getParameter("+ROLE")).split(","); |
3467 |
08 Jun 07 |
nicklas |
476 |
for (int i = 0; i < addRoles.length; ++i) |
3467 |
08 Jun 07 |
nicklas |
477 |
{ |
3467 |
08 Jun 07 |
nicklas |
478 |
int roleId = Values.getInt(addRoles[i], -1); |
3467 |
08 Jun 07 |
nicklas |
479 |
if (roleId != -1) Role.getById(dc, roleId).setDefault(true); |
3467 |
08 Jun 07 |
nicklas |
480 |
} |
3467 |
08 Jun 07 |
nicklas |
481 |
dc.commit(); |
3467 |
08 Jun 07 |
nicklas |
482 |
} |
3467 |
08 Jun 07 |
nicklas |
483 |
|
1968 |
10 Feb 06 |
nicklas |
484 |
else |
1968 |
10 Feb 06 |
nicklas |
485 |
{ |
1968 |
10 Feb 06 |
nicklas |
486 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
1968 |
10 Feb 06 |
nicklas |
487 |
} |
502 |
02 May 05 |
nicklas |
488 |
} |
502 |
02 May 05 |
nicklas |
489 |
finally |
502 |
02 May 05 |
nicklas |
490 |
{ |
502 |
02 May 05 |
nicklas |
491 |
if (dc != null) dc.close(); |
502 |
02 May 05 |
nicklas |
492 |
} |
1968 |
10 Feb 06 |
nicklas |
493 |
|
1968 |
10 Feb 06 |
nicklas |
494 |
if (forward != null) |
1968 |
10 Feb 06 |
nicklas |
495 |
{ |
6192 |
31 Oct 12 |
nicklas |
496 |
sc.setSessionSetting("alert-message", message); |
1968 |
10 Feb 06 |
nicklas |
497 |
pageContext.forward(forward); |
1968 |
10 Feb 06 |
nicklas |
498 |
} |
1968 |
10 Feb 06 |
nicklas |
499 |
else if (redirect != null) |
1968 |
10 Feb 06 |
nicklas |
500 |
{ |
6192 |
31 Oct 12 |
nicklas |
501 |
sc.setSessionSetting("alert-message", message); |
1968 |
10 Feb 06 |
nicklas |
502 |
response.sendRedirect(redirect); |
1968 |
10 Feb 06 |
nicklas |
503 |
} |
1968 |
10 Feb 06 |
nicklas |
504 |
else if (message == null) |
1968 |
10 Feb 06 |
nicklas |
505 |
{ |
1968 |
10 Feb 06 |
nicklas |
506 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
1968 |
10 Feb 06 |
nicklas |
507 |
} |
1968 |
10 Feb 06 |
nicklas |
508 |
else |
1968 |
10 Feb 06 |
nicklas |
509 |
{ |
1968 |
10 Feb 06 |
nicklas |
510 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
1968 |
10 Feb 06 |
nicklas |
511 |
} |
1968 |
10 Feb 06 |
nicklas |
512 |
%> |
1968 |
10 Feb 06 |
nicklas |
513 |
|