Index: src/plugins/broadcast/readme.html =================================================================== --- src/plugins/broadcast/readme.html (revision 10222) +++ src/plugins/broadcast/readme.html (working copy) @@ -76,6 +76,8 @@ to broadcast messages to all connected users at once. When this property isn't set, anyone is allowed to broadcast messages to all users. Users should be specified by their bare JID (e.g. john@myserver.com) +
  • plugin.broadcast.messagePrefix -- string prepended to all broadcast messages. + If no value is set, the default is to leave the message unaltered.
  • Using the Plugin

    Index: src/plugins/broadcast/src/java/org/jivesoftware/openfire/plugin/BroadcastPlugin.java =================================================================== --- src/plugins/broadcast/src/java/org/jivesoftware/openfire/plugin/BroadcastPlugin.java (revision 10222) +++ src/plugins/broadcast/src/java/org/jivesoftware/openfire/plugin/BroadcastPlugin.java (working copy) @@ -12,6 +12,7 @@ package org.jivesoftware.openfire.plugin; +import org.dom4j.tree.FlyweightText; import org.dom4j.Element; import org.jivesoftware.openfire.SessionManager; import org.jivesoftware.openfire.XMPPServer; @@ -44,6 +45,7 @@ public class BroadcastPlugin implements Plugin, Component, PropertyEventListener { private String serviceName; + private String messagePrefix; private SessionManager sessionManager; private GroupManager groupManager; private List allowedUsers; @@ -62,6 +64,7 @@ groupMembersAllowed = JiveGlobals.getBooleanProperty( "plugin.broadcast.groupMembersAllowed", true); allowedUsers = stringToList(JiveGlobals.getProperty("plugin.broadcast.allowedUsers", "")); + messagePrefix = JiveGlobals.getProperty("plugin.broadcast.messagePrefix", null); } // Plugin Interface @@ -173,6 +176,10 @@ private void processMessage(Message message, boolean targetAll, Group group, boolean canProceed) { + // Prepend each message with the global prefix. + if (messagePrefix != null && message.getBody() != null) { + prependMessage(message.getElement()); + } // Check to see if trying to broadcast to all connected users. if (targetAll) { if (!canProceed) { @@ -574,4 +581,26 @@ } return values; } -} \ No newline at end of file + + /** + * Iteratively prepend all message bodys within a given Element with + * value from messagePrefix property. + * + * @param element a Message element. + */ + private void prependMessage(Element element) { + Iterator it = element.elementIterator(); + while (it.hasNext()) { + Element el = (Element)it.next(); + if (el.getName().equals("body")) { + List content = el.content(); + FlyweightText text = new FlyweightText(messagePrefix); + content.add(0, text); + el.setContent(content); + } + else { + prependMessage(el); + } + } + } +}