Update of /var/cvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets In directory james.mmbase.org:/tmp/cvs-serv12154/portlets-login/src/java/com/finalist/cmsc/portlets
Modified Files: Tag: b1_5 RegisterPorlet.java Log Message: NWS-32 - Vinkje met link gebruikersvoorwaarden kunnen toevoegen aan registratieformulier See also: http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets See also: http://www.mmbase.org/jira/browse/NWS-32 Index: RegisterPorlet.java =================================================================== RCS file: /var/cvs/contributions/CMSContainer_Portlets/portlets-login/src/java/com/finalist/cmsc/portlets/RegisterPorlet.java,v retrieving revision 1.1.2.15 retrieving revision 1.1.2.16 diff -u -b -r1.1.2.15 -r1.1.2.16 --- RegisterPorlet.java 13 Feb 2009 04:44:28 -0000 1.1.2.15 +++ RegisterPorlet.java 4 Mar 2009 13:45:34 -0000 1.1.2.16 @@ -12,6 +12,7 @@ import javax.portlet.ActionResponse; import javax.portlet.PortletException; import javax.portlet.PortletPreferences; +import javax.portlet.PortletSession; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; @@ -27,6 +28,7 @@ import com.finalist.cmsc.services.community.security.Authentication; import com.finalist.cmsc.services.community.security.AuthenticationService; import com.finalist.cmsc.services.community.security.AuthorityService; +import com.finalist.cmsc.services.sitemanagement.SiteManagement; import com.finalist.cmsc.util.EmailSender; public class RegisterPorlet extends AbstractLoginPortlet { @@ -37,10 +39,15 @@ private static final String ACEGI_SECURITY_FORM_LASTNAME_KEY = "lastName"; private static final String ACEGI_SECURITY_FORM_PASSWORD_KEY = "passwordText"; private static final String ACEGI_SECURITY_FORM_PASSWORDCONF_KEY = "passwordConfirmation"; + private static final String ACEGI_SECURITY_FORM_TERMS = "agreedToTerms"; private static final String GROUPNAME = "groupName"; + private static final String ALLGROUPNAMES = "allGroupNames"; private static final String NoGROUP = "nogroup"; + private static final String USE_TERMS="useterms"; + private static final String TERMS_PAGE = "page"; + private static final Log log = LogFactory.getLog(RegisterPorlet.class); @Override @@ -49,6 +56,17 @@ PortletPreferences preferences = req.getPreferences(); setAttribute(req, GROUPNAME, preferences.getValue(GROUPNAME,"")); setAttribute(req, ALLGROUPNAMES, getAllGroupNames()); + /* NWS-32 */ + setAttribute(req, USE_TERMS, preferences.getValue(USE_TERMS,"")); + + String pageid = preferences.getValue(TERMS_PAGE, null); + if (StringUtils.isNotEmpty(pageid)) { + String pagepath = SiteManagement.getPath(Integer.valueOf(pageid), true); + + if (pagepath != null) { + setAttribute(req, "pagepath", pagepath); + } + } super.doEditDefaults(req, res); } @@ -59,6 +77,9 @@ PortletPreferences preferences = request.getPreferences(); String portletId = preferences.getValue(PortalConstants.CMSC_OM_PORTLET_ID, null); setPortletParameter(portletId, GROUPNAME, request.getParameter(GROUPNAME)); + setPortletParameter(portletId, USE_TERMS, request.getParameter(USE_TERMS)); + setPortletParameter(portletId, TERMS_PAGE, request.getParameter(TERMS_PAGE)); + super.processEditDefaults(request, response); } @@ -75,26 +96,33 @@ String lastName = request.getParameter(ACEGI_SECURITY_FORM_LASTNAME_KEY); String passwordText = request.getParameter(ACEGI_SECURITY_FORM_PASSWORD_KEY); String passwordConfirmation = request.getParameter(ACEGI_SECURITY_FORM_PASSWORDCONF_KEY); + String terms = request.getParameter(ACEGI_SECURITY_FORM_TERMS); String errorMessages = ""; Long authId = null; + if (StringUtils.isBlank(email)) { errorMessages = "register.email.empty"; - response.setRenderParameter("errorMessages", errorMessages); + request.getPortletSession().setAttribute("errorMessages", errorMessages); return; } if (!isEmailAddress(email)) { errorMessages = "register.email.match"; - response.setRenderParameter("errorMessages", errorMessages); + request.getPortletSession().setAttribute("errorMessages", errorMessages); return; } if (StringUtils.isEmpty(passwordText)) { errorMessages = "register.password.empty"; - response.setRenderParameter("errorMessages", errorMessages); + request.getPortletSession().setAttribute("errorMessages", errorMessages); return; } if (!passwordText.equals(passwordConfirmation)) { errorMessages = "register.passwords.not_equal"; - response.setRenderParameter("errorMessages", errorMessages); + request.getPortletSession().setAttribute("errorMessages", errorMessages); + return; + } + if (preferences.getValue(USE_TERMS,"").equals("yes") && StringUtils.isBlank(terms)) { + errorMessages = "register.terms.agree"; + request.getPortletSession().setAttribute("errorMessages", errorMessages); return; } AuthenticationService authenticationService = (AuthenticationService) ApplicationContextFactory @@ -156,6 +184,8 @@ protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { String screenId = (String) request.getAttribute(PortalConstants.CMSC_OM_PAGE_ID); + PortletSession portletSession = request.getPortletSession(); + request.setAttribute("page", screenId); String template; String error = request.getParameter("errorMessages"); @@ -174,6 +204,12 @@ template = "login/register.jsp"; } } + /* NWS-46 errorMessages never came out so I added this */ + if (portletSession.getAttribute("errorMessages") != null) { + String errormessages = (String) portletSession.getAttribute("errorMessages"); + portletSession.removeAttribute("errorMessages"); + request.setAttribute("errorMessages", errormessages); + } doInclude("view", template, request, response); } _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs