Commit 3fd654b1 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Removed hardcoded "admin" user and used a Widlfire admin instead. JM-906

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6320 b35dd754-fafc-0310-a699-88a17e54d16e
parent ff8984ee
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
errorPage="error.jsp" errorPage="error.jsp"
%> %>
<%@ page import="java.text.SimpleDateFormat"%> <%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="org.xmpp.packet.JID" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
...@@ -21,15 +22,15 @@ ...@@ -21,15 +22,15 @@
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" /> <jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<% webManager.init(request, response, session, application, out ); %> <% webManager.init(request, response, session, application, out ); %>
<% // Get paramters <% // Get paramters
boolean doTest = request.getParameter("test") != null; boolean doTest = request.getParameter("test") != null;
boolean cancel = request.getParameter("cancel") != null; boolean cancel = request.getParameter("cancel") != null;
boolean sent = ParamUtils.getBooleanParameter(request,"sent"); boolean sent = ParamUtils.getBooleanParameter(request, "sent");
boolean success = ParamUtils.getBooleanParameter(request,"success"); boolean success = ParamUtils.getBooleanParameter(request, "success");
String from = ParamUtils.getParameter(request,"from"); String from = ParamUtils.getParameter(request, "from");
String to = ParamUtils.getParameter(request,"to"); String to = ParamUtils.getParameter(request, "to");
String subject = ParamUtils.getParameter(request,"subject"); String subject = ParamUtils.getParameter(request, "subject");
String body = ParamUtils.getParameter(request,"body"); String body = ParamUtils.getParameter(request, "body");
// Cancel if requested // Cancel if requested
if (cancel) { if (cancel) {
...@@ -43,17 +44,25 @@ ...@@ -43,17 +44,25 @@
// Validate input // Validate input
Map<String, String> errors = new HashMap<String, String>(); Map<String, String> errors = new HashMap<String, String>();
if (doTest) { if (doTest) {
if (from == null) { errors.put("from",""); } if (from == null) {
if (to == null) { errors.put("to",""); } errors.put("from", "");
if (subject == null) { errors.put("subject",""); } }
if (body == null) { errors.put("body",""); } if (to == null) {
errors.put("to", "");
}
if (subject == null) {
errors.put("subject", "");
}
if (body == null) {
errors.put("body", "");
}
EmailService service = EmailService.getInstance(); EmailService service = EmailService.getInstance();
// Validate host - at a minimum, it needs to be set: // Validate host - at a minimum, it needs to be set:
String host = service.getHost(); String host = service.getHost();
if (host == null) { if (host == null) {
errors.put("host",""); errors.put("host", "");
} }
// if no errors, continue // if no errors, continue
...@@ -86,7 +95,18 @@ ...@@ -86,7 +95,18 @@
} }
// Set var defaults // Set var defaults
User user = webManager.getUserManager().getUser("admin"); Collection<JID> jids = webManager.getXMPPServer().getAdmins();
User user = null;
if (!jids.isEmpty()) {
for (JID jid : jids) {
if (webManager.getXMPPServer().isLocal(jid)) {
user = webManager.getUserManager().getUser(jid.getNode());
if (user.getEmail() != null) {
break;
}
}
}
}
if (from == null) { if (from == null) {
from = user.getEmail(); from = user.getEmail();
} }
...@@ -218,7 +238,7 @@ function checkClick(el) { ...@@ -218,7 +238,7 @@ function checkClick(el) {
<input type="hidden" name="from" value="<%= from %>"> <input type="hidden" name="from" value="<%= from %>">
<%= StringUtils.escapeHTMLTags(from) %> <%= StringUtils.escapeHTMLTags(from) %>
<span class="jive-description"> <span class="jive-description">
(<a href="user-edit-form.jsp?username=admin">Update Address</a>) (<a href="user-edit-form.jsp?username=<%=user.getUsername()%>">Update Address</a>)
</span> </span>
</td> </td>
</tr> </tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment