* src/gen_mod.erl: First store module options in ETS and Mnesia,

then start the module. In case of failure, remove options from
ETS. Until now the module was started before the options were
stored in database, and some modules started incorrectly because
they couldn't access the options from database; for instance
mod_muc_room required this for reading max_users option.

* src/mod_muc/mod_muc_room.erl: Include the value of max_users
service option and the current max_users room option in the list
of allowed room limit values.

SVN Revision: 1685
This commit is contained in:
Badlop 2008-11-26 15:10:38 +00:00
parent 8ef0fe6b56
commit 34d93528ae
3 changed files with 36 additions and 12 deletions

View File

@ -1,3 +1,16 @@
2008-11-26 Badlop <badlop@process-one.net>
* src/gen_mod.erl: First store module options in ETS and Mnesia,
then start the module. In case of failure, remove options from
ETS. Until now the module was started before the options were
stored in database, and some modules started incorrectly because
they couldn't access the options from database; for instance
mod_muc_room required this for reading max_users option.
* src/mod_muc/mod_muc_room.erl: Include the value of max_users
service option and the current max_users room option in the list
of allowed room limit values.
2008-10-17 Christophe Romain <christophe.romain@process-one.net>
* src/mod_pubsub/node_pep.erl: Fix get_node_affiliations resultset to

View File

@ -62,14 +62,16 @@ start() ->
start_module(Host, Module, Opts) ->
set_module_opts_mnesia(Host, Module, Opts),
ets:insert(ejabberd_modules,
#ejabberd_module{module_host = {Module, Host},
opts = Opts}),
case catch Module:start(Host, Opts) of
{'EXIT', Reason} ->
del_module_mnesia(Host, Module),
ets:delete(ejabberd_modules, {Module, Host}),
?ERROR_MSG("~p", [Reason]);
_ ->
set_module_opts_mnesia(Host, Module, Opts),
ets:insert(ejabberd_modules,
#ejabberd_module{module_host = {Module, Host},
opts = Opts}),
ok
end.

View File

@ -2626,11 +2626,25 @@ check_allowed_persistent_change(XEl, StateData, From) ->
-define(PRIVATEXFIELD(Label, Var, Val),
?XFIELD("text-private", Label, Var, Val)).
get_default_room_maxusers(RoomState) ->
DefRoomOpts = gen_mod:get_module_opt(RoomState#state.server_host, mod_muc, default_room_options, ?MAX_USERS_DEFAULT),
RoomState2 = set_opts(DefRoomOpts, RoomState),
(RoomState2#state.config)#config.max_users.
get_config(Lang, StateData, From) ->
{_AccessRoute, _AccessCreate, _AccessAdmin, AccessPersistent} = StateData#state.access,
ServiceMaxUsers = get_service_max_users(StateData),
DefaultRoomMaxUsers = get_default_room_maxusers(StateData), %+++
?INFO_MSG("DefaultMaxUsers: ~p", [DefaultRoomMaxUsers]),
Config = StateData#state.config,
{MaxUsersRoomInteger, MaxUsersRoomString} =
case get_max_users(StateData) of
N when is_integer(N) ->
{N, erlang:integer_to_list(N)};
_ -> {0, "none"}
end,
Res =
[{xmlelement, "title", [],
[{xmlcdata, translate:translate(Lang, "Configuration for ") ++
@ -2670,13 +2684,7 @@ get_config(Lang, StateData, From) ->
[{"type", "list-single"},
{"label", translate:translate(Lang, "Maximum Number of Occupants")},
{"var", "muc#roomconfig_maxusers"}],
[{xmlelement, "value", [], [{xmlcdata,
case get_max_users(StateData) of
N when is_integer(N) ->
erlang:integer_to_list(N);
_ -> "none"
end
}]}] ++
[{xmlelement, "value", [], [{xmlcdata, MaxUsersRoomString}]}] ++
if
is_integer(ServiceMaxUsers) -> [];
true ->
@ -2687,7 +2695,8 @@ get_config(Lang, StateData, From) ->
[{xmlelement, "option", [{"label", erlang:integer_to_list(N)}],
[{xmlelement, "value", [],
[{xmlcdata, erlang:integer_to_list(N)}]}]} ||
N <- ?MAX_USERS_DEFAULT_LIST, N =< ServiceMaxUsers]
N <- lists:usort([ServiceMaxUsers, DefaultRoomMaxUsers, MaxUsersRoomInteger |
?MAX_USERS_DEFAULT_LIST]), N =< ServiceMaxUsers]
},
{xmlelement, "field",
[{"type", "list-single"},