5936 |
27 Jan 12 |
nicklas |
1 |
<%-- $Id$ |
5936 |
27 Jan 12 |
nicklas |
2 |
------------------------------------------------------------------ |
5936 |
27 Jan 12 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
5936 |
27 Jan 12 |
nicklas |
4 |
|
5936 |
27 Jan 12 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
5936 |
27 Jan 12 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
5936 |
27 Jan 12 |
nicklas |
7 |
|
5936 |
27 Jan 12 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
5936 |
27 Jan 12 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
5936 |
27 Jan 12 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
5936 |
27 Jan 12 |
nicklas |
11 |
of the License, or (at your option) any later version. |
5936 |
27 Jan 12 |
nicklas |
12 |
|
5936 |
27 Jan 12 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
5936 |
27 Jan 12 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5936 |
27 Jan 12 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5936 |
27 Jan 12 |
nicklas |
16 |
GNU General Public License for more details. |
5936 |
27 Jan 12 |
nicklas |
17 |
|
5936 |
27 Jan 12 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
5936 |
27 Jan 12 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5936 |
27 Jan 12 |
nicklas |
20 |
------------------------------------------------------------------ |
5936 |
27 Jan 12 |
nicklas |
21 |
|
5936 |
27 Jan 12 |
nicklas |
22 |
@author Nicklas |
5936 |
27 Jan 12 |
nicklas |
23 |
@since 3.1 |
5936 |
27 Jan 12 |
nicklas |
24 |
--%> |
5936 |
27 Jan 12 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
5936 |
27 Jan 12 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
5936 |
27 Jan 12 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
5936 |
27 Jan 12 |
nicklas |
28 |
import="net.sf.basedb.core.Item" |
5936 |
27 Jan 12 |
nicklas |
29 |
import="net.sf.basedb.core.ItemContext" |
5936 |
27 Jan 12 |
nicklas |
30 |
import="net.sf.basedb.core.MultiPermissions" |
5936 |
27 Jan 12 |
nicklas |
31 |
import="net.sf.basedb.core.Permission" |
5936 |
27 Jan 12 |
nicklas |
32 |
import="net.sf.basedb.core.SharedItem" |
7212 |
19 Oct 16 |
nicklas |
33 |
import="net.sf.basedb.core.Annotatable" |
5936 |
27 Jan 12 |
nicklas |
34 |
import="net.sf.basedb.core.User" |
5936 |
27 Jan 12 |
nicklas |
35 |
import="net.sf.basedb.core.Group" |
5936 |
27 Jan 12 |
nicklas |
36 |
import="net.sf.basedb.core.Project" |
5936 |
27 Jan 12 |
nicklas |
37 |
import="net.sf.basedb.clients.web.Base" |
5936 |
27 Jan 12 |
nicklas |
38 |
import="net.sf.basedb.clients.web.PermissionUtil" |
5936 |
27 Jan 12 |
nicklas |
39 |
import="net.sf.basedb.clients.web.util.HTML" |
5936 |
27 Jan 12 |
nicklas |
40 |
import="net.sf.basedb.util.Values" |
5936 |
27 Jan 12 |
nicklas |
41 |
import="java.util.List" |
5936 |
27 Jan 12 |
nicklas |
42 |
import="java.util.Set" |
5936 |
27 Jan 12 |
nicklas |
43 |
import="java.util.Collections" |
5936 |
27 Jan 12 |
nicklas |
44 |
%> |
5936 |
27 Jan 12 |
nicklas |
45 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
5936 |
27 Jan 12 |
nicklas |
46 |
<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
5936 |
27 Jan 12 |
nicklas |
47 |
|
5936 |
27 Jan 12 |
nicklas |
48 |
<% |
5936 |
27 Jan 12 |
nicklas |
49 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
5936 |
27 Jan 12 |
nicklas |
50 |
final String ID = sc.getId(); |
5936 |
27 Jan 12 |
nicklas |
51 |
final Item itemType = Item.valueOf(request.getParameter("item_type")); |
5936 |
27 Jan 12 |
nicklas |
52 |
final int itemId = Values.getInt(request.getParameter("item_id")); |
5936 |
27 Jan 12 |
nicklas |
53 |
final ItemContext cc = sc.getCurrentContext(itemType); |
5936 |
27 Jan 12 |
nicklas |
54 |
final String title = Values.getString(request.getParameter("title"), "Shared to"); |
7954 |
12 May 21 |
nicklas |
55 |
final DbControl dc = sc.newDbControl(":List access permissions"); |
5936 |
27 Jan 12 |
nicklas |
56 |
|
5936 |
27 Jan 12 |
nicklas |
57 |
try |
5936 |
27 Jan 12 |
nicklas |
58 |
{ |
5936 |
27 Jan 12 |
nicklas |
59 |
SharedItem item = (SharedItem)itemType.getById(dc, itemId); |
7212 |
19 Oct 16 |
nicklas |
60 |
String useRestrictedWrite = item instanceof Annotatable ? "A" : null; |
5936 |
27 Jan 12 |
nicklas |
61 |
MultiPermissions mp = new MultiPermissions(Collections.singleton(item)); |
5936 |
27 Jan 12 |
nicklas |
62 |
List<User> users = mp.getUsers().list(dc); |
5936 |
27 Jan 12 |
nicklas |
63 |
List<Group> groups = mp.getGroups().list(dc); |
5936 |
27 Jan 12 |
nicklas |
64 |
List<Project> projects = mp.getProjects().list(dc); |
5936 |
27 Jan 12 |
nicklas |
65 |
int count = users.size() + groups.size() + projects.size(); |
5936 |
27 Jan 12 |
nicklas |
66 |
%> |
5936 |
27 Jan 12 |
nicklas |
67 |
<base:page type="include"> |
5936 |
27 Jan 12 |
nicklas |
68 |
<base:body> |
5936 |
27 Jan 12 |
nicklas |
69 |
<base:section |
5936 |
27 Jan 12 |
nicklas |
70 |
id="sharedTo" |
5936 |
27 Jan 12 |
nicklas |
71 |
title="<%=title + " (" + (count) +")"%>" |
5936 |
27 Jan 12 |
nicklas |
72 |
context="<%=cc%>" |
5936 |
27 Jan 12 |
nicklas |
73 |
> |
5936 |
27 Jan 12 |
nicklas |
74 |
<% |
5936 |
27 Jan 12 |
nicklas |
75 |
if (count == 0) |
5936 |
27 Jan 12 |
nicklas |
76 |
{ |
5936 |
27 Jan 12 |
nicklas |
77 |
%> |
5936 |
27 Jan 12 |
nicklas |
78 |
<div class="messagecontainer note"> |
5936 |
27 Jan 12 |
nicklas |
79 |
This <%=itemType.toString().toLowerCase() %> is not shared |
5936 |
27 Jan 12 |
nicklas |
80 |
(or, you don't have permission to view the ones it is shared to). |
5936 |
27 Jan 12 |
nicklas |
81 |
</div> |
5936 |
27 Jan 12 |
nicklas |
82 |
<% |
5936 |
27 Jan 12 |
nicklas |
83 |
} |
5936 |
27 Jan 12 |
nicklas |
84 |
else |
5936 |
27 Jan 12 |
nicklas |
85 |
{ |
5936 |
27 Jan 12 |
nicklas |
86 |
%> |
5936 |
27 Jan 12 |
nicklas |
87 |
<tbl:table |
5936 |
27 Jan 12 |
nicklas |
88 |
id="itemsSharedTo" |
5936 |
27 Jan 12 |
nicklas |
89 |
columns="all" |
5936 |
27 Jan 12 |
nicklas |
90 |
> |
5936 |
27 Jan 12 |
nicklas |
91 |
<tbl:columndef |
5936 |
27 Jan 12 |
nicklas |
92 |
id="itemType" |
5936 |
27 Jan 12 |
nicklas |
93 |
title="Item type" |
5936 |
27 Jan 12 |
nicklas |
94 |
/> |
5936 |
27 Jan 12 |
nicklas |
95 |
<tbl:columndef |
5936 |
27 Jan 12 |
nicklas |
96 |
id="name" |
5936 |
27 Jan 12 |
nicklas |
97 |
title="Name" |
5936 |
27 Jan 12 |
nicklas |
98 |
/> |
5936 |
27 Jan 12 |
nicklas |
99 |
<tbl:columndef |
5936 |
27 Jan 12 |
nicklas |
100 |
id="permissions" |
5936 |
27 Jan 12 |
nicklas |
101 |
title="Permissions" |
5936 |
27 Jan 12 |
nicklas |
102 |
/> |
5936 |
27 Jan 12 |
nicklas |
103 |
<tbl:data> |
5936 |
27 Jan 12 |
nicklas |
104 |
<tbl:headers> |
5936 |
27 Jan 12 |
nicklas |
105 |
<tbl:headerrow> |
5936 |
27 Jan 12 |
nicklas |
106 |
<tbl:columnheaders /> |
5936 |
27 Jan 12 |
nicklas |
107 |
</tbl:headerrow> |
5936 |
27 Jan 12 |
nicklas |
108 |
</tbl:headers> |
5936 |
27 Jan 12 |
nicklas |
109 |
<tbl:rows> |
5936 |
27 Jan 12 |
nicklas |
110 |
<% |
5936 |
27 Jan 12 |
nicklas |
111 |
for (Project project : projects) |
5936 |
27 Jan 12 |
nicklas |
112 |
{ |
5936 |
27 Jan 12 |
nicklas |
113 |
Set<Permission> permissions = mp.getPermissions(project).values().iterator().next(); |
5936 |
27 Jan 12 |
nicklas |
114 |
%> |
5936 |
27 Jan 12 |
nicklas |
115 |
<tbl:row> |
5936 |
27 Jan 12 |
nicklas |
116 |
<tbl:cell column="itemType"><%=project.getType()%></tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
117 |
<tbl:cell column="name"><base:icon |
5946 |
03 Feb 12 |
nicklas |
118 |
image="deleted.png" |
5936 |
27 Jan 12 |
nicklas |
119 |
tooltip="This item has been scheduled for deletion" |
5936 |
27 Jan 12 |
nicklas |
120 |
visible="<%=project.isRemoved()%>" |
5936 |
27 Jan 12 |
nicklas |
121 |
/><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
122 |
<tbl:cell column="permissions"> |
7212 |
19 Oct 16 |
nicklas |
123 |
<%=PermissionUtil.translatePermissionsToString(permissions, useRestrictedWrite)%> |
5936 |
27 Jan 12 |
nicklas |
124 |
</tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
125 |
</tbl:row> |
5936 |
27 Jan 12 |
nicklas |
126 |
<% |
5936 |
27 Jan 12 |
nicklas |
127 |
} |
5936 |
27 Jan 12 |
nicklas |
128 |
for (Group group : groups) |
5936 |
27 Jan 12 |
nicklas |
129 |
{ |
5936 |
27 Jan 12 |
nicklas |
130 |
Set<Permission> permissions = mp.getPermissions(group).values().iterator().next(); |
5936 |
27 Jan 12 |
nicklas |
131 |
%> |
5936 |
27 Jan 12 |
nicklas |
132 |
<tbl:row> |
5936 |
27 Jan 12 |
nicklas |
133 |
<tbl:cell column="itemType"><%=group.getType()%></tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
134 |
<tbl:cell column="name"><base:icon |
5946 |
03 Feb 12 |
nicklas |
135 |
image="deleted.png" |
5936 |
27 Jan 12 |
nicklas |
136 |
tooltip="This item has been scheduled for deletion" |
5936 |
27 Jan 12 |
nicklas |
137 |
visible="<%=group.isRemoved()%>" |
5936 |
27 Jan 12 |
nicklas |
138 |
/><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
139 |
<tbl:cell column="permissions"> |
7212 |
19 Oct 16 |
nicklas |
140 |
<%=PermissionUtil.translatePermissionsToString(permissions, useRestrictedWrite)%> |
5936 |
27 Jan 12 |
nicklas |
141 |
</tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
142 |
</tbl:row> |
5936 |
27 Jan 12 |
nicklas |
143 |
<% |
5936 |
27 Jan 12 |
nicklas |
144 |
} |
5936 |
27 Jan 12 |
nicklas |
145 |
for (User user : users) |
5936 |
27 Jan 12 |
nicklas |
146 |
{ |
5936 |
27 Jan 12 |
nicklas |
147 |
Set<Permission> permissions = mp.getPermissions(user).values().iterator().next(); |
5936 |
27 Jan 12 |
nicklas |
148 |
%> |
5936 |
27 Jan 12 |
nicklas |
149 |
<tbl:row> |
5936 |
27 Jan 12 |
nicklas |
150 |
<tbl:cell column="itemType"><%=user.getType()%></tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
151 |
<tbl:cell column="name"><base:icon |
5946 |
03 Feb 12 |
nicklas |
152 |
image="deleted.png" |
5936 |
27 Jan 12 |
nicklas |
153 |
tooltip="This item has been scheduled for deletion" |
5936 |
27 Jan 12 |
nicklas |
154 |
visible="<%=user.isRemoved()%>" |
5936 |
27 Jan 12 |
nicklas |
155 |
/><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
156 |
<tbl:cell column="permissions"> |
7212 |
19 Oct 16 |
nicklas |
157 |
<%=PermissionUtil.translatePermissionsToString(permissions, useRestrictedWrite)%> |
5936 |
27 Jan 12 |
nicklas |
158 |
</tbl:cell> |
5936 |
27 Jan 12 |
nicklas |
159 |
</tbl:row> |
5936 |
27 Jan 12 |
nicklas |
160 |
<% |
5936 |
27 Jan 12 |
nicklas |
161 |
} |
5936 |
27 Jan 12 |
nicklas |
162 |
%> |
5936 |
27 Jan 12 |
nicklas |
163 |
</tbl:rows> |
5936 |
27 Jan 12 |
nicklas |
164 |
</tbl:data> |
5936 |
27 Jan 12 |
nicklas |
165 |
</tbl:table> |
5936 |
27 Jan 12 |
nicklas |
166 |
<% |
5936 |
27 Jan 12 |
nicklas |
167 |
} |
5936 |
27 Jan 12 |
nicklas |
168 |
%> |
5936 |
27 Jan 12 |
nicklas |
169 |
</base:section> |
5936 |
27 Jan 12 |
nicklas |
170 |
</base:body> |
5936 |
27 Jan 12 |
nicklas |
171 |
</base:page> |
5936 |
27 Jan 12 |
nicklas |
172 |
<% |
5936 |
27 Jan 12 |
nicklas |
173 |
} |
5936 |
27 Jan 12 |
nicklas |
174 |
finally |
5936 |
27 Jan 12 |
nicklas |
175 |
{ |
5936 |
27 Jan 12 |
nicklas |
176 |
if (dc != null) dc.close(); |
5936 |
27 Jan 12 |
nicklas |
177 |
} |
5936 |
27 Jan 12 |
nicklas |
178 |
|
5936 |
27 Jan 12 |
nicklas |
179 |
%> |