7294 |
17 Feb 17 |
nicklas |
1 |
<%-- $Id $ |
7294 |
17 Feb 17 |
nicklas |
2 |
------------------------------------------------------------------ |
7294 |
17 Feb 17 |
nicklas |
Copyright (C) 2017 Nicklas Nordborg |
7294 |
17 Feb 17 |
nicklas |
4 |
|
7294 |
17 Feb 17 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
7294 |
17 Feb 17 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
7294 |
17 Feb 17 |
nicklas |
7 |
|
7294 |
17 Feb 17 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
7294 |
17 Feb 17 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
7294 |
17 Feb 17 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
7294 |
17 Feb 17 |
nicklas |
11 |
of the License, or (at your option) any later version. |
7294 |
17 Feb 17 |
nicklas |
12 |
|
7294 |
17 Feb 17 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
7294 |
17 Feb 17 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7294 |
17 Feb 17 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7294 |
17 Feb 17 |
nicklas |
16 |
GNU General Public License for more details. |
7294 |
17 Feb 17 |
nicklas |
17 |
|
7294 |
17 Feb 17 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
7294 |
17 Feb 17 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7294 |
17 Feb 17 |
nicklas |
20 |
------------------------------------------------------------------ |
7294 |
17 Feb 17 |
nicklas |
21 |
|
7294 |
17 Feb 17 |
nicklas |
22 |
@author Nicklas |
7294 |
17 Feb 17 |
nicklas |
23 |
--%> |
7294 |
17 Feb 17 |
nicklas |
24 |
<%@ page pageEncoding="UTF-8" session="false" |
7294 |
17 Feb 17 |
nicklas |
25 |
import="net.sf.basedb.core.SessionControl" |
7294 |
17 Feb 17 |
nicklas |
26 |
import="net.sf.basedb.core.DbControl" |
7294 |
17 Feb 17 |
nicklas |
27 |
import="net.sf.basedb.core.Item" |
7294 |
17 Feb 17 |
nicklas |
28 |
import="net.sf.basedb.core.Role" |
7294 |
17 Feb 17 |
nicklas |
29 |
import="net.sf.basedb.core.Include" |
7294 |
17 Feb 17 |
nicklas |
30 |
import="net.sf.basedb.core.ItemContext" |
7294 |
17 Feb 17 |
nicklas |
31 |
import="net.sf.basedb.core.StringUtil" |
7294 |
17 Feb 17 |
nicklas |
32 |
import="net.sf.basedb.clients.web.Base" |
7294 |
17 Feb 17 |
nicklas |
33 |
import="net.sf.basedb.util.Values" |
7294 |
17 Feb 17 |
nicklas |
34 |
import="net.sf.basedb.clients.web.util.HTML" |
7294 |
17 Feb 17 |
nicklas |
35 |
import="java.util.List" |
7294 |
17 Feb 17 |
nicklas |
36 |
import="java.util.ArrayList" |
7294 |
17 Feb 17 |
nicklas |
37 |
import="java.util.Arrays" |
7294 |
17 Feb 17 |
nicklas |
38 |
%> |
7294 |
17 Feb 17 |
nicklas |
39 |
<%@ taglib |
7294 |
17 Feb 17 |
nicklas |
40 |
prefix="base" uri="/WEB-INF/base.tld" |
7294 |
17 Feb 17 |
nicklas |
41 |
%> |
7294 |
17 Feb 17 |
nicklas |
42 |
<% |
7294 |
17 Feb 17 |
nicklas |
43 |
SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
7294 |
17 Feb 17 |
nicklas |
44 |
String ID = sc.getId(); |
7294 |
17 Feb 17 |
nicklas |
45 |
String root = request.getContextPath()+"/"; |
7294 |
17 Feb 17 |
nicklas |
46 |
|
7294 |
17 Feb 17 |
nicklas |
47 |
// Toggles the active status of the given role |
7294 |
17 Feb 17 |
nicklas |
48 |
int roleId = Values.getInt(request.getParameter("role_id"), 0); |
7294 |
17 Feb 17 |
nicklas |
49 |
String message = ""; |
7294 |
17 Feb 17 |
nicklas |
50 |
String title = ""; |
7294 |
17 Feb 17 |
nicklas |
51 |
|
7954 |
12 May 21 |
nicklas |
52 |
DbControl dc = sc.newDbControl(":Toggle role"); |
7294 |
17 Feb 17 |
nicklas |
53 |
try |
7294 |
17 Feb 17 |
nicklas |
54 |
{ |
7294 |
17 Feb 17 |
nicklas |
55 |
Role role = Role.getById(dc, roleId); |
7294 |
17 Feb 17 |
nicklas |
56 |
boolean isInactive = sc.isRoleInactive(roleId); |
7294 |
17 Feb 17 |
nicklas |
57 |
boolean changed = sc.setRoleInactive(roleId, !isInactive); |
7294 |
17 Feb 17 |
nicklas |
58 |
|
7294 |
17 Feb 17 |
nicklas |
59 |
// Force the menu to re-load |
7294 |
17 Feb 17 |
nicklas |
60 |
if (changed) |
7294 |
17 Feb 17 |
nicklas |
61 |
{ |
7294 |
17 Feb 17 |
nicklas |
62 |
sc.setSessionSetting("menu.standard.html", null); |
7294 |
17 Feb 17 |
nicklas |
63 |
title = "Role " + (isInactive ? "activated" : "de-activated"); |
7294 |
17 Feb 17 |
nicklas |
64 |
message = "The '" + HTML.encodeTags(role.getName()) + "' role is now "; |
7294 |
17 Feb 17 |
nicklas |
65 |
message += isInactive ? "active." : "inactive."; |
7294 |
17 Feb 17 |
nicklas |
66 |
} |
7294 |
17 Feb 17 |
nicklas |
67 |
else |
7294 |
17 Feb 17 |
nicklas |
68 |
{ |
7294 |
17 Feb 17 |
nicklas |
69 |
title = "No change"; |
7294 |
17 Feb 17 |
nicklas |
70 |
message = "The '" + HTML.encodeTags(role.getName()) + "' role is still "; |
7294 |
17 Feb 17 |
nicklas |
71 |
message += isInactive ? "de-activated." : "active."; |
7294 |
17 Feb 17 |
nicklas |
72 |
} |
7294 |
17 Feb 17 |
nicklas |
73 |
} |
7294 |
17 Feb 17 |
nicklas |
74 |
finally |
7294 |
17 Feb 17 |
nicklas |
75 |
{ |
7294 |
17 Feb 17 |
nicklas |
76 |
if (dc != null) dc.close(); |
7294 |
17 Feb 17 |
nicklas |
77 |
} |
7294 |
17 Feb 17 |
nicklas |
78 |
response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&title="+HTML.urlEncode(title)+"&message="+HTML.urlEncode(message)); |
7294 |
17 Feb 17 |
nicklas |
79 |
%> |