1 | <%-- $Id: impersonate.jsp 5907 2011-12-13 08:36:28Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006, 2007 Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 3 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | ------------------------------------------------------------------ |
---|
21 | |
---|
22 | @author Nicklas |
---|
23 | @version 2.0 |
---|
24 | --%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.SessionControl" |
---|
27 | import="net.sf.basedb.core.DbControl" |
---|
28 | import="net.sf.basedb.core.News" |
---|
29 | import="net.sf.basedb.core.User" |
---|
30 | import="net.sf.basedb.core.ItemQuery" |
---|
31 | import="net.sf.basedb.core.ItemResultList" |
---|
32 | import="net.sf.basedb.core.query.Orders" |
---|
33 | import="net.sf.basedb.core.query.Hql" |
---|
34 | import="net.sf.basedb.clients.web.Base" |
---|
35 | import="net.sf.basedb.clients.web.util.HTML" |
---|
36 | import="net.sf.basedb.util.Values" |
---|
37 | %> |
---|
38 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
39 | <% |
---|
40 | final String login = Values.getString(request.getParameter("login"), ""); |
---|
41 | final String error = Values.getString(request.getParameter("error"), null); |
---|
42 | final String root = request.getContextPath()+"/"; |
---|
43 | |
---|
44 | final SessionControl sc = Base.getSessionControl(pageContext, true); |
---|
45 | final String ID = sc.getId(); |
---|
46 | final DbControl dc = sc.newDbControl(); |
---|
47 | ItemResultList<News> news = null; |
---|
48 | try |
---|
49 | { |
---|
50 | User currentUser = null; |
---|
51 | int userId = Values.getInt(request.getParameter("user_id")); |
---|
52 | if (userId != 0) currentUser = User.getById(dc, userId); |
---|
53 | %> |
---|
54 | <base:page type="popup" title="Impersonate user"> |
---|
55 | <base:head scripts="md5.js" styles="login.css"> |
---|
56 | <script language="JavaScript" type="text/javascript"> |
---|
57 | function doLogin() |
---|
58 | { |
---|
59 | var frm = document.forms['login']; |
---|
60 | if (frm.remainOnPage.checked) |
---|
61 | { |
---|
62 | frm.redirect.value = window.opener.location.href; |
---|
63 | } |
---|
64 | else |
---|
65 | { |
---|
66 | frm.redirect.value = '<%=root%>my_base/index.jsp?ID=<%=ID%>'; |
---|
67 | } |
---|
68 | frm.submit(); |
---|
69 | } |
---|
70 | function selectUserOnClick() |
---|
71 | { |
---|
72 | var frm = document.forms['login']; |
---|
73 | var url = 'admin/users/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectone&callback=setUserCallback'; |
---|
74 | if (frm.user_id.length > 0) |
---|
75 | { |
---|
76 | var id = Math.abs(parseInt(frm.user_id[0].value)); |
---|
77 | url += '&item_id='+id; |
---|
78 | } |
---|
79 | Main.openPopup(url, 'SelectUser', 1000, 700); |
---|
80 | } |
---|
81 | function setUserCallback(id, name) |
---|
82 | { |
---|
83 | var frm = document.forms['login']; |
---|
84 | var list = frm.user_id; |
---|
85 | if (list.length < 1 || list[0].value == '0') // > |
---|
86 | { |
---|
87 | Forms.addListOption(list, 0, new Option()); |
---|
88 | } |
---|
89 | list[0].value = id; |
---|
90 | list[0].text = name; |
---|
91 | list.selectedIndex = 0; |
---|
92 | } |
---|
93 | </script> |
---|
94 | </base:head> |
---|
95 | |
---|
96 | <base:body onload="init();"> |
---|
97 | <h1>Impersonate user <base:help helpid="impersonateuser" /></h1> |
---|
98 | <form name="login" action="login.jsp" method="post" onsubmit="doLogin();"> |
---|
99 | <input type="hidden" name="cmd" value="Impersonate"> |
---|
100 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
101 | <input type="hidden" name="again" value="1"> |
---|
102 | <input type="hidden" name="redirect" value=""> |
---|
103 | |
---|
104 | <div class="content"> |
---|
105 | <% |
---|
106 | if (error != null) |
---|
107 | { |
---|
108 | %> |
---|
109 | <div class="error"><%=error%></div> |
---|
110 | <% |
---|
111 | } |
---|
112 | %> |
---|
113 | <table class="fullform input100 bottomborder smaller"> |
---|
114 | <tr> |
---|
115 | <th>User</th> |
---|
116 | <td colspan="2"> |
---|
117 | <base:select |
---|
118 | id="user_id" |
---|
119 | clazz="selectionlist" |
---|
120 | required="true" |
---|
121 | current="<%=currentUser%>" |
---|
122 | recent="<%=null%>" |
---|
123 | newitem="true" |
---|
124 | onselect="selectUserOnClick()" |
---|
125 | /> |
---|
126 | </td> |
---|
127 | |
---|
128 | </tr> |
---|
129 | <tr> |
---|
130 | <th><label for="remainOnPage">Remain on page</label></th> |
---|
131 | <td> |
---|
132 | <input type="checkbox" name="remainOnPage" id="remainOnPage" checked value="1"> |
---|
133 | </td> |
---|
134 | <td></td> |
---|
135 | </tr> |
---|
136 | <tr class="dynamic"> |
---|
137 | <th>Comment</th> |
---|
138 | <td> |
---|
139 | <textarea class="text" rows="6" name="comment"></textarea> |
---|
140 | </td> |
---|
141 | <td> |
---|
142 | <a href="javascript:Main.zoom('Comment', 'login', 'comment')" |
---|
143 | title="Edit in larger window"><base:icon image="zoom.gif" /></a> |
---|
144 | </td> |
---|
145 | </tr> |
---|
146 | </table> |
---|
147 | </div> |
---|
148 | </form> |
---|
149 | |
---|
150 | <base:buttongroup subclass="dialogbuttons"> |
---|
151 | <base:button image="login.png" onclick="doLogin();" title="Impersonate" /> |
---|
152 | <base:button onclick="window.close()" title="Cancel" /> |
---|
153 | </base:buttongroup> |
---|
154 | |
---|
155 | </base:body> |
---|
156 | </base:page> |
---|
157 | <% |
---|
158 | } |
---|
159 | finally |
---|
160 | { |
---|
161 | if (dc != null) dc.close(); |
---|
162 | } |
---|
163 | %> |
---|
164 | |
---|