<%@page import="com.insightguru.giraffe.server.Configuration"%> <%@ page import="com.insightguru.giraffe.server.filter.SecurityCheckFilter" %> <%@ page import="java.util.List" %> <%@ page import="com.insightguru.giraffe.server.domain.PendingInviteList" %> <%@ page import="com.insightguru.giraffe.server.dao.UserDAO" %> <%@ page import="com.insightguru.giraffe.server.dao.InviteDAO" %> <%@ page import="com.insightguru.giraffe.common.constant.UserProfileBitFlags" %> <%@ page import="org.owasp.esapi.ESAPI" %> <%@ page import="org.owasp.esapi.Encoder" %> <%@ page import="java.net.URLEncoder"%> <%@ page import="com.insightguru.giraffe.server.domain.PendingInviteStatus"%> <%@ page import="com.insightguru.giraffe.server.utils.GEmail"%> <%@ page import="com.insightguru.giraffe.server.utils.ServletUtil"%> <%!public String summarizePIL(PendingInviteList pi) { Encoder e = ESAPI.encoder(); StringBuilder sb = new StringBuilder(); sb.append(""); sb.append(e.encodeForHTML(pi.getEmail())); sb.append(""); sb.append(e.encodeForHTML(pi.getName())); sb.append(""); sb.append(e.encodeForHTML(pi.getHowTheyHeardAboutUs())); sb.append(""); sb.append((pi.getRequestedBy() == null) ? pi.getRequestedBy() : e.encodeForHTML(pi.getRequestedBy().getFullName())); sb.append(""); sb.append(e.encodeForHTML(pi.getMessage())); sb.append(""); sb.append(pi.getRequestedTime().toString()); try { switch (pi.getStatus()) { case PENDING: sb.append(" approve "); sb.append("| reject "); break; case REJECTED: sb.append(" unreject "); break; case APPROVED: sb.append("none"); break; } } catch (Exception ex) { sb.append("" + ex.getMessage()); } sb.append("\n"); return sb.toString(); }%> Trefis Pending Invites <% String periodName; String action; User currentUser = UserDAO.getCurrentUser(); if(currentUser == null || !UserProfileBitFlags.isAdmin(currentUser)) { %>

Admin Access Only

<% } else { if ("approve".equals(request.getParameter("action"))) { PendingInviteList thisPending = InviteDAO.getPendingInvite(request.getParameter("email")); %>
" /> Address To Approve: <%= request.getParameter("email") %>
Email Subject " />
Email Body:
<% } // end "approve".equals(request.getParameter("action")) if ("reject".equals(request.getParameter("action"))) { InviteDAO.rejectPendingInvite(request.getParameter("email")); } else if ("unreject".equals(request.getParameter("action"))) { InviteDAO.unrejectPendingInvite(request.getParameter("email")); } else if ("approve2".equals(request.getParameter("action"))) { PendingInviteList thisPending = InviteDAO.getPendingInvite(request.getParameter("email")); if (thisPending == null) { out.write("Email not sent, no pending invite found for " + request.getParameter("email")); } else if (thisPending.getStatus() == PendingInviteStatus.PENDING) { InviteDAO.approvePendingInvite(request.getParameter("email"), SecurityCheckFilter.getLoggedInUserId()); if (request.getParameter("sendEmail") != null ) { GEmail ge = GEmail.getServletConfigurationInstance(); if(!ge.isEnabled()) ge = GEmail.getTestingInstance(); ge.sendMail("admin@trefis.com", "Trefis", new String[] {thisPending.getEmail()}, null, request.getParameter("subject"), request.getParameter("body"), true); out.write("Email Sent to " + thisPending.getEmail()); } else { out.write("Address approved, but no Email sent to " + thisPending.getEmail()); } } else { out.write("Email not sent, status of " + thisPending.getEmail() + " was " + thisPending.getStatus().name()); } } List pil = InviteDAO.getPendingInvites(PendingInviteStatus.PENDING); List approved = InviteDAO.getPendingInvites(PendingInviteStatus.APPROVED); List rejected = InviteDAO.getPendingInvites(PendingInviteStatus.REJECTED); %>

Pending Invites

<% for (PendingInviteList pi : pil) { out.write(summarizePIL(pi)); } %>
emailnamehow_heard requested_by_user_idmessagerequestedtime Action
<%= pil.size() %> total

Approved Invites

<% for (PendingInviteList pi : approved) { out.write(summarizePIL(pi)); } %>
emailnamehow_heard requested_by_user_idmessagerequestedtime Action
<%= approved.size() %> total

Rejected Invites

<% for (PendingInviteList pi : rejected) { out.write(summarizePIL(pi)); } %>
emailnamehow_heard requested_by_user_idmessagerequestedtime Action
<%= rejected.size() %> total <%@ include file="components/jqueryJS.jsp" %> <% } %>