source: trunk/www/admin/groups/view_group.jsp @ 5042

Last change on this file since 5042 was 5042, checked in by Martin Svensson, 14 years ago

References #360 Covering the submenu items in 'Administrate' menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 10.8 KB
Line 
1<%-- $Id: view_group.jsp 5042 2009-08-11 10:48:42Z martin $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Nicklas Nordborg
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.SystemItems"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.Group"
34  import="net.sf.basedb.core.Quota"
35  import="net.sf.basedb.core.User"
36  import="net.sf.basedb.core.PermissionDeniedException"
37  import="net.sf.basedb.core.PluginDefinition"
38  import="net.sf.basedb.core.ItemQuery"
39  import="net.sf.basedb.core.ItemResultList"
40  import="net.sf.basedb.core.Include"
41  import="net.sf.basedb.core.query.Orders"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.clients.web.Base"
46  import="net.sf.basedb.clients.web.PermissionUtil"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.Values"
49  import="net.sf.basedb.util.formatter.Formatter"
50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
51  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
52  import="net.sf.basedb.clients.web.extensions.JspContext"
53  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
54  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
55  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
56  import="java.util.Date"
57  import="java.util.Map"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
61<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
62<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
63<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
64<%!
65  private static final Item itemType = Item.GROUP;
66  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
67%>
68<%
69final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
70final String ID = sc.getId();
71final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
72final int itemId = cc.getId();
73final float scale = Base.getScale(sc);
74final DbControl dc = sc.newDbControl();
75try
76{
77  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
78  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
79
80  String title = null;
81  Group group = Group.getById(dc, itemId);
82 
83  final boolean writePermission = group.hasPermission(Permission.WRITE);
84  final boolean deletePermission = group.hasPermission(Permission.DELETE);
85  final boolean isRemoved = group.isRemoved();
86  final boolean isUsed = isRemoved && group.isUsed();
87  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
88  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, group);
89  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
90  %>
91  <base:page title="<%=title%>">
92  <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
93    <ext:scripts context="<%=jspContext%>" />
94    <ext:stylesheets context="<%=jspContext%>" />
95    <script language="JavaScript">
96    function editItem()
97    {
98      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
99    }
100    function deleteItem()
101    {
102      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
103    }
104    function restoreItem()
105    {
106      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
107    }
108    function deleteItemPermanently()
109    {
110      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
111    }
112    function itemDeleted()
113    {
114      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
115    }
116    function showUsingItems()
117    {
118      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
119    }
120    function runPlugin(cmd)
121    {
122      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
123    }
124    </script>
125  </base:head>
126  <base:body>
127    <p>
128    <p:path>
129      <p:pathelement title="Groups" href="<%="index.jsp?ID="+ID%>" />
130      <p:pathelement title="<%=HTML.encodeTags(group.getName())%>" />
131    </p:path>
132   
133    <t:tabcontrol id="main" active="properties">
134    <t:tab id="properties" title="Properties">
135   
136    <tbl:toolbar
137      >
138      <tbl:button 
139        disabled="<%=writePermission ? false : true%>" 
140        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
141        onclick="editItem()" 
142        title="Edit&hellip;" 
143        tooltip="<%=writePermission ? "Edit this group" : "You do not have permission to edit this group"%>" 
144      />
145      <tbl:button 
146        disabled="<%=deletePermission ? false : true%>" 
147        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
148        onclick="deleteItem()" 
149        title="Delete"
150        visible="<%=!group.isRemoved()%>"
151        tooltip="<%=deletePermission ? "Delete this group" : "You do not have permission to delete this group"%>" 
152      />
153      <tbl:button 
154        disabled="<%=writePermission ? false : true%>" 
155        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
156        onclick="restoreItem()" 
157        title="Restore"
158        visible="<%=group.isRemoved()%>"
159        tooltip="<%=writePermission ? "Restore this group" : "You do not have permission to restore this group"%>" 
160      />
161      <tbl:button 
162        image="import.gif" 
163        onclick="runPlugin('ImportItem')" 
164        title="Import&hellip;" 
165        tooltip="Import data" 
166        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
167      />
168      <tbl:button 
169        image="export.gif" 
170        onclick="runPlugin('ExportItem')" 
171        title="Export&hellip;" 
172        tooltip="Export data" 
173        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
174      />
175      <tbl:button 
176        image="runplugin.gif" 
177        onclick="runPlugin('RunPlugin')" 
178        title="Run plugin&hellip;" 
179        tooltip="Run a plugin" 
180        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
181      />
182      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
183        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
184      <tbl:button
185        image="help.gif"
186        onclick="<%="Main.openHelp('" + ID +"', 'group.view.properties')"%>"
187        title="Help&hellip;"
188        tooltip="Get help about this page"
189      />
190      </tbl:toolbar>
191    <div class="boxedbottom">
192      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(group)%></i></div>
193      <%
194      if (group.isRemoved())
195      {
196        %>
197        <div class="itemstatus">
198          <base:icon 
199            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
200            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
201            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
202            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
203          <base:icon image="used.gif" 
204            onclick="showUsingItems()"
205            tooltip="Show the items that are using this one"
206            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
207        </div>
208        <%
209      }
210      %>
211      <table class="form" cellspacing=0>
212      <tr>
213        <td class="prompt">Name</td>
214        <td><%=HTML.encodeTags(group.getName())%></td>
215      </tr>
216      <tr>
217        <td class="prompt">Registered</td>
218        <td><%=dateFormatter.format(group.getEntryDate())%></td>
219      </tr>
220      <tr>
221        <td class="prompt">System ID</td>
222        <td><%=HTML.encodeTags(group.getSystemId())%></td>
223      </tr>
224      <tr>
225        <td class="prompt">Quota</td>
226        <td><base:propertyvalue item="<%=group%>" property="quota" /></td>
227      </tr>
228      <tr>
229        <td class="prompt">Is default</td>
230        <td><%=group.isDefault() ? "yes" : "no"%></td>
231      </tr>
232      <tr>
233        <td class="prompt">Description</td>
234        <td><%=HTML.niceFormat(group.getDescription())%></td>
235      </tr>
236      </table>
237     
238      <%
239      ItemQuery<User> userQuery = group.getUsers();
240      userQuery.include(Include.ALL);
241      userQuery.order(Orders.asc(Hql.property("name")));
242      ItemResultList<User> users = userQuery.list(dc);
243     
244      ItemQuery<Group> groupQuery = group.getGroups();
245      groupQuery.include(Include.ALL);
246      groupQuery.order(Orders.asc(Hql.property("name")));
247      ItemResultList<Group> groups = groupQuery.list(dc);
248     
249      if (groups.size() == 0 && users.size() == 0)
250      {
251        %>
252        <h4>Members</h4>
253        There are no members of this group (or, you don't have permission to view them).
254        <%
255      }
256      else
257      {
258        %>
259        <base:section 
260          id="members" 
261          title="<%="Members (" + (users.size() + groups.size()) + ")"%>"
262          context="<%=cc%>"
263          >       
264          <tbl:table
265            id="members"
266            clazz="itemlist"
267            columns="all"
268            >
269          <tbl:columndef 
270            id="name"
271            title="Name"
272          />
273          <tbl:columndef 
274            id="type"
275            title="Type"
276          />
277          <tbl:columndef 
278            id="description"
279            title="Description"
280          />
281          <tbl:data>
282            <tbl:columns>
283            </tbl:columns>
284            <tbl:rows>
285            <%
286            for (User user : users)
287            {
288              %>
289              <tbl:row>
290                <tbl:cell column="name"><base:icon 
291                    image="deleted.gif" 
292                    tooltip="This item has been scheduled for deletion" 
293                    visible="<%=user.isRemoved()%>"
294                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
295                <tbl:cell column="type">User</tbl:cell>
296                <tbl:cell column="description"><%=HTML.encodeTags(user.getDescription())%></tbl:cell>
297              </tbl:row>
298              <%
299            }
300            for (Group child : groups)
301            {
302              %>
303              <tbl:row>
304                <tbl:cell column="name"><base:icon 
305                    image="deleted.gif" 
306                    tooltip="This item has been scheduled for deletion" 
307                    visible="<%=child.isRemoved()%>"
308                  /><%=Base.getLinkedName(ID, child, false, true)%></tbl:cell>
309                <tbl:cell column="type">Group</tbl:cell>
310                <tbl:cell column="description"><%=HTML.encodeTags(child.getDescription())%></tbl:cell>
311              </tbl:row>
312              <%
313            }
314            %>
315            </tbl:rows>
316          </tbl:data>
317          </tbl:table>
318        </base:section>
319        <%
320      }
321      %>
322    </div>
323      </t:tab>
324      </t:tabcontrol>
325
326  </base:body>
327  </base:page>
328  <%
329}
330finally
331{
332  if (dc != null) dc.close();
333}
334
335%>
Note: See TracBrowser for help on using the repository browser.