%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
import="java.util.*"
import="javax.servlet.http.HttpServletRequest"
import="com.tootsville.user.*"
import="org.starhope.appius.user.*"
import="org.starhope.appius.mb.Messages"
import="com.tootsville.WebUtil"
%><%
//---------- Universal Declarations: Place this on every page.
/**
* Parent/User object. On myAccount this should be declared User and on parent this should be declared Parent
*/
Parent sessionUser=null;
/**
* Error message list
*/
HashMap err = new HashMap ();
HashMap storeValues = new HashMap ();
String url = "/membership/";
%><%
//----------- Verify the session and create a User or Parent Object
//----------- This should be placed on any of the 'logged in' sections on the website.
if (null!=session.getAttribute("sUserID")
&& null!=session.getAttribute("sUserPassword")
&& null!=session.getAttribute("sUserType")) {
String userID=session.getAttribute("sUserID").toString();
String userPassword=session.getAttribute("sUserPassword").toString();
String userType=session.getAttribute("sUserType").toString();
if (userPassword.equals("approval")) {
WebUtil.log ("A parent has come to approve or deny their child.");
sessionUser=Parent.getByID(Integer.parseInt(userID));
WebUtil.log ("userID: " + userID + " userType: " + userType + " password: " + userPassword);
} else {
if (userType.equals(WebUtil.USER)) {
err.put("username", Messages.getText("login_invalid"));
url = "/membership/";
} else if (userType.equals(WebUtil.PARENT)) {
sessionUser=WebUtil.verifyParentLogin(userID, userPassword);
}
if (null==sessionUser)
err.put("username", Messages.getText("login_invalid"));
}
} else {
if (null==session.getAttribute("sUserID"))
if (null==session.getAttribute("sUserPassword"))
if (null==session.getAttribute("sUserType"))
err.put("username", Messages.getText("login_invalid"));
}
Toot selectedChild = null;
String childID = "";
if (null!=request.getParameter("toot") && !request.getParameter("toot").equals("")) {
childID = request.getParameter("toot");
selectedChild = (Toot) User.getByID(Integer.parseInt(childID));
}
//----------- Error handling: Place this on every page.
//----------- These errors are read and displayed by Header.jsp
if (err.size() > 0) {
session.setAttribute("sError", err);
response.sendRedirect(url);
} else {
%>
Tootsville™ Membership