]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_config.erl: Added possibility for appending values
authorAlexey Shchepin <alexey@process-one.net>
Tue, 31 Jul 2007 04:13:29 +0000 (04:13 +0000)
committerAlexey Shchepin <alexey@process-one.net>
Tue, 31 Jul 2007 04:13:29 +0000 (04:13 +0000)
to config options (thanks to Badlop)
* doc/guide.tex: Updated

SVN Revision: 845

ChangeLog
doc/guide.tex
src/ejabberd_config.erl

index 56e19a51b8a9999ce9a108723daf2cfaa85f2b02..b75e64aa362a142baed9eb3c603c1a270947c0ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-31  Alexey Shchepin  <alexey@sevcom.net>
+
+       * src/ejabberd_config.erl: Added possibility for appending values
+       to config options (thanks to Badlop)
+       * doc/guide.tex: Updated
+
 2007-07-30  Mickael Remond  <mickael.remond@process-one.net>
 
        * src/xml.erl: Better escaping management with CDATA. We only add
index b5175f93c764f1976bb79fe8c697787711d66979..dc42f6bc839507026182f12a1b18adb64d6f5fd8 100644 (file)
@@ -740,6 +740,25 @@ Examples:
 \end{verbatim}
 \end{itemize}
 
+If you want to define more \term{registration\_watchers} or \term{modules} for a virtual host and add them to the defined for all the Jabber server, instead of defining the option name simply as \term{modules} use this: \term{\{add, modules\}}.
+
+Examples:
+\begin{itemize}
+       \item If you defined two global watchers but on a certain virtual host only Ann should be watcher:
+\begin{verbatim}
+{registration_watchers, ["tom@example.com", "moe@example.net"]}.
+
+{host_config, "example.org", [{registration_watchers, ["ann@example.net"]}]}.
+\end{verbatim}
+
+\item If you prefer all three to be registration watchers on that virtual host:
+\begin{verbatim}
+{registration_watchers, ["tom@example.com", "moe@example.net"]}.
+
+{host_config, "example.org", [{{add, registration_watchers}, ["ann@example.net"]}]}.
+\end{verbatim}
+\end{itemize}
+
 \subsubsection{SASL Anonymous and Anonymous Login}
 \label{saslanonymous}
 \ind{sasl anonymous}\ind{anonymous login}
index a44c9378f347968777de554e6d9f64b6f72dcb1d..a06d4e2bc3653094723bc3f1804a10ff5e4e67f9 100644 (file)
@@ -3,12 +3,10 @@
 %%% Author  : Alexey Shchepin <alexey@sevcom.net>
 %%% Purpose : Load config file
 %%% Created : 14 Dec 2002 by Alexey Shchepin <alexey@sevcom.net>
-%%% Id      : $Id$
 %%%----------------------------------------------------------------------
 
 -module(ejabberd_config).
 -author('alexey@sevcom.net').
--vsn('$Revision$ ').
 
 -export([start/0, load_file/1,
         add_global_option/2, add_local_option/2,
@@ -188,8 +186,26 @@ add_option(Opt, Val, State) ->
            State#state{opts = [#config{key = Opt, value = Val} |
                                State#state.opts]};
        local_config ->
-           State#state{opts = [#local_config{key = Opt, value = Val} |
-                               State#state.opts]}
+           case Opt of
+               {{add, OptName}, Host} ->
+                   State#state{opts = compact({OptName, Host}, Val,
+                                              State#state.opts, [])};
+               _ ->
+                   State#state{opts = [#local_config{key = Opt, value = Val} |
+                                       State#state.opts]}
+           end
+    end.
+
+compact(Opt, Val, [], Os) ->
+    [#local_config{key = Opt, value = Val}] ++ Os;
+compact(Opt, Val, [O | Os1], Os2) ->
+    case O#local_config.key of
+       Opt ->
+           Os2 ++ [#local_config{key = Opt,
+                                 value = Val++O#local_config.value}
+                  ] ++ Os1;
+       _ ->
+           compact(Opt, Val, Os1, Os2++[O])
     end.