620 |
19 May 05 |
nicklas |
1 |
<%-- $Id$ |
620 |
19 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 |
620 |
19 May 05 |
nicklas |
5 |
|
2304 |
22 May 06 |
jari |
6 |
This file is part of BASE - BioArray Software Environment. |
2304 |
22 May 06 |
jari |
7 |
Available at http://base.thep.lu.se/ |
620 |
19 May 05 |
nicklas |
8 |
|
620 |
19 May 05 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
620 |
19 May 05 |
nicklas |
10 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
11 |
as published by the Free Software Foundation; either version 3 |
620 |
19 May 05 |
nicklas |
12 |
of the License, or (at your option) any later version. |
620 |
19 May 05 |
nicklas |
13 |
|
620 |
19 May 05 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
620 |
19 May 05 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
620 |
19 May 05 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
620 |
19 May 05 |
nicklas |
17 |
GNU General Public License for more details. |
620 |
19 May 05 |
nicklas |
18 |
|
620 |
19 May 05 |
nicklas |
19 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
620 |
19 May 05 |
nicklas |
21 |
------------------------------------------------------------------ |
620 |
19 May 05 |
nicklas |
22 |
|
620 |
19 May 05 |
nicklas |
23 |
Configure the order and visibility of columns in a table of items. |
620 |
19 May 05 |
nicklas |
24 |
This page will use the TableColumn.getTableColumns(item) to retreive the |
620 |
19 May 05 |
nicklas |
25 |
list of all available columns for that item type and |
620 |
19 May 05 |
nicklas |
26 |
getSession().getSetting(item+".columns") to retreive a comma-separated |
620 |
19 May 05 |
nicklas |
27 |
list of the current order of visible columns. |
620 |
19 May 05 |
nicklas |
28 |
|
620 |
19 May 05 |
nicklas |
29 |
@param item The type of items in the table |
620 |
19 May 05 |
nicklas |
30 |
@param cmd |
620 |
19 May 05 |
nicklas |
31 |
- Save: To save the settings |
620 |
19 May 05 |
nicklas |
32 |
- otherwise: A configuration dialouge is displayed |
620 |
19 May 05 |
nicklas |
33 |
@param columns Only used if cmd=Save. Contains a comma-separated list |
620 |
19 May 05 |
nicklas |
34 |
of column ID:s which is saved to a user-client setting. |
620 |
19 May 05 |
nicklas |
35 |
|
620 |
19 May 05 |
nicklas |
36 |
@author Nicklas |
620 |
19 May 05 |
nicklas |
37 |
@version 2.0 |
620 |
19 May 05 |
nicklas |
38 |
--%> |
5426 |
24 Sep 10 |
nicklas |
39 |
<%@ page pageEncoding="UTF-8" session="false" |
620 |
19 May 05 |
nicklas |
40 |
import="net.sf.basedb.core.SessionControl" |
620 |
19 May 05 |
nicklas |
41 |
import="net.sf.basedb.core.DbControl" |
620 |
19 May 05 |
nicklas |
42 |
import="net.sf.basedb.core.Item" |
620 |
19 May 05 |
nicklas |
43 |
import="net.sf.basedb.core.Permission" |
620 |
19 May 05 |
nicklas |
44 |
import="net.sf.basedb.core.MultiPermissions" |
2218 |
05 May 06 |
nicklas |
45 |
import="net.sf.basedb.core.ItemContext" |
620 |
19 May 05 |
nicklas |
46 |
import="net.sf.basedb.core.User" |
620 |
19 May 05 |
nicklas |
47 |
import="net.sf.basedb.core.Group" |
620 |
19 May 05 |
nicklas |
48 |
import="net.sf.basedb.core.Project" |
5370 |
23 Jun 10 |
nicklas |
49 |
import="net.sf.basedb.core.PermissionTemplate" |
620 |
19 May 05 |
nicklas |
50 |
import="net.sf.basedb.clients.web.Base" |
1965 |
10 Feb 06 |
nicklas |
51 |
import="net.sf.basedb.clients.web.PermissionUtil" |
620 |
19 May 05 |
nicklas |
52 |
import="net.sf.basedb.clients.web.WebException" |
2753 |
20 Oct 06 |
nicklas |
53 |
import="net.sf.basedb.util.Values" |
620 |
19 May 05 |
nicklas |
54 |
import="net.sf.basedb.clients.web.util.HTML" |
620 |
19 May 05 |
nicklas |
55 |
import="java.util.Arrays" |
620 |
19 May 05 |
nicklas |
56 |
import="java.util.Set" |
620 |
19 May 05 |
nicklas |
57 |
%> |
620 |
19 May 05 |
nicklas |
58 |
<% |
620 |
19 May 05 |
nicklas |
59 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
620 |
19 May 05 |
nicklas |
60 |
final String ID = sc.getId(); |
620 |
19 May 05 |
nicklas |
61 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
2218 |
05 May 06 |
nicklas |
62 |
final String subContext = Values.getString(request.getParameter("subcontext"), ""); |
620 |
19 May 05 |
nicklas |
63 |
final String cmd = request.getParameter("cmd"); |
620 |
19 May 05 |
nicklas |
64 |
final String root = request.getContextPath()+"/"; |
620 |
19 May 05 |
nicklas |
65 |
|
620 |
19 May 05 |
nicklas |
66 |
String forward = null; |
620 |
19 May 05 |
nicklas |
67 |
String message = null; |
7954 |
12 May 21 |
nicklas |
68 |
final DbControl dc = sc.newDbControl(":Update permissions"); |
620 |
19 May 05 |
nicklas |
69 |
try |
620 |
19 May 05 |
nicklas |
70 |
{ |
620 |
19 May 05 |
nicklas |
71 |
if ("Save".equals(cmd)) |
620 |
19 May 05 |
nicklas |
72 |
{ |
2218 |
05 May 06 |
nicklas |
73 |
ItemContext cc = sc.getCurrentContext(itemType, subContext); |
7605 |
26 Feb 19 |
nicklas |
74 |
MultiPermissions mp = cc.getObject("MultiPermissions"); |
4312 |
26 May 08 |
nicklas |
75 |
boolean recursive = Values.getBoolean(request.getParameter("recursive")); |
1713 |
14 Dec 05 |
nicklas |
76 |
|
6322 |
11 Sep 13 |
nicklas |
77 |
String[] modifiedUsers = Values.getString(request.getParameter("!USER")).split(","); |
620 |
19 May 05 |
nicklas |
78 |
for (int i = 0; i < modifiedUsers.length; ++i) |
620 |
19 May 05 |
nicklas |
79 |
{ |
620 |
19 May 05 |
nicklas |
80 |
int userId = Values.getInt(modifiedUsers[i], -1); |
620 |
19 May 05 |
nicklas |
81 |
if (userId != -1) |
620 |
19 May 05 |
nicklas |
82 |
{ |
6322 |
11 Sep 13 |
nicklas |
83 |
Set<Permission> permissions = PermissionUtil.getPermissions(Values.getInt(request.getParameter("USER."+userId), 0)); |
620 |
19 May 05 |
nicklas |
84 |
mp.setPermissions(User.getById(dc, userId), permissions); |
620 |
19 May 05 |
nicklas |
85 |
} |
620 |
19 May 05 |
nicklas |
86 |
} |
620 |
19 May 05 |
nicklas |
87 |
|
6322 |
11 Sep 13 |
nicklas |
88 |
String[] modifiedGroups = Values.getString(request.getParameter("!GROUP")).split(","); |
620 |
19 May 05 |
nicklas |
89 |
for (int i = 0; i < modifiedGroups.length; ++i) |
620 |
19 May 05 |
nicklas |
90 |
{ |
620 |
19 May 05 |
nicklas |
91 |
int groupId = Values.getInt(modifiedGroups[i], -1); |
620 |
19 May 05 |
nicklas |
92 |
if (groupId != -1) |
620 |
19 May 05 |
nicklas |
93 |
{ |
6322 |
11 Sep 13 |
nicklas |
94 |
Set<Permission> permissions = PermissionUtil.getPermissions(Values.getInt(request.getParameter("GROUP."+groupId), 0)); |
620 |
19 May 05 |
nicklas |
95 |
mp.setPermissions(Group.getById(dc, groupId), permissions); |
620 |
19 May 05 |
nicklas |
96 |
} |
620 |
19 May 05 |
nicklas |
97 |
} |
620 |
19 May 05 |
nicklas |
98 |
|
6322 |
11 Sep 13 |
nicklas |
99 |
String[] modifiedProjects = Values.getString(request.getParameter("!PROJECT")).split(","); |
620 |
19 May 05 |
nicklas |
100 |
for (int i = 0; i < modifiedProjects.length; ++i) |
620 |
19 May 05 |
nicklas |
101 |
{ |
620 |
19 May 05 |
nicklas |
102 |
int projectId = Values.getInt(modifiedProjects[i], -1); |
620 |
19 May 05 |
nicklas |
103 |
if (projectId != -1) |
620 |
19 May 05 |
nicklas |
104 |
{ |
6322 |
11 Sep 13 |
nicklas |
105 |
Set<Permission> permissions = PermissionUtil.getPermissions(Values.getInt(request.getParameter("PROJECT."+projectId), 0)); |
620 |
19 May 05 |
nicklas |
106 |
mp.setPermissions(Project.getById(dc, projectId), permissions); |
620 |
19 May 05 |
nicklas |
107 |
} |
620 |
19 May 05 |
nicklas |
108 |
} |
5370 |
23 Jun 10 |
nicklas |
109 |
|
6322 |
11 Sep 13 |
nicklas |
110 |
String[] permissionTemplates = Values.getString(request.getParameter("!PERMISSIONTEMPLATE")).split(","); |
5370 |
23 Jun 10 |
nicklas |
111 |
for (int i = 0; i < permissionTemplates.length; ++i) |
5370 |
23 Jun 10 |
nicklas |
112 |
{ |
5370 |
23 Jun 10 |
nicklas |
113 |
int permissionTemplateId = Values.getInt(permissionTemplates[i], -1); |
5370 |
23 Jun 10 |
nicklas |
114 |
if (permissionTemplateId != -1) |
5370 |
23 Jun 10 |
nicklas |
115 |
{ |
5370 |
23 Jun 10 |
nicklas |
116 |
PermissionTemplate template = PermissionTemplate.getById(dc, permissionTemplateId); |
5370 |
23 Jun 10 |
nicklas |
117 |
mp.merge(template.getItemKey()); |
5370 |
23 Jun 10 |
nicklas |
118 |
mp.merge(template.getProjectKey()); |
5370 |
23 Jun 10 |
nicklas |
119 |
} |
5370 |
23 Jun 10 |
nicklas |
120 |
} |
5370 |
23 Jun 10 |
nicklas |
121 |
|
5370 |
23 Jun 10 |
nicklas |
122 |
|
4312 |
26 May 08 |
nicklas |
123 |
mp.updateKeys(dc, recursive); |
5136 |
15 Oct 09 |
nicklas |
124 |
sc.reloadPermissions(); |
620 |
19 May 05 |
nicklas |
125 |
dc.commit(); |
2218 |
05 May 06 |
nicklas |
126 |
cc.removeObject("MultiPermissions"); |
620 |
19 May 05 |
nicklas |
127 |
message = "Items shared"; |
620 |
19 May 05 |
nicklas |
128 |
} |
620 |
19 May 05 |
nicklas |
129 |
else |
620 |
19 May 05 |
nicklas |
130 |
{ |
620 |
19 May 05 |
nicklas |
131 |
throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); |
620 |
19 May 05 |
nicklas |
132 |
} |
620 |
19 May 05 |
nicklas |
133 |
} |
620 |
19 May 05 |
nicklas |
134 |
finally |
620 |
19 May 05 |
nicklas |
135 |
{ |
620 |
19 May 05 |
nicklas |
136 |
if (dc != null) dc.close(); |
620 |
19 May 05 |
nicklas |
137 |
} |
620 |
19 May 05 |
nicklas |
138 |
|
620 |
19 May 05 |
nicklas |
139 |
if (forward != null) |
620 |
19 May 05 |
nicklas |
140 |
{ |
6192 |
31 Oct 12 |
nicklas |
141 |
sc.setSessionSetting("alert-message", message); |
620 |
19 May 05 |
nicklas |
142 |
pageContext.forward(forward); |
620 |
19 May 05 |
nicklas |
143 |
} |
620 |
19 May 05 |
nicklas |
144 |
else if (message == null) |
620 |
19 May 05 |
nicklas |
145 |
{ |
620 |
19 May 05 |
nicklas |
146 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0"); |
620 |
19 May 05 |
nicklas |
147 |
} |
620 |
19 May 05 |
nicklas |
148 |
else |
620 |
19 May 05 |
nicklas |
149 |
{ |
620 |
19 May 05 |
nicklas |
150 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message)); |
620 |
19 May 05 |
nicklas |
151 |
} |
620 |
19 May 05 |
nicklas |
152 |
%> |