[Ils-source] r1365 - trunk/webapp
scribe at crosswire.org
scribe at crosswire.org
Thu Dec 17 12:16:52 MST 2015
Author: scribe
Date: 2015-12-17 12:16:52 -0700 (Thu, 17 Dec 2015)
New Revision: 1365
Modified:
trunk/webapp/selfregistration.jsp
Log:
Committed Adam's patch to fix selfregistration bug introduced during addition of internationalization
Converted to normalized linebreaks
Modified: trunk/webapp/selfregistration.jsp
===================================================================
--- trunk/webapp/selfregistration.jsp 2015-12-17 18:45:30 UTC (rev 1364)
+++ trunk/webapp/selfregistration.jsp 2015-12-17 19:16:52 UTC (rev 1365)
@@ -1,392 +1,393 @@
-<%@ page
- language="java"
- contentType="text/html;charset=utf-8"
-%>
-<%@ page import="org.crosswire.utils.HTTPUtils" %>
-<%@ page import="org.crosswire.utils.GeoData" %>
-<%@ page import="com.resolutions.ils.*" %>
-<%@ page import="com.resolutions.ils.data.*" %>
-<%@ page import="java.util.Vector" %>
-<%@ page import="java.util.Date" %>
-<%@ page import="java.io.File" %>
-<%@ page import="java.io.BufferedReader" %>
-<%@ page import="java.io.StringReader" %>
-<%@ page import="java.net.URL" %>
-<%@ page import="java.util.Properties" %>
-<%@ page import="java.text.SimpleDateFormat" %>
-<%@ page import="org.apache.log4j.Logger" %>
-
-<%
- Logger logger = Logger.getLogger(this.getClass());
- Logger eventsLogger = Logger.getLogger("EVENTS");
- String statusMsg = "";
- String validError = "";
- boolean noSave = false;
-
- SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
- String action = request.getParameter("action");
- if ("clear".equals(action)) session.removeAttribute("ilsSession");
- ILSSession ilsSession = (ILSSession)session.getAttribute("ilsSession");
- if (ilsSession != null && ilsSession.getCurrentUserProfile().getUserProfileAccessLevel() > UserProfile.ACCESS_ANONYMOUS) {
- out.print("<html><body>You cannot self-register for an account when you are already logged in.</body></html>");
- return;
- }
- else {
- if (!"on".equals(com.resolutions.ils.Utils.getSysConfig(session).getProperty("SREnable", null))) {
- out.print("<html><head><META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=login.jsp\"></head></html>");
- return;
- }
-
- // This is for Self Registration
-
- //-- Company logic from login.jsp -------
- // TODO: consolidate this somewhere
- String requestURL = request.getRequestURL().toString() + "?" + request.getQueryString();
- String co = com.resolutions.ils.Utils.getCompanyFromConfig(session, requestURL);
- if (co == null) co = com.resolutions.ils.Utils.getSysConfig(session).getProperty("Company", null);
- if (co == null) co = request.getParameter("co");
- if (co != null) session.setAttribute("co", co);
- co = (String) session.getAttribute("co");
- Company company = Company.getCompany((co != null) ? Integer.parseInt(co):1);
-
- ilsSession = ILSSession.getAnonymous(company.getCompanyID());
- }
-
- UserProfile user = ilsSession.getCurrentUserProfile();
-
- UserProfile current = user;
- int profileID = current.getUserProfileID();
-
- String passwd = request.getParameter("passwd");
- String passwd2 = request.getParameter("passwd2");
- if (passwd == null || passwd.length() == 0) passwd = "";
- if (passwd2 == null || passwd2.length() == 0) passwd2 = "";
-
- Vector tmp = Group.getUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
- int currentRoleID = ((tmp != null) && (tmp.size()>0)) ? ((Group)tmp.get(0)).getGroupID() : -1;
- String currentLocation = request.getParameter("location");
- if (currentLocation == null) currentLocation = "";
- else currentLocation = currentLocation.trim().toUpperCase();
-
- if ((profileID == -1) || ("New".equals(action))) {
- current = new UserProfile();
- current.defaultAll();
- currentRoleID = -1;
- profileID = -1;
- }
- current.setUserProfileStatusID(UserProfile.STATUS_ACTIVE);
-
- String val = request.getParameter("role");
- int requestedRole = (val != null) ? (Integer.parseInt(val)) : -1;
-
- if ("Save".equals(action)) {
- UserProfile orig = (UserProfile)current.clone();
- val = request.getParameter("num");
- if (val != null) {
- UserProfile up = UserProfile.getUserProfile(ilsSession, val);
- if ((up != null) && (up.getUserProfileID() != current.getUserProfileID())) {
- validError = "The Employee ID already exists. Please enter a unique ID.";
- }
- else {
- current.setUserProfileNum(val);
- }
- }
- if (passwd.length() > 0) {
- if (passwd.equals(passwd2)) {
- current.setUserProfilePasswd(passwd);
- }
- else validError = "Passwords do not match.";
- }
- else validError = "You must enter a password.";
-
- val = request.getParameter("firstName");
- if (val != null) current.setUserProfileFirstName(val);
- val = request.getParameter("lastName");
- if (val != null) current.setUserProfileLastName(val);
- val = request.getParameter("addr1");
- if (val != null) current.setUserProfileAddr1(val);
- val = request.getParameter("addr2");
- if (val != null) current.setUserProfileAddr2(val);
- val = request.getParameter("city");
- if (val != null) current.setUserProfileCity(val);
- val = request.getParameter("state");
- if (val != null) current.setUserProfileState(val);
- val = request.getParameter("zip");
- if (val != null) current.setUserProfileZip(val);
- val = request.getParameter("country");
- if (val != null) current.setUserProfileCountry(val);
- val = request.getParameter("eMail");
- if (val != null) current.setUserProfileEMail(val);
- val = request.getParameter("phone");
- if (val != null) current.setUserProfilePhone(val);
- val = request.getParameter("hdate");
- if ((val != null) && (!val.startsWith("m"))) {
- Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
- if (v != null) {
- current.setUserProfileHireDate(v);
- }
- else {
- validError = "Invalid Hire Date, please enter a reasonable date using the format MM/DD/YYYY";
- }
- }
- val = request.getParameter("tdate");
- if ((val != null) && (!val.startsWith("m"))) {
- Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
- if (v != null) {
- current.setUserProfileTermDate(v);
- }
- else {
- validError = "Invalid Termination Date, please enter a reasonable date using the format MM/DD/YYYY";
- }
- }
- if ((current.getUserProfilePasswd() == null) || (current.getUserProfilePasswd().trim().length() < 1)) {
- current.setUserProfilePasswd("changeme");
- }
-
- if (validError.length() > 0) {
- // we already have an error
- }
- else if ((current.getUserProfileFirstName() == null) || (current.getUserProfileFirstName().length() < 1)) {
- validError = "You must supply a First Name";
- }
- else if ((current.getUserProfileLastName() == null) || (current.getUserProfileLastName().length() < 1)) {
- validError = "You must supply a Last Name";
- }
- else if ((current.getUserProfileNum() == null) || (current.getUserProfileNum().length() < 1)) {
- validError = "You must supply an Employee ID";
- }
- else if (currentRoleID < 0 && requestedRole < 0) {
- validError = "You must choose a <t:t>Role</t:t>";
- }
- else if (currentLocation.length() < 1) {
- validError = "You must enter a <t:t>Workgroup</t:t>";
- }
- else {
- int len = -1; try { len = Integer.parseInt(com.resolutions.ils.Utils.getSysConfig(session).getProperty("SRLengthVal", "-1")); } catch (Exception e) {}
- if (len > 0 && currentLocation.length() != len) {
- validError = "Invalid <t:t>Workgroup</t:t>";
- }
- else {
- String validationStrings = com.resolutions.ils.Utils.getSysConfig(session).getProperty("SRWGVal", null);
- if (validationStrings != null && validationStrings.length() > 0) {
- BufferedReader reader = new BufferedReader(new StringReader(validationStrings));
- try {
- String str;
- int count = 0;
- boolean validation = false;
- while ((str = reader.readLine()) != null) {
- count++;
- if (str.trim().length() > 0) {
- if (currentLocation.indexOf(str.trim().toUpperCase()) > -1) {
- validation = true;
- break;
- }
- }
- }
- if (count > 0 && !validation) {
- validError = "Invalid <t:t>Workgroup</t:t>";
- }
- } catch(Exception e) {}
- }
- }
- }
- if (validError.length() < 1) {
- if (orig.getUserProfileID() > 0) {
- boolean emailNotice = "on".equals(Utils.getSysConfig(session).getProperty("EmailEnableChangePassword", "off"));
- HttpSession sendEmail = (emailNotice) ? session : null;
- current.save(ilsSession, orig, sendEmail);
- }
- else {
- current.setUserProfileAccessLevel(UserProfile.ACCESS_EMPLOYEE);
- current.setUserProfileHireDate(new Date());
- String roleNameForEmail = ""; try { roleNameForEmail = Group.getGroup(ilsSession, requestedRole).getGroupName(); } catch (Exception e) {}
- current = current.saveNew(ilsSession, session, currentLocation, roleNameForEmail);
- profileID = current.getUserProfileID();
- }
- if ((requestedRole != currentRoleID) && (requestedRole > -1)) {
- Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
- Group.addUserGroup(ilsSession, requestedRole, current.getUserProfileID());
- // modifying an existing user
- if (orig.getUserProfileID() > 0) {
- eventsLogger.info("User " + current.getUserProfileNum() + " ROLE changed from " + currentRoleID + " to " + requestedRole + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
- }
- }
- int requestedLocation = -1;
- if (currentLocation != null && currentLocation.trim().length() > 0) {
- for (int i = 0; i < 2; ++i) {
- Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_LOCATION, currentLocation);
- if (g != null) {
- requestedLocation = g.getGroupID();
- break;
- }
- else {
- if (i < 1) {
- Group grp = new Group();
- grp.defaultAll();
- grp.setGroupTypeID(Group.GROUPTYPE_LOCATION);
- grp.setGroupName(currentLocation);
- grp.setGroupDesc(currentLocation);
- grp.saveNew(ilsSession);
- }
- else {
-%>
-<t:t>Workgroup</t:t> could not be created.
-<%
- return;
- }
- }
- }
- }
- if (requestedLocation > -1) {
- Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
- Group.addUserGroup(ilsSession, requestedLocation, current.getUserProfileID());
- if (orig.getUserProfileID() > 0) {
- eventsLogger.info("User " + current.getUserProfileNum() + " add to WORKGROUP " + requestedLocation + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
- }
- }
- current = ilsSession.getCurrentUserProfile();
- if (profileID != current.getUserProfileID()) {
- current = UserProfile.getUserProfile(ilsSession, profileID);
- }
- tmp = Group.getUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
- currentRoleID = ((tmp != null) && (tmp.size()>0)) ? ((Group)tmp.get(0)).getGroupID() : -1;
- tmp = Group.getUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
- statusMsg = "Your account has been created. You may now login.";
- noSave = true;
- }
- }
-
- boolean alternativeLoginValidationEnable = "on".equals(Utils.getSysConfig(session).getProperty("AlternativeLoginValidationEnable", "off"));
-
-
- Vector roles = Group.getAllGroups(ilsSession, Group.GROUPTYPE_ROLE);
- String returnPage = "login.jsp";
-%>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
- <title><%= ilsSession.getCurrentCompany().getCompanyName() %> eLearning Portal</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <meta http-equiv="Pragma" content="no-cache">
- <meta http-equiv="Expires" content="-1">
- <link href="lms_style.css" rel="stylesheet" type="text/css">
- <script type="text/javascript" src="crosswire.js"></script>
-</head>
-
-<body onLoad="init()">
-<%@ include file="header.jsp" %>
- <div id="pageContainer">
-<%@ include file="menu.jsp" %>
- <div id="content">
- <div id="pageTitles">
- <br/>
- <span class="instructiontxt"><%= statusMsg %></span>
- <span class="instructiontxt"><%= validError %></span>
- </div>
- <table id="tableForm">
- <tr>
- <th>
- Request an Account
- </th>
- </tr>
- <tr>
- <td> </td>
- </tr>
- <tr>
- <td>
- <form name="profsave" method="post" action="selfregistration.jsp">
- <input type="hidden" name="action" value="Save"/>
- <input type="hidden" name="profileid" value="<%= profileID %>"/>
- <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" id="tableFormData">
-
- <tr>
- <td class="formHeadings"><div align="right">First Name: </div></td>
- <td colspan="2"><input name="firstName" type="text" value="<%=current.getUserProfileFirstName()%>" size="35" /> </td>
- </tr>
- <tr>
- <td class="formHeadings">Last Name:</td>
- <td colspan="2"><input name="lastName" type="text" value="<%=current.getUserProfileLastName()%>" size="35" /> </td>
- </tr>
- <tr>
- <td width="140" class="formHeadings">User Name:</td>
- <td><input name="num" type="text" value="<%=current.getUserProfileNum()%>" size="35" /></td>
- </tr>
- <tr>
- <td height="23" class="formHeadings">Email: </td>
- <td colspan="2"><input name="eMail" type="text" value="<%=current.getUserProfileEMail()%>" size="35" /> </td>
- </tr>
- <tr>
- <td valign="middle" class="formHeadings"><t:t>Workgroup</t:t>:</td>
- <td colspan="2"><input name="location" type="text" value="<%=currentLocation%>" size="35" autocomplete="off" /> </td>
- </tr>
- <tr>
- <td valign="middle" class="formHeadings"><t:t>Role</t:t>: </td>
- <td width="228"><select name="role" style="width:215px;">
- <option value="-1">Select <t:t>Role</t:t></option>
- <%
- if (currentRoleID == -1) currentRoleID = requestedRole;
- for (int i = 0; i < roles.size(); i++) {
- Group role = (Group)roles.get(i);
- %>
- <option value="<%=role.getGroupID()%>" <%=(role.getGroupID() == currentRoleID)?"selected=\"selected\"":""%>><%=HTTPUtils.canonize(role.getGroupName())%></option>
- <%
- }
- %>
- </select> </td>
- <td width="320"> </td>
- </tr>
- <tr>
- <td class="formHeadings">State:</td>
- <td colspan="2">
- <select name="state">
- <option></option>
-<%
- for (String[] s : GeoData.getStates()) {
-%>
- <option value="<%=s[0]%>" <%=(s[0].equals(current.getUserProfileState())?"selected=\"selected\"":"")%>><%=s[1] %></option>
-
-<%
- }
-%>
- </select>
- </td>
- </tr>
- <tr>
- <td class="formHeadings">Password:</td>
- <td><input name="passwd" type="password" value="<%=passwd%>" size="35" <%=(!alternativeLoginValidationEnable)?"":"disabled=\"true\""%> /> </td>
- </tr>
- <tr>
- <td class="formHeadings">Confirm Password:</td>
- <td><input name="passwd2" type="password" value="<%=passwd2%>" size="35" <%=(!alternativeLoginValidationEnable)?"":"disabled=\"true\""%> /> </td>
- </tr>
-
- <tr>
- <td> </td>
- <td colspan="2">
- <%
- if (!noSave) {
- %>
- <a href="#" onClick="document.profsave.submit()"><img border="0" src="images/createaccount.png" width="106" height="23" hspace="3" alt=""/></a>
- <a href="<%=returnPage%>"><img border="0" src="images/cancel_btn.gif" width="72" height="24" alt=""></a>
- <%
- }
- else {
- %>
- <a href="<%=returnPage%>"><img border="0" src="images/loginnow.png" width="106" height="23" hspace="3" alt=""/></a>
- <%
- }
- %>
- </td>
- </tr>
- </table>
- <input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
- </form>
- </td>
- </tr>
- </table>
-
- </div>
-<%@ include file="footer.jsp" %>
- </div>
-</body>
-</html>
+<%@ page
+ language="java"
+ contentType="text/html;charset=utf-8"
+%>
+<%@ page import="org.crosswire.utils.HTTPUtils" %>
+<%@ page import="org.crosswire.utils.GeoData" %>
+<%@ page import="com.resolutions.ils.*" %>
+<%@ page import="com.resolutions.ils.data.*" %>
+<%@ page import="java.util.Vector" %>
+<%@ page import="java.util.Date" %>
+<%@ page import="java.io.File" %>
+<%@ page import="java.io.BufferedReader" %>
+<%@ page import="java.io.StringReader" %>
+<%@ page import="java.net.URL" %>
+<%@ page import="java.util.Properties" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="org.apache.log4j.Logger" %>
+
+<%
+ Logger logger = Logger.getLogger(this.getClass());
+ Logger eventsLogger = Logger.getLogger("EVENTS");
+ String statusMsg = "";
+ String validError = "";
+ boolean noSave = false;
+
+ SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
+ String action = request.getParameter("action");
+ if ("clear".equals(action)) session.removeAttribute("ilsSession");
+ ILSSession ilsSession = (ILSSession)session.getAttribute("ilsSession");
+ if (ilsSession != null && ilsSession.getCurrentUserProfile().getUserProfileAccessLevel() > UserProfile.ACCESS_ANONYMOUS) {
+ out.print("<html><body>You cannot self-register for an account when you are already logged in.</body></html>");
+ return;
+ }
+ else {
+ if (!"on".equals(com.resolutions.ils.Utils.getSysConfig(session).getProperty("SREnable", null))) {
+ out.print("<html><head><META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=login.jsp\"></head></html>");
+ return;
+ }
+
+ // This is for Self Registration
+
+ //-- Company logic from login.jsp -------
+ // TODO: consolidate this somewhere
+ String requestURL = request.getRequestURL().toString() + "?" + request.getQueryString();
+ String co = com.resolutions.ils.Utils.getCompanyFromConfig(session, requestURL);
+ if (co == null) co = com.resolutions.ils.Utils.getSysConfig(session).getProperty("Company", null);
+ if (co == null) co = request.getParameter("co");
+ if (co != null) session.setAttribute("co", co);
+ co = (String) session.getAttribute("co");
+ Company company = Company.getCompany((co != null) ? Integer.parseInt(co):1);
+
+ ilsSession = ILSSession.getAnonymous(company.getCompanyID());
+ }
+
+ UserProfile user = ilsSession.getCurrentUserProfile();
+
+ UserProfile current = user;
+ int profileID = current.getUserProfileID();
+
+ String passwd = request.getParameter("passwd");
+ String passwd2 = request.getParameter("passwd2");
+ if (passwd == null || passwd.length() == 0) passwd = "";
+ if (passwd2 == null || passwd2.length() == 0) passwd2 = "";
+
+ Vector tmp = Group.getUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
+ int currentRoleID = ((tmp != null) && (tmp.size()>0)) ? ((Group)tmp.get(0)).getGroupID() : -1;
+ String currentLocation = request.getParameter("location");
+ if (currentLocation == null) currentLocation = "";
+ else currentLocation = currentLocation.trim().toUpperCase();
+
+ if ((profileID == -1) || ("New".equals(action))) {
+ current = new UserProfile();
+ current.defaultAll();
+ currentRoleID = -1;
+ profileID = -1;
+ }
+ current.setUserProfileStatusID(UserProfile.STATUS_ACTIVE);
+
+ String val = request.getParameter("role");
+ int requestedRole = (val != null) ? (Integer.parseInt(val)) : -1;
+%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title><%= ilsSession.getCurrentCompany().getCompanyName() %> eLearning Portal</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta http-equiv="Pragma" content="no-cache">
+ <meta http-equiv="Expires" content="-1">
+ <link href="lms_style.css" rel="stylesheet" type="text/css">
+ <script type="text/javascript" src="crosswire.js"></script>
+</head>
+
+<body onLoad="init()">
+<%@ include file="header.jsp" %>
+<%
+ if ("Save".equals(action)) {
+ UserProfile orig = (UserProfile)current.clone();
+ val = request.getParameter("num");
+ if (val != null) {
+ UserProfile up = UserProfile.getUserProfile(ilsSession, val);
+ if ((up != null) && (up.getUserProfileID() != current.getUserProfileID())) {
+ validError = "The Employee ID already exists. Please enter a unique ID.";
+ }
+ else {
+ current.setUserProfileNum(val);
+ }
+ }
+ if (passwd.length() > 0) {
+ if (passwd.equals(passwd2)) {
+ current.setUserProfilePasswd(passwd);
+ }
+ else validError = "Passwords do not match.";
+ }
+ else validError = "You must enter a password.";
+
+ val = request.getParameter("firstName");
+ if (val != null) current.setUserProfileFirstName(val);
+ val = request.getParameter("lastName");
+ if (val != null) current.setUserProfileLastName(val);
+ val = request.getParameter("addr1");
+ if (val != null) current.setUserProfileAddr1(val);
+ val = request.getParameter("addr2");
+ if (val != null) current.setUserProfileAddr2(val);
+ val = request.getParameter("city");
+ if (val != null) current.setUserProfileCity(val);
+ val = request.getParameter("state");
+ if (val != null) current.setUserProfileState(val);
+ val = request.getParameter("zip");
+ if (val != null) current.setUserProfileZip(val);
+ val = request.getParameter("country");
+ if (val != null) current.setUserProfileCountry(val);
+ val = request.getParameter("eMail");
+ if (val != null) current.setUserProfileEMail(val);
+ val = request.getParameter("phone");
+ if (val != null) current.setUserProfilePhone(val);
+ val = request.getParameter("hdate");
+ if ((val != null) && (!val.startsWith("m"))) {
+ Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
+ if (v != null) {
+ current.setUserProfileHireDate(v);
+ }
+ else {
+ validError = "Invalid Hire Date, please enter a reasonable date using the format MM/DD/YYYY";
+ }
+ }
+ val = request.getParameter("tdate");
+ if ((val != null) && (!val.startsWith("m"))) {
+ Date v = Utils.parseDate(val, 150 * 365, 10 * 365);
+ if (v != null) {
+ current.setUserProfileTermDate(v);
+ }
+ else {
+ validError = "Invalid Termination Date, please enter a reasonable date using the format MM/DD/YYYY";
+ }
+ }
+ if ((current.getUserProfilePasswd() == null) || (current.getUserProfilePasswd().trim().length() < 1)) {
+ current.setUserProfilePasswd("changeme");
+ }
+
+ if (validError.length() > 0) {
+ // we already have an error
+ }
+ else if ((current.getUserProfileFirstName() == null) || (current.getUserProfileFirstName().length() < 1)) {
+ validError = "You must supply a First Name";
+ }
+ else if ((current.getUserProfileLastName() == null) || (current.getUserProfileLastName().length() < 1)) {
+ validError = "You must supply a Last Name";
+ }
+ else if ((current.getUserProfileNum() == null) || (current.getUserProfileNum().length() < 1)) {
+ validError = "You must supply an Employee ID";
+ }
+ else if (currentRoleID < 0 && requestedRole < 0) {
+ validError = "You must choose a <t:t>Role</t:t>";
+ }
+ else if (currentLocation.length() < 1) {
+ validError = "You must enter a <t:t>Workgroup</t:t>";
+ }
+ else {
+ int len = -1; try { len = Integer.parseInt(com.resolutions.ils.Utils.getSysConfig(session).getProperty("SRLengthVal", "-1")); } catch (Exception e) {}
+ if (len > 0 && currentLocation.length() != len) {
+ validError = "Invalid <t:t>Workgroup</t:t>";
+ }
+ else {
+ String validationStrings = com.resolutions.ils.Utils.getSysConfig(session).getProperty("SRWGVal", null);
+ if (validationStrings != null && validationStrings.length() > 0) {
+ BufferedReader reader = new BufferedReader(new StringReader(validationStrings));
+ try {
+ String str;
+ int count = 0;
+ boolean validation = false;
+ while ((str = reader.readLine()) != null) {
+ count++;
+ if (str.trim().length() > 0) {
+ if (currentLocation.indexOf(str.trim().toUpperCase()) > -1) {
+ validation = true;
+ break;
+ }
+ }
+ }
+ if (count > 0 && !validation) {
+ validError = "Invalid <t:t>Workgroup</t:t>";
+ }
+ } catch(Exception e) {}
+ }
+ }
+ }
+ if (validError.length() < 1) {
+ if (orig.getUserProfileID() > 0) {
+ boolean emailNotice = "on".equals(Utils.getSysConfig(session).getProperty("EmailEnableChangePassword", "off"));
+ HttpSession sendEmail = (emailNotice) ? session : null;
+ current.save(ilsSession, orig, sendEmail);
+ }
+ else {
+ current.setUserProfileAccessLevel(UserProfile.ACCESS_EMPLOYEE);
+ current.setUserProfileHireDate(new Date());
+ String roleNameForEmail = ""; try { roleNameForEmail = Group.getGroup(ilsSession, requestedRole).getGroupName(); } catch (Exception e) {}
+ current = current.saveNew(ilsSession, session, currentLocation, roleNameForEmail);
+ profileID = current.getUserProfileID();
+ }
+ if ((requestedRole != currentRoleID) && (requestedRole > -1)) {
+ Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
+ Group.addUserGroup(ilsSession, requestedRole, current.getUserProfileID());
+ // modifying an existing user
+ if (orig.getUserProfileID() > 0) {
+ eventsLogger.info("User " + current.getUserProfileNum() + " ROLE changed from " + currentRoleID + " to " + requestedRole + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
+ }
+ }
+ int requestedLocation = -1;
+ if (currentLocation != null && currentLocation.trim().length() > 0) {
+ for (int i = 0; i < 2; ++i) {
+ Group g = Group.getGroupByName(ilsSession, Group.GROUPTYPE_LOCATION, currentLocation);
+ if (g != null) {
+ requestedLocation = g.getGroupID();
+ break;
+ }
+ else {
+ if (i < 1) {
+ Group grp = new Group();
+ grp.defaultAll();
+ grp.setGroupTypeID(Group.GROUPTYPE_LOCATION);
+ grp.setGroupName(currentLocation);
+ grp.setGroupDesc(currentLocation);
+ grp.saveNew(ilsSession);
+ }
+ else {
+%>
+<t:t>Workgroup</t:t> could not be created.
+<%
+ return;
+ }
+ }
+ }
+ }
+ if (requestedLocation > -1) {
+ Group.deleteUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
+ Group.addUserGroup(ilsSession, requestedLocation, current.getUserProfileID());
+ if (orig.getUserProfileID() > 0) {
+ eventsLogger.info("User " + current.getUserProfileNum() + " add to WORKGROUP " + requestedLocation + " by user: " + ilsSession.getCurrentUserProfile().getUserProfileNum());
+ }
+ }
+ current = ilsSession.getCurrentUserProfile();
+ if (profileID != current.getUserProfileID()) {
+ current = UserProfile.getUserProfile(ilsSession, profileID);
+ }
+ tmp = Group.getUserGroups(ilsSession, Group.GROUPTYPE_ROLE, current.getUserProfileID());
+ currentRoleID = ((tmp != null) && (tmp.size()>0)) ? ((Group)tmp.get(0)).getGroupID() : -1;
+ tmp = Group.getUserGroups(ilsSession, Group.GROUPTYPE_LOCATION, current.getUserProfileID());
+ statusMsg = "Your account has been created. You may now login.";
+ noSave = true;
+ }
+ }
+
+ boolean alternativeLoginValidationEnable = "on".equals(Utils.getSysConfig(session).getProperty("AlternativeLoginValidationEnable", "off"));
+
+
+ Vector roles = Group.getAllGroups(ilsSession, Group.GROUPTYPE_ROLE);
+ String returnPage = "login.jsp";
+%>
+ <div id="pageContainer">
+<%@ include file="menu.jsp" %>
+ <div id="content">
+ <div id="pageTitles">
+ <br/>
+ <span class="instructiontxt"><%= statusMsg %></span>
+ <span class="instructiontxt"><%= validError %></span>
+ </div>
+ <table id="tableForm">
+ <tr>
+ <th>
+ Request an Account
+ </th>
+ </tr>
+ <tr>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>
+ <form name="profsave" method="post" action="selfregistration.jsp">
+ <input type="hidden" name="action" value="Save"/>
+ <input type="hidden" name="profileid" value="<%= profileID %>"/>
+ <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" id="tableFormData">
+
+ <tr>
+ <td class="formHeadings"><div align="right">First Name: </div></td>
+ <td colspan="2"><input name="firstName" type="text" value="<%=current.getUserProfileFirstName()%>" size="35" /> </td>
+ </tr>
+ <tr>
+ <td class="formHeadings">Last Name:</td>
+ <td colspan="2"><input name="lastName" type="text" value="<%=current.getUserProfileLastName()%>" size="35" /> </td>
+ </tr>
+ <tr>
+ <td width="140" class="formHeadings">User Name:</td>
+ <td><input name="num" type="text" value="<%=current.getUserProfileNum()%>" size="35" /></td>
+ </tr>
+ <tr>
+ <td height="23" class="formHeadings">Email: </td>
+ <td colspan="2"><input name="eMail" type="text" value="<%=current.getUserProfileEMail()%>" size="35" /> </td>
+ </tr>
+ <tr>
+ <td valign="middle" class="formHeadings"><t:t>Workgroup</t:t>:</td>
+ <td colspan="2"><input name="location" type="text" value="<%=currentLocation%>" size="35" autocomplete="off" /> </td>
+ </tr>
+ <tr>
+ <td valign="middle" class="formHeadings"><t:t>Role</t:t>: </td>
+ <td width="228"><select name="role" style="width:215px;">
+ <option value="-1">Select <t:t>Role</t:t></option>
+ <%
+ if (currentRoleID == -1) currentRoleID = requestedRole;
+ for (int i = 0; i < roles.size(); i++) {
+ Group role = (Group)roles.get(i);
+ %>
+ <option value="<%=role.getGroupID()%>" <%=(role.getGroupID() == currentRoleID)?"selected=\"selected\"":""%>><%=HTTPUtils.canonize(role.getGroupName())%></option>
+ <%
+ }
+ %>
+ </select> </td>
+ <td width="320"> </td>
+ </tr>
+ <tr>
+ <td class="formHeadings">State:</td>
+ <td colspan="2">
+ <select name="state">
+ <option></option>
+<%
+ for (String[] s : GeoData.getStates()) {
+%>
+ <option value="<%=s[0]%>" <%=(s[0].equals(current.getUserProfileState())?"selected=\"selected\"":"")%>><%=s[1] %></option>
+
+<%
+ }
+%>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td class="formHeadings">Password:</td>
+ <td><input name="passwd" type="password" value="<%=passwd%>" size="35" <%=(!alternativeLoginValidationEnable)?"":"disabled=\"true\""%> /> </td>
+ </tr>
+ <tr>
+ <td class="formHeadings">Confirm Password:</td>
+ <td><input name="passwd2" type="password" value="<%=passwd2%>" size="35" <%=(!alternativeLoginValidationEnable)?"":"disabled=\"true\""%> /> </td>
+ </tr>
+
+ <tr>
+ <td> </td>
+ <td colspan="2">
+ <%
+ if (!noSave) {
+ %>
+ <a href="#" onClick="document.profsave.submit()"><img border="0" src="images/createaccount.png" width="106" height="23" hspace="3" alt=""/></a>
+ <a href="<%=returnPage%>"><img border="0" src="images/cancel_btn.gif" width="72" height="24" alt=""></a>
+ <%
+ }
+ else {
+ %>
+ <a href="<%=returnPage%>"><img border="0" src="images/loginnow.png" width="106" height="23" hspace="3" alt=""/></a>
+ <%
+ }
+ %>
+ </td>
+ </tr>
+ </table>
+ <input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
+ </form>
+ </td>
+ </tr>
+ </table>
+
+ </div>
+<%@ include file="footer.jsp" %>
+ </div>
+</body>
+</html>
More information about the Ils-source
mailing list