Commit 8e88fb87 authored by Ryan Graham's avatar Ryan Graham Committed by ryang

added the ability to allow users to create accounts via a web page

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3261 b35dd754-fafc-0310-a699-88a17e54d16e
parent 04adb4c8
......@@ -44,6 +44,11 @@
Registration Plugin Changelog
</h1>
<p><b>1.3.0</b> -- January 6, 2006</p>
<ul>
<li>Added the ability to allow users to create accounts via a web page.</li>
</ul>
<p><b>1.2.1</b> -- December 15, 2005</p>
<ul>
<li>Now requires Wildfire 2.4.0</li>
......
......@@ -5,11 +5,11 @@
<name>Registration</name>
<description>Performs various actions whenever a new user account is created.</description>
<author>Ryan Graham</author>
<version>1.2.1</version>
<date>12/15/2005</date>
<version>1.3.0</version>
<date>01/05/2005</date>
<minServerVersion>2.4.0</minServerVersion>
<adminconsole>
<adminconsole>
<tab id="tab-users">
<sidebar id="sidebar-users">
<item id="registration-props-form" name="Registration Properties"
......
......@@ -67,6 +67,7 @@ The registration plugin has three items that can be configured:
notify them whenever a new user registers.</li>
<li>Welcome Message - A message that will be sent to a user when they first register.</li>
<li>Default Group - A group that all users will be added to when they first register.</li>
<li>Web Page Registration - Allows users to create accounts via a web page.
<h2>Using the Plugin</h2>
<p>
......
......@@ -17,12 +17,12 @@ import org.jivesoftware.wildfire.group.Group;
import org.jivesoftware.wildfire.group.GroupManager;
import org.jivesoftware.wildfire.group.GroupNotFoundException;
import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.admin.AuthCheckFilter;
import org.jivesoftware.util.EmailService;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;
import java.io.File;
import java.util.ArrayList;
......@@ -43,6 +43,8 @@ import javax.mail.internet.MimeUtility;
* @author Ryan Graham.
*/
public class RegistrationPlugin implements Plugin {
private static final String URL = "registration/sign-up.jsp";
/**
* The expected value is a boolean, if true all contacts specified in the property #IM_CONTACTS
* will receive a notification when a new user registers. The default value is false.
......@@ -67,6 +69,12 @@ public class RegistrationPlugin implements Plugin {
*/
private static final String GROUP_ENABLED = "registration.group.enabled";
/**
* The expected value is a boolean, if true any users will be able to register at the following
* url http://[SERVER_NAME}:9090/plugins/registration/sign-up.jsp
*/
private static final String WEB_ENABLED = "registration.web.enabled";
/**
* The expected value is a comma separated String of usernames who will receive a instant
* message when a new user registers if the property #IM_NOTIFICATION_ENABLED is set to true.
......@@ -90,6 +98,12 @@ public class RegistrationPlugin implements Plugin {
* be added to when they register, if the property #GROUP_ENABLED is set to true.
*/
private static final String REGISTRAION_GROUP = "registration.group";
/**
* The expected value is a String that contains the text that will be displayed in the header
* of the sign-up.jsp, if the property #WEB_ENABLED is set to true.
*/
private static final String HEADER = "registration.header";
private RegistrationUserEventListener listener = new RegistrationUserEventListener();
......@@ -122,13 +136,12 @@ public class RegistrationPlugin implements Plugin {
JiveGlobals.deleteProperty("registration.notification.enabled");
}
public void processPacket(Packet packet) {
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
AuthCheckFilter.addExclude(URL);
}
public void destroyPlugin() {
AuthCheckFilter.removeExclude(URL);
UserEventDispatcher.removeListener(listener);
serverAddress = null;
listener = null;
......@@ -196,7 +209,7 @@ public class RegistrationPlugin implements Plugin {
}
public void setWelcomeEnabled(boolean enable) {
JiveGlobals.setProperty(WELCOME_ENABLED, enable ? "true" : "false");
JiveGlobals.setProperty(WELCOME_ENABLED, enable ? "true" : "false");
}
public boolean welcomeEnabled() {
......@@ -219,6 +232,19 @@ public class RegistrationPlugin implements Plugin {
return JiveGlobals.getBooleanProperty(GROUP_ENABLED, false);
}
public void setWebEnabled(boolean enable) {
JiveGlobals.setProperty(WEB_ENABLED, enable ? "true" : "false");
}
public boolean webEnabled() {
return JiveGlobals.getBooleanProperty(WEB_ENABLED, false);
}
public String webRegistrationAddress() {
return "http://" + XMPPServer.getInstance().getServerInfo().getName() + ":"
+ JiveGlobals.getXMLProperty("adminConsole.port") + "/plugins/" + URL;
}
public void setGroup(String group) {
JiveGlobals.setProperty(REGISTRAION_GROUP, group);
}
......@@ -227,6 +253,14 @@ public class RegistrationPlugin implements Plugin {
return JiveGlobals.getProperty(REGISTRAION_GROUP);
}
public void setHeader(String message) {
JiveGlobals.setProperty(HEADER, message);
}
public String getHeader() {
return JiveGlobals.getProperty(HEADER, "Web Sign-In");
}
private class RegistrationUserEventListener implements UserEventListener {
public void userCreated(User user, Map params) {
if (imNotificationEnabled()) {
......@@ -304,8 +338,7 @@ public class RegistrationPlugin implements Plugin {
try {
GroupManager groupManager = GroupManager.getInstance();
Group group = groupManager.getGroup(getGroup());
group.getMembers()
.add(XMPPServer.getInstance().createJID(user.getUsername(), null));
group.getMembers().add(XMPPServer.getInstance().createJID(user.getUsername(), null));
}
catch (GroupNotFoundException e) {
Log.error(e);
......
<%--
- Copyright (C) 2005 Jive Software. All rights reserved.
-
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ page
import="java.util.*,
org.jivesoftware.admin.*,
......@@ -12,143 +19,161 @@
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<%
boolean save = request.getParameter("save") != null;
boolean saveWelcome = request.getParameter("savemessage") != null;
boolean saveGroup = request.getParameter("savegroup") != null;
boolean save = request.getParameter("save") != null;
boolean saveWelcome = request.getParameter("savemessage") != null;
boolean saveGroup = request.getParameter("savegroup") != null;
boolean saveHeader = request.getParameter("saveheader") != null;
boolean imEnabled = ParamUtils.getBooleanParameter(request, "imenabled", false);
boolean emailEnabled = ParamUtils.getBooleanParameter(request, "emailenabled", false);
boolean welcomeEnabled = ParamUtils.getBooleanParameter(request, "welcomeenabled", false);
boolean groupEnabled = ParamUtils.getBooleanParameter(request, "groupenabled", false);
boolean imEnabled = ParamUtils.getBooleanParameter(request, "imenabled", false);
boolean emailEnabled = ParamUtils.getBooleanParameter(request, "emailenabled", false);
boolean welcomeEnabled = ParamUtils.getBooleanParameter(request, "welcomeenabled", false);
boolean groupEnabled = ParamUtils.getBooleanParameter(request, "groupenabled", false);
boolean webEnabled = ParamUtils.getBooleanParameter(request, "webenabled", false);
String contactIM = ParamUtils.getParameter(request, "contactIM");
boolean addIM = ParamUtils.getBooleanParameter(request, "addIM");
boolean deleteIM = ParamUtils.getBooleanParameter(request, "deleteIM");
String contactIM = ParamUtils.getParameter(request, "contactIM");
boolean addIM = ParamUtils.getBooleanParameter(request, "addIM");
boolean deleteIM = ParamUtils.getBooleanParameter(request, "deleteIM");
String contactEmail = ParamUtils.getParameter(request, "contactEmail");
boolean addEmail = ParamUtils.getBooleanParameter(request, "addEmail");
boolean deleteEmail = ParamUtils.getBooleanParameter(request, "deleteEmail");
String contactEmail = ParamUtils.getParameter(request, "contactEmail");
boolean addEmail = ParamUtils.getBooleanParameter(request, "addEmail");
boolean deleteEmail = ParamUtils.getBooleanParameter(request, "deleteEmail");
String welcomeMessage = ParamUtils.getParameter(request, "welcomemessage");
String group = ParamUtils.getParameter(request, "groupname");
String welcomeMessage = ParamUtils.getParameter(request, "welcomemessage");
String group = ParamUtils.getParameter(request, "groupname");
String header = ParamUtils.getParameter(request, "header");
RegistrationPlugin plugin = (RegistrationPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("registration");
RegistrationPlugin plugin = (RegistrationPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("registration");
Map<String, String> errors = new HashMap<String, String>();
if (addIM) {
if (contactIM == null) {
errors.put("missingContact", "missingContact");
}
else {
contactIM = contactIM.trim().toLowerCase();
Map<String, String> errors = new HashMap<String, String>();
if (addIM) {
if (contactIM == null) {
errors.put("missingContact", "missingContact");
}
else {
contactIM = contactIM.trim().toLowerCase();
try {
XMPPServer.getInstance().getUserManager().getUser(contactIM);
plugin.addIMContact(contactIM);
response.sendRedirect("registration-props-form.jsp?addSuccess=true");
return;
}
catch (UserNotFoundException unfe) {
errors.put("userNotFound", "userNotFound");
}
}
}
try {
XMPPServer.getInstance().getUserManager().getUser(contactIM);
plugin.addIMContact(contactIM);
response.sendRedirect("registration-props-form.jsp?addSuccess=true");
return;
}
catch (UserNotFoundException unfe) {
errors.put("userNotFound", "userNotFound");
}
}
}
if (deleteIM) {
plugin.removeIMContact(contactIM);
response.sendRedirect("registration-props-form.jsp?deleteSuccess=true");
return;
}
if (deleteIM) {
plugin.removeIMContact(contactIM);
response.sendRedirect("registration-props-form.jsp?deleteSuccess=true");
return;
}
if (addEmail) {
if (contactEmail == null) {
errors.put("missingContact", "missingContact");
}
else {
if (plugin.isValidAddress(contactEmail)) {
plugin.addEmailContact(contactEmail);
response.sendRedirect("registration-props-form.jsp?addSuccess=true");
return;
}
else {
errors.put("invalidAddress", "invalidAddress");
}
}
}
if (addEmail) {
if (contactEmail == null) {
errors.put("missingContact", "missingContact");
}
else {
if (plugin.isValidAddress(contactEmail)) {
plugin.addEmailContact(contactEmail);
response.sendRedirect("registration-props-form.jsp?addSuccess=true");
return;
}
else {
errors.put("invalidAddress", "invalidAddress");
}
}
}
if (deleteEmail) {
plugin.removeEmailContact(contactEmail);
response.sendRedirect("registration-props-form.jsp?deleteSuccess=true");
return;
}
if (deleteEmail) {
plugin.removeEmailContact(contactEmail);
response.sendRedirect("registration-props-form.jsp?deleteSuccess=true");
return;
}
if (save) {
plugin.setIMNotificationEnabled(imEnabled);
plugin.setEmailNotificationEnabled(emailEnabled);
plugin.setWelcomeEnabled(welcomeEnabled);
if (save) {
plugin.setIMNotificationEnabled(imEnabled);
plugin.setEmailNotificationEnabled(emailEnabled);
plugin.setWelcomeEnabled(welcomeEnabled);
plugin.setWebEnabled(webEnabled);
if (groupEnabled) {
group = plugin.getGroup();
if (group == null || group.trim().length() < 1) {
errors.put("groupNotFound", "groupNotFound");
}
if (groupEnabled) {
group = plugin.getGroup();
if (group == null || group.trim().length() < 1) {
errors.put("groupNotFound", "groupNotFound");
}
try {
GroupManager.getInstance().getGroup(group);
}
catch (Exception e) {
errors.put("groupNotFound", "groupNotFound");
}
}
try {
GroupManager.getInstance().getGroup(group);
}
catch (Exception e) {
errors.put("groupNotFound", "groupNotFound");
}
}
if (errors.size() == 0) {
plugin.setGroupEnabled(groupEnabled);
response.sendRedirect("registration-props-form.jsp?settingsSaved=true");
return;
}
}
if (errors.size() == 0) {
plugin.setGroupEnabled(groupEnabled);
response.sendRedirect("registration-props-form.jsp?settingsSaved=true");
return;
}
}
if (saveWelcome) {
if (welcomeMessage == null || welcomeMessage.trim().length() < 1) {
errors.put("missingWelcomeMessage", "missingWelcomeMessage");
} else {
plugin.setWelcomeMessage(welcomeMessage);
response.sendRedirect("registration-props-form.jsp?welcomeSaved=true");
return;
}
}
if (saveWelcome) {
if (welcomeMessage == null || welcomeMessage.trim().length() < 1) {
errors.put("missingWelcomeMessage", "missingWelcomeMessage");
}
else {
plugin.setWelcomeMessage(welcomeMessage);
response.sendRedirect("registration-props-form.jsp?welcomeSaved=true");
return;
}
}
if (saveGroup && plugin.groupEnabled()) {
if (group == null || group.trim().length() < 1) {
errors.put("groupNotFound", "groupNotFound");
}
if (saveGroup && plugin.groupEnabled()) {
if (group == null || group.trim().length() < 1) {
errors.put("groupNotFound", "groupNotFound");
}
try {
GroupManager.getInstance().getGroup(group);
}
catch (Exception e) {
errors.put("groupNotFound", "groupNotFound");
}
try {
GroupManager.getInstance().getGroup(group);
}
catch (Exception e) {
errors.put("groupNotFound", "groupNotFound");
}
if (errors.size() == 0) {
plugin.setGroup(group);
response.sendRedirect("registration-props-form.jsp?groupSaved=true");
return;
}
}
if (errors.size() == 0) {
plugin.setGroup(group);
response.sendRedirect("registration-props-form.jsp?groupSaved=true");
return;
}
}
if (saveGroup && !plugin.groupEnabled()) {
group = (group == null) ? "" : group;
plugin.setGroup(group);
}
if (saveGroup && !plugin.groupEnabled()) {
group = (group == null) ? "" : group;
plugin.setGroup(group);
}
if (saveHeader) {
if (header == null || header.trim().length() < 1) {
errors.put("missingHeader", "missingHeader");
} else {
plugin.setHeader(header);
response.sendRedirect("registration-props-form.jsp?headerSaved=true");
return;
}
}
imEnabled = plugin.imNotificationEnabled();
emailEnabled = plugin.emailNotificationEnabled();
welcomeEnabled = plugin.welcomeEnabled();
groupEnabled = plugin.groupEnabled();
imEnabled = plugin.imNotificationEnabled();
emailEnabled = plugin.emailNotificationEnabled();
welcomeEnabled = plugin.welcomeEnabled();
groupEnabled = plugin.groupEnabled();
webEnabled = plugin.webEnabled();
welcomeMessage = plugin.getWelcomeMessage();
group = plugin.getGroup();
welcomeMessage = plugin.getWelcomeMessage();
group = plugin.getGroup();
header = plugin.getHeader();
%>
<html>
......@@ -160,13 +185,13 @@
<script language="JavaScript" type="text/javascript">
function addIMContact() {
document.regform.addIM.value = 'true';
document.regform.submit();
document.regform.addIM.value = 'true';
document.regform.submit();
}
function addEmailContact() {
document.regform.addEmail.value = 'true';
document.regform.submit();
document.regform.addEmail.value = 'true';
document.regform.submit();
}
</script>
......@@ -177,62 +202,66 @@ function addEmailContact() {
<input type="hidden" name="addEmail" value="">
<fieldset>
<legend>Registration Settings</legend>
<div>
<p>Enable registration features using the checkboxes below.</p>
<% if (ParamUtils.getBooleanParameter(request, "settingsSaved")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Settings saved successfully.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<% if (errors.containsKey("groupNotFound")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<legend>Registration Settings</legend>
<div>
<p>Enable registration features using the checkboxes below.</p>
<% if (ParamUtils.getBooleanParameter(request, "settingsSaved")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Settings saved successfully.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<% if (errors.containsKey("groupNotFound")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Please enter and save a valid group name in the Default Group section at the bottom of this page before enabling automatic group adding.</td>
</tr>
</tbody>
</table>
</div>
</tr>
</tbody>
</table>
</div>
<% } %>
<% } %>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="imenabled" <%=(imEnabled) ? "checked" : "" %> onclick="return enableWelcomeMessage();"></td>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="imenabled" <%=(imEnabled) ? "checked" : "" %>></td>
<td width="99%" align="left">Enable instant message registration notification.</td>
</tr>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="emailenabled" <%=(emailEnabled) ? "checked" : "" %> onclick="return enableWelcomeMessage();"></td>
</tr>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="emailenabled" <%=(emailEnabled) ? "checked" : "" %>></td>
<td width="99%" align="left">Enable email registration notification.</td>
</tr>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="welcomeenabled" <%=(welcomeEnabled) ? "checked" : "" %> onclick="return enableWelcomeMessage();"></td>
</tr>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="welcomeenabled" <%=(welcomeEnabled) ? "checked" : "" %>></td>
<td width="99%" align="left">Enable welcome message.</td>
</tr>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="groupenabled" <%=(groupEnabled) ? "checked" : "" %> onclick="return enableWelcomeMessage();"></td>
</tr>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="groupenabled" <%=(groupEnabled) ? "checked" : "" %>></td>
<td width="99%" align="left">Enable automatically adding of new users to a group.</td>
</tr>
</tbody>
</table>
</div>
</tr>
<tr>
<td width="1%" align="center" nowrap><input type="checkbox" name="webenabled" <%=(webEnabled) ? "checked" : "" %>></td>
<td width="99%" align="left">Enable users to register via a web page at <%=plugin.webRegistrationAddress() %>.</td>
</tr>
</tbody>
</table>
</div>
<input type="submit" value="Save Settings"/>
</fieldset>
......@@ -240,167 +269,163 @@ function addEmailContact() {
<br><br>
<fieldset>
<legend>Registration Notification Contacts</legend>
<div>
<p>Add or remove contacts to be alerted when a new user registers.</p>
<% if (ParamUtils.getBooleanParameter(request, "deleteSuccess")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Contact successfully removed.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (ParamUtils.getBooleanParameter(request, "addSuccess")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Contact successfully added.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (errors.containsKey("missingContact")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Missing contact.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (errors.containsKey("userNotFound")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Contact not found.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (errors.containsKey("invalidAddress")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Invalid email address.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<div>
<label for="contacttf">Add IM Contact</label>
<input type="text" name="contactIM" size="30" maxlength="100" value="<%= (contactIM != null ? contactIM : "") %>" id="contacttf"/>
<input type="submit" value="Add" onclick="return addIMContact();"/>
<br>
<br>
<div class="jive-table" style="width:400px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<legend>Registration Notification Contacts</legend>
<div>
<p>Add or remove contacts to be alerted when a new user registers.</p>
<% if (ParamUtils.getBooleanParameter(request, "deleteSuccess")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Contact successfully removed.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (ParamUtils.getBooleanParameter(request, "addSuccess")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Contact successfully added.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (errors.containsKey("missingContact")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Missing contact.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (errors.containsKey("userNotFound")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Contact not found.</td>
</tr>
</tbody>
</table>
</div>
<% } else if (errors.containsKey("invalidAddress")) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Invalid email address.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<div>
<label for="contacttf">Add IM Contact:</label>
<input type="text" name="contactIM" size="30" maxlength="100" value="<%= (contactIM != null ? contactIM : "") %>" id="contacttf"/>
<input type="submit" value="Add" onclick="return addIMContact();"/>
<br><br>
<div class="jive-table" style="width:400px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th width="99%">IM Contact</th>
<th width="1%" nowrap>Remove</th>
</tr>
</thead>
<tbody>
<% if (plugin.getIMContacts().size() == 0) { %>
<tr>
<td width="100%" colspan="2" align="center" nowrap>No contacts specified, use the form above to add one.</td>
</tr>
<% } %>
<% for (String imContact : plugin.getIMContacts()) { %>
<tr>
<td width="99%"><%=imContact %></td>
<td width="1%" align="center"><a
href="registration-props-form.jsp?deleteIM=true&contactIM=<%=imContact %>"
title="Delete Contact?"
onclick="return confirm('Are you sure you want to delete this contact?');"><img
src="images/delete-16x16.gif" width="16" height="16"
border="0"></a>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
<div>
<label for="emailtf">Add Email Contact</label>
<input type="text" name="contactEmail" size="30" maxlength="100" value="<%= (contactEmail != null ? contactEmail : "") %>" id="emailtf"/>
<input type="submit" value="Add" onclick="return addEmailContact();"/>
<br>
<br>
<div class="jive-table" style="width:400px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
</tr>
</thead>
<tbody>
<% if (plugin.getIMContacts().size() == 0) { %>
<tr>
<td width="100%" colspan="2" align="center" nowrap>No contacts specified, use the form above to add one.</td>
</tr>
<% } %>
<% for (String imContact : plugin.getIMContacts()) { %>
<tr>
<td width="99%"><%=imContact %></td>
<td width="1%" align="center"><a
href="registration-props-form.jsp?deleteIM=true&contactIM=<%=imContact %>"
title="Delete Contact?"
onclick="return confirm('Are you sure you want to delete this contact?');"><img
src="images/delete-16x16.gif" width="16" height="16"
border="0"></a>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
<div>
<label for="emailtf">Add Email Contact:</label>
<input type="text" name="contactEmail" size="30" maxlength="100" value="<%= (contactEmail != null ? contactEmail : "") %>" id="emailtf"/>
<input type="submit" value="Add" onclick="return addEmailContact();"/>
<br><br>
<div class="jive-table" style="width:400px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
<tr>
<th width="99%">Email Contact</th>
<th width="1%" nowrap>Remove</th>
</tr>
</thead>
<tbody>
<% if (plugin.getEmailContacts().size() == 0) { %>
<tr>
<td width="100%" colspan="2" align="center" nowrap>No contacts
specified, use the form above to add one.</td>
</tr>
<% } %>
<% for (String emailContact : plugin.getEmailContacts()) { %>
<tr>
<td width="99%"><%=emailContact %></td>
<td width="1%" align="center"><a
href="registration-props-form.jsp?deleteEmail=true&contactEmail=<%=emailContact %>"
title="Delete Contact?"
onclick="return confirm('Are you sure you want to delete this contact?');"><img
src="images/delete-16x16.gif" width="16" height="16"
border="0"></a>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
</div>
</tr>
</thead>
<tbody>
<% if (plugin.getEmailContacts().size() == 0) { %>
<tr>
<td width="100%" colspan="2" align="center" nowrap>No contacts pecified, use the form above to add one.</td>
</tr>
<% } %>
<% for (String emailContact : plugin.getEmailContacts()) { %>
<tr>
<td width="99%"><%=emailContact %></td>
<td width="1%" align="center"><a
href="registration-props-form.jsp?deleteEmail=true&contactEmail=<%=emailContact %>"
title="Delete Contact?"
onclick="return confirm('Are you sure you want to delete this contact?');"><img
src="images/delete-16x16.gif" width="16" height="16"
border="0"></a>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</div>
</fieldset>
</form>
......@@ -408,43 +433,40 @@ function addEmailContact() {
<form action="registration-props-form.jsp?savemessage=true" method="post">
<fieldset>
<legend>Welcome Message</legend>
<div>
<legend>Welcome Message</legend>
<div>
<p>Enter the welcome message that will be sent to new users when they register.</p>
<p>Enter the welcome message that will be sent to new users when they register.</p>
<% if (ParamUtils.getBooleanParameter(request, "messageSaved")) { %>
<% if (ParamUtils.getBooleanParameter(request, "welcomeSaved")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Message saved successfully.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Message saved successfully.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td width="5%" valign="top">Message:&nbsp;</td>
<td width="95%"><textarea cols="45" rows="5" wrap="virtual" name="welcomemessage"><%= welcomeMessage %></textarea>
<% if (errors.containsKey("missingWelcomeMessage")) { %>
<span class="jive-error-text"> <br>
Please enter a welcome message.
</span>
<% } %>
</td>
</tr>
</tbody>
</table>
</div>
<input type="submit" value="Save Message"/>
<td width="95%"><textarea cols="45" rows="5" wrap="virtual" name="welcomemessage"><%= welcomeMessage %></textarea></td>
<% if (errors.containsKey("missingWelcomeMessage")) { %>
<span class="jive-error-text"><br>Please enter a welcome message.</span>
<% } %>
</tr>
</tbody>
</table>
</div>
<input type="submit" value="Save Message"/>
</fieldset>
</form>
......@@ -452,38 +474,79 @@ function addEmailContact() {
<form action="registration-props-form.jsp?savegroup=true" method="post">
<fieldset>
<legend>Default Group</legend>
<div>
<legend>Default Group</legend>
<div>
<p>Enter the name of the group that all new users will be automatically added to.</p>
<p>Enter the name of the group that all new users will be automatically added to.</p>
<% if (ParamUtils.getBooleanParameter(request, "groupSaved")) { %>
<% if (ParamUtils.getBooleanParameter(request, "groupSaved")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Group saved successfully.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Group saved successfully.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<label>Default Group</label>
<input type="text" name="groupname" size="30" maxlength="100" value="<%= (group != null ? group : "") %>"/>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td>Default Group:&nbsp;<input type="text" name="groupname" size="30" maxlength="100" value="<%= (group != null ? group : "") %>"/>
<% if (errors.containsKey("groupNotFound")) { %>
<span class="jive-error-text"><br>Group not found or is invalid.</span>
<% } %>
</tr>
</tbody>
</table>
</div>
<input type="submit" value="Save Group"/>
</fieldset>
</form>
<br><br>
<% if (errors.containsKey("groupNotFound")) { %>
<span class="jive-error-text"> <br>
Group not found or is invalid.
</span>
<% } %>
<form action="registration-props-form.jsp?saveheader=true" method="post">
<fieldset>
<legend>Sign-Up Page Header Text</legend>
<div>
<p>Enter the text that will be displayed at the top of the sign-up web page.</p>
</div>
<% if (ParamUtils.getBooleanParameter(request, "headerSaved")) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">Header saved successfully.</td>
</tr>
</tbody>
</table>
</div>
<% } %>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td>Header Text:&nbsp;<input type="text" name="header" size="30" maxlength="100" value="<%=header %>"/></td>
<% if (errors.containsKey("missingHeader")) { %>
<span class="jive-error-text"><br>Please enter a header.</span>
<% } %>
</tr>
</tbody>
</table>
</div>
<input type="submit" value="Save Group"/>
<input type="submit" value="Save Message"/>
</fieldset>
</form>
......
<%--
- Copyright (C) 2005 Jive Software. All rights reserved.
-
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ page import="org.jivesoftware.wildfire.user.*,
org.jivesoftware.wildfire.plugin.RegistrationPlugin,
org.jivesoftware.util.*,
org.jivesoftware.stringprep.Stringprep,
org.jivesoftware.stringprep.StringprepException"
%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<html>
<head>
<title>Jive Wifdfire Web Registration</title>
<link rel="stylesheet" type="text/css" href="/style/global.css">
<style type="text/css">
.drop-shadow {
font-weight: bold;
font-size: 14pt;
color: white;
text-shadow: black 0.1em 0.1em 0.2em;
padding-top: 21px;}
</style>
<meta name="decorator" content="none"/>
</head>
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
<jsp:useBean id="errors" class="java.util.HashMap" />
<% webManager.init(request, response, session, application, out);
boolean create = request.getParameter("create") != null;
String username = ParamUtils.getParameter(request,"username");
String name = ParamUtils.getParameter(request,"name");
String email = ParamUtils.getParameter(request,"email");
String password = ParamUtils.getParameter(request,"password");
String passwordConfirm = ParamUtils.getParameter(request,"passwordConfirm");
// Handle a request to create a user:
if (create) {
// Validate
if (username == null) {
errors.put("username","");
}
else {
try {
username = username.trim().toLowerCase();
username = Stringprep.nodeprep(username);
}
catch (StringprepException se) {
errors.put("username", "");
}
}
if (password == null) {
errors.put("password","");
}
if (passwordConfirm == null) {
errors.put("passwordConfirm","");
}
if (password != null && passwordConfirm != null && !password.equals(passwordConfirm)) {
errors.put("passwordMatch","");
}
// do a create if there were no errors
if (errors.size() == 0) {
try {
webManager.getUserManager().createUser(username, password, name, email);
response.sendRedirect("sign-up.jsp?success=true");
return;
}
catch (UserAlreadyExistsException e) {
errors.put("usernameAlreadyExists","");
}
catch (Exception e) {
errors.put("general","");
Log.error(e);
}
}
}
RegistrationPlugin plugin = (RegistrationPlugin) webManager.getXMPPServer().getPluginManager().getPlugin("registration");
%>
<body>
<div id="jive-header">
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr><td class="drop-shadow">&nbsp;<%=plugin.getHeader() %></td></tr>
</tbody>
</table>
</div>
<div id="jive-content">
<% if (!plugin.webEnabled()) { %>
This service is currently unavailable.
<% } else { %>
<p>Use the form below to create a new user account</p>
<c:set var="submit" value="${param.create}"/>
<c:set var="errors" value="${errors}"/>
<% if (!errors.isEmpty()) { %>
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"/></td>
<td class="jive-icon-label">
<% if (errors.get("general") != null) { %>
<fmt:message key="user.create.error_creating_account" />
<% } else if (errors.get("username") != null) { %>
<fmt:message key="user.create.invalid_username" />
<% } else if (errors.get("usernameAlreadyExists") != null) { %>
<fmt:message key="user.create.user_exist" />
<% } else if (errors.get("name") != null) { %>
<fmt:message key="user.create.invalid_name" />
<% } else if (errors.get("email") != null) { %>
<fmt:message key="user.create.invalid_email" />
<% } else if (errors.get("password") != null) { %>
<fmt:message key="user.create.invalid_password" />
<% } else if (errors.get("passwordMatch") != null) { %>
<fmt:message key="user.create.invalid_match_password" />
<% } else if (errors.get("passwordConfirm") != null) { %>
<fmt:message key="user.create.invalid_password_confirm" />
<% } %>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<% } else if (request.getParameter("success") != null) { %>
<div class="jive-success">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/success-16x16.gif" width="16" height="16" border="0"></td>
<td class="jive-icon-label">New account successfully created.</td>
</tr>
</tbody>
</table>
</div><br>
<% } %>
<form name="f" action="sign-up.jsp" method="get">
<fieldset>
<legend>Create Account</legend>
<div>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr>
<td width="1%" nowrap><label for="usernametf">Username:</label> *</td>
<td width="99%">
<input type="text" name="username" size="30" maxlength="75" value="<%= ((username!=null) ? username : "") %>"
id="usernametf" autocomplete="off">
</td>
</tr>
<tr>
<td width="1%" nowrap>
<label for="nametf">Name:</label>
</td>
<td width="99%">
<input type="text" name="name" size="30" maxlength="75" value="<%= ((name!=null) ? name : "") %>"
id="nametf">
</td>
</tr>
<tr>
<td width="1%" nowrap>
<label for="emailtf">Email:</label></td>
<td width="99%">
<input type="text" name="email" size="30" maxlength="75" value="<%= ((email!=null) ? email : "") %>"
id="emailtf">
</td>
</tr>
<tr>
<td nowrap>
<label for="passtf">Password:</label> *
</td>
<td width="99%">
<input type="password" name="password" value="" size="20" maxlength="75"
id="passtf">
</td>
</tr>
<tr>
<td width="1%" nowrap>
<label for="confpasstf">Confirm Password:</label> *
</td>
<td width="99%">
<input type="password" name="passwordConfirm" value="" size="20" maxlength="75"
id="confpasstf">
</td>
</tr>
</tbody>
</table>
<br>
<span class="jive-description">
* Required Fields
</span>
</div>
</fieldset>
<br><br>
<input type="submit" name="create" value="Create Account">
</form>
<script language="JavaScript" type="text/javascript">
document.f.username.focus();
</script>
<% } %>
</body>
</html>
\ No newline at end of file
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