source: branches/2.2.2/www/my_base/user/submit_user.jsp @ 3138

Last change on this file since 3138 was 3138, checked in by Nicklas Nordborg, 16 years ago

Fixes #497: Floating point numbers with leading zeroes in the decimal part are not correctly displayed

Also added an option in the File/Preferences?... dialog to allow a user to specify the number
of decimals to display. This solves the 0.004 issue. Another (better) solution would be to make
it possible to specify a default number of decimals to display for each annotation type. But it
requires a lot more work and should be a tast of it's own.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1<%-- $Id: submit_user.jsp 3138 2007-02-20 07:34:13Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  This page will save user information and preferences.
25
26  @param cmd The command to execute
27    - SaveSettings: Save the settings from the settings.jsp page.
28    - SavePreferences: Save preferences from the preferences.jsp page.
29
30  @author Nicklas
31  @version 2.0
32--%>
33<%@ page session="false"
34  import="net.sf.basedb.core.SessionControl"
35  import="net.sf.basedb.core.DbControl"
36  import="net.sf.basedb.core.Item"
37  import="net.sf.basedb.core.User"
38  import="net.sf.basedb.core.ItemContext"
39  import="net.sf.basedb.clients.web.Base"
40  import="net.sf.basedb.clients.web.WebException"
41  import="net.sf.basedb.clients.web.util.HTML"
42  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
43  import="net.sf.basedb.util.Values"
44  import="java.util.Arrays"
45%>
46<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
47<%
48SessionControl sc = Base.getExistingSessionControl(pageContext, true);
49String ID = sc.getId();
50String cmd = request.getParameter("cmd");
51String message = "";
52String root = request.getContextPath()+"/";
53
54DbControl dc = sc.newDbControl();
55try
56{
57  if ("SaveSettings".equals(cmd))
58  {
59    String email = Values.getStringOrNull(request.getParameter("email"));
60    if (email != null && !HTML.isValidEmail(email))
61    {
62      throw new WebException("popup", "Invalid email address",
63        "The email address {1} is not a valid email address.",
64        HTML.encodeTags(email)
65      );
66    }
67    User user = (User)sc.getSessionSetting("user");
68    dc.reattachItem(user);
69
70    // Contact information tab
71    user.setEmail(email);
72    user.setOrganisation(Values.getStringOrNull(request.getParameter("organisation")));
73    user.setAddress(Values.getStringOrNull(request.getParameter("address")));
74    user.setPhone(Values.getStringOrNull(request.getParameter("phone")));
75    user.setFax(Values.getStringOrNull(request.getParameter("fax")));
76    user.setUrl(Values.getStringOrNull(request.getParameter("url")));
77
78    // Password tab
79    String password = Values.getStringOrNull(request.getParameter("password"));
80    if (password != null) user.setPassword(password);
81
82    // Other settings tab
83    user.setDescription(Values.getStringOrNull(request.getParameter("description")));
84
85    dc.commit();
86    sc.setSessionSetting("user", null);
87    message = "Information saved";
88  }
89  else if ("SavePreferences".equals(cmd))
90  {
91    int newScale = Values.getInt(request.getParameter("scale"), 100);
92    sc.setUserClientSetting("appearance.scale", Integer.toString(newScale));
93    sc.setUserClientSetting("appearance.fontsize", Values.getString(request.getParameter("fontsize"), "size_m.css"));
94    sc.setSessionSetting("appearance.scale", new Float(newScale / 100.0));
95    int newMaxRecent = Values.getInt(request.getParameter("recent"), 4);
96    sc.setUserClientSetting("appearance.recent", Integer.toString(newMaxRecent));
97    sc.setSessionSetting("appearance.recent", newMaxRecent);
98    ItemContext cc = sc.getCurrentContext(Item.USERCLIENTSETTING);
99    int maxRecent = Base.getMaxRecent(sc);
100 
101    String toolbar = request.getParameter("toolbar");
102    boolean hasImages = true;
103    boolean hasText = true;
104    if ("text".equals(toolbar))
105    {
106      hasImages = false;
107    }
108    else if ("images".equals(toolbar))
109    {
110      hasText = false;
111    }
112    sc.setUserClientSetting("toolbar.images", hasImages ? "1" : "0");
113    sc.setUserClientSetting("toolbar.text", hasText ? "1" : "0");
114    String minColor = Values.getString(request.getParameter("mincolor"), "0000FF");
115    String midColor = Values.getString(request.getParameter("midcolor"), "FFFFFF");
116    String maxColor = Values.getString(request.getParameter("maxcolor"), "FFFF00");
117    sc.setUserClientSetting("ratiocolor.min", minColor);
118    sc.setUserClientSetting("ratiocolor.mid", midColor);
119    sc.setUserClientSetting("ratiocolor.max", maxColor);
120    cc.setRecent("colors", minColor + "," + midColor + "," + maxColor, maxRecent);
121   
122    String dateFormat = request.getParameter("date_format");
123    String dateTimeFormat = request.getParameter("datetime_format");
124    FormatterSettings.setDateFormat(sc, dateFormat);
125    FormatterSettings.setDateTimeFormat(sc, dateTimeFormat);
126    cc.setRecent("dateFormats", dateFormat, maxRecent);
127    cc.setRecent("dateTimeFormats", dateTimeFormat, maxRecent);
128
129    int numDecimals = Values.getInt(request.getParameter("decimals"), 2);
130    FormatterSettings.setNumDecimals(sc, numDecimals);
131   
132    sc.setUserClientSetting("plugins.sendmessage", Values.getString(request.getParameter("sendmessage"), "0"));
133    String[] mostRecent = request.getParameterValues("enabled");
134    sc.setUserClientSetting("menu.mostRecent", 
135      mostRecent == null ? "" : Values.getString(Arrays.asList(mostRecent), ":", true));
136    sc.setUserClientSetting("menu.mostRecent.loadNames", Values.getString(request.getParameter("loadNames"), "0"));
137   
138    message = "Preferences saved";
139  }
140  else if ("ReloadPermissions".equals(cmd))
141  {
142    sc.reloadPermissions();
143    sc.reloadSettings(true, false);
144    sc.setSessionSetting("menu.standard.html", null);
145    message = "Permissions reloaded";
146  }
147}
148finally
149{
150  if (dc != null) dc.close();
151}
152response.sendRedirect(root + "common/close_popup.jsp?ID="+ID+"&refresh_opener=1&&message="+HTML.urlEncode(message));
153%>
154
Note: See TracBrowser for help on using the repository browser.