Commit dec892c0 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

1. Modified RegistrationPlugin due to changes in SessionManager#sendServerMessage.

2. Renamed to RegistrationPlugin.java


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1268 b35dd754-fafc-0310-a699-88a17e54d16e
parent c67079f5
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<class>org.jivesoftware.messenger.plugin.RegistrationNotificationPlugin</class>
<class>org.jivesoftware.messenger.plugin.RegistrationPlugin</class>
<name>Registration Notification Plugin</name>
<description>Adds the ability to allow an specified user to be notified whenever a new user attempts to register with the server.</description>
<author>Ryan Graham</author>
......
/**
* 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.
*/
package org.jivesoftware.messenger.plugin;
import org.jivesoftware.messenger.SessionManager;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.container.Plugin;
import org.jivesoftware.messenger.container.PluginManager;
import org.jivesoftware.messenger.event.UserEventDispatcher;
import org.jivesoftware.messenger.event.UserEventListener;
import org.jivesoftware.messenger.user.User;
import org.jivesoftware.util.JiveGlobals;
import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
import java.io.File;
import java.util.Map;
public class RegistrationPlugin implements Plugin {
private PluginManager pluginManager;
private SessionManager sessionManager;
private RegistrationUserEventListener listener = new RegistrationUserEventListener();
private static String serverName;
private boolean serviceEnabled;
private String contact;
public RegistrationPlugin() {
sessionManager = SessionManager.getInstance();
serverName = XMPPServer.getInstance().getServerInfo().getName();
serviceEnabled = JiveGlobals.getBooleanProperty("registration.notification.enabled", true);
setServiceEnabled(serviceEnabled);
contact = JiveGlobals.getProperty("registration.notification.contact");
if (contact == null) {
contact = "admin";
JiveGlobals.setProperty("registration.notification.contact", contact);
}
UserEventDispatcher.addListener(listener);
}
public String getName() {
return pluginManager.getName(this);
}
public String getDescription() {
return pluginManager.getDescription(this);
}
public String getAuthor() {
return pluginManager.getAuthor(this);
}
public String getVersion() {
return pluginManager.getVersion(this);
}
public void processPacket(Packet packet) {
}
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
}
public void destroyPlugin() {
UserEventDispatcher.removeListener(listener);
pluginManager = null;
sessionManager = null;
}
public void setServiceEnabled(boolean enable) {
serviceEnabled = enable;
JiveGlobals.setProperty("registration.notification.enabled", serviceEnabled ? "true" : "false");
}
public boolean serviceEnabled() {
return "true".equals(JiveGlobals.getProperty("registration.notification.enabled"));
}
public void setContact(String contact) {
this.contact = contact;
JiveGlobals.setProperty("registration.notification.contact", contact);
}
public String getContact() {
return contact;
}
//TODO JM-170
//TODO add the ability to have a admin configurable messange sent to newly registered user
//TODO add the ability for the admin to monitor when users are created and/or deleted?
private class RegistrationUserEventListener implements UserEventListener {
public void userCreated(User user, Map params) {
String msg = " A new user with the username of '" + user.getUsername() + "' just registered";
sessionManager.sendServerMessage(new JID(getContact() + "@" + serverName),
"Registration Notification",
msg);
}
public void userDeleting(User user, Map params) {
}
public void userModified(User user, Map params) {
}
}
}
......@@ -2,7 +2,7 @@
org.jivesoftware.admin.*,
org.jivesoftware.messenger.XMPPServer,
org.jivesoftware.messenger.user.*,
org.jivesoftware.messenger.plugin.RegistrationNotificationPlugin,
org.jivesoftware.messenger.plugin.RegistrationPlugin,
org.jivesoftware.util.*"
errorPage="error.jsp"
%>
......@@ -20,7 +20,7 @@
boolean notificationEnabled = ParamUtils.getBooleanParameter(request, "notificationenabled");
String contactName = ParamUtils.getParameter(request, "contactname");
RegistrationNotificationPlugin plugin = (RegistrationNotificationPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("registrationnotification");
RegistrationPlugin plugin = (RegistrationPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("registrationnotification");
Map errors = new HashMap();
if (save) {
......
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