source: trunk/www/impersonate.jsp @ 5905

Last change on this file since 5905 was 5905, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • Use relative font sizes (em and %) instead of pixel values. This should make it possible to use relative values for everything and we don't have to split up into size_*.css


  • Removed "valign" attribute from lots of tables.


  • Removed "wrap" attribute from lots of texarea fields.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 4.7 KB
Line 
1<%-- $Id: impersonate.jsp 5905 2011-12-12 08:42:09Z 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<%
40final String login = Values.getString(request.getParameter("login"), "");
41final String error = Values.getString(request.getParameter("error"), null);
42final String root = request.getContextPath()+"/";
43
44final SessionControl sc = Base.getSessionControl(pageContext, true);
45final String ID = sc.getId();
46final DbControl dc = sc.newDbControl();
47ItemResultList<News> news = null;
48try
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    <form name="login" action="login.jsp" method="post" onsubmit="doLogin();">
98    <input type="hidden" name="cmd" value="Impersonate">
99    <input type="hidden" name="ID" value="<%=ID%>">
100    <input type="hidden" name="again" value="1">
101    <input type="hidden" name="redirect" value="">
102 
103    <h3 class="docked">Impersonate user <base:help helpid="impersonateuser" /></h3>
104    <div class="boxedbottom">
105      <%
106      if (error != null) 
107      {
108        %>
109        <div class="error"><%=error%></div>
110        <%
111      }
112      %>
113      <table class="form" border="0" cellspacing="1" cellpadding="2">
114      <tr>
115        <td class="prompt">User</td>
116        <td>
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       
127        </td>
128      </tr>
129      <tr>
130        <td class="prompt"><label for="remainOnPage">Remain on page</label></td>
131        <td>
132          <input type="checkbox" name="remainOnPage" id="remainOnPage" checked value="1">
133        </td>
134      </tr>
135      <tr >
136        <td class="prompt">Comment</td>
137        <td nowrap>
138          <textarea class="text" rows="4" cols="40" name="comment" 
139            ></textarea>
140          <a href="javascript:Main.zoom('Comment', 'login', 'comment')"
141            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
142        </td>
143      </tr>
144     
145      </table>
146    </div>
147   
148    <br>
149    <table align="center">
150    <tr>
151      <td width="50%"><base:button image="login.png" onclick="doLogin();" title="Impersonate" /></td>
152      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
153    </tr>
154    </table>
155    </form>
156   
157
158  </base:body>
159  </base:page>
160  <%
161}
162finally
163{
164  if (dc != null) dc.close();
165}
166%>
167
Note: See TracBrowser for help on using the repository browser.