25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

* src/mod_muc/mod_muc_room.erl: Use standardized MUC room

configuration fields (thanks to Magnus Henoch and Andy Turner)

SVN Revision: 592
This commit is contained in:
Alexey Shchepin 2006-08-04 01:57:51 +00:00
parent ab2e19a399
commit 81f9ffcd45
2 changed files with 55 additions and 23 deletions

View File

@ -1,3 +1,8 @@
2006-08-04 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc_room.erl: Use standardized MUC room
configuration fields (thanks to Magnus Henoch and Andy Turner)
2006-08-02 Alexey Shchepin <alexey@sevcom.net> 2006-08-02 Alexey Shchepin <alexey@sevcom.net>
* src/mod_roster_odbc.erl: Bugfix * src/mod_roster_odbc.erl: Bugfix

View File

@ -2103,41 +2103,56 @@ get_config(Lang, StateData, From) ->
[{xmlelement, "title", [], [{xmlelement, "title", [],
[{xmlcdata, translate:translate(Lang, "Configuration for ") ++ [{xmlcdata, translate:translate(Lang, "Configuration for ") ++
jlib:jid_to_string(StateData#state.jid)}]}, jlib:jid_to_string(StateData#state.jid)}]},
{xmlelement, "field", [{"type", "hidden"},
{"var", "FORM_TYPE"}],
[{xmlelement, "value", [],
[{xmlcdata, "http://jabber.org/protocol/muc#roomconfig"}]}]},
?STRINGXFIELD("Room title", ?STRINGXFIELD("Room title",
"title", "muc#roomconfig_roomname",
Config#config.title), Config#config.title),
?BOOLXFIELD("Make room persistent", ?BOOLXFIELD("Make room persistent",
"persistent", "muc#roomconfig_persistentroom",
Config#config.persistent), Config#config.persistent),
?BOOLXFIELD("Make room public searchable", ?BOOLXFIELD("Make room public searchable",
"public", "muc#roomconfig_publicroom",
Config#config.public), Config#config.public),
?BOOLXFIELD("Make participants list public", ?BOOLXFIELD("Make participants list public",
"public_list", "public_list",
Config#config.public_list), Config#config.public_list),
?BOOLXFIELD("Make room password protected", ?BOOLXFIELD("Make room password protected",
"password_protected", "muc#roomconfig_passwordprotectedroom",
Config#config.password_protected), Config#config.password_protected),
?PRIVATEXFIELD("Password", ?PRIVATEXFIELD("Password",
"password", "muc#roomconfig_roomsecret",
case Config#config.password_protected of case Config#config.password_protected of
true -> Config#config.password; true -> Config#config.password;
false -> "" false -> ""
end), end),
?BOOLXFIELD("Make room semianonymous", {xmlelement, "field",
"anonymous", [{"type", "list-single"},
Config#config.anonymous), {"label", translate:translate(Lang, "Who may discover real JIDs?")},
{"var", "muc#roomconfig_whois"}],
[{xmlelement, "value", [], [{xmlcdata,
if Config#config.anonymous ->
"moderators";
true ->
"anyone"
end}]},
{xmlelement, "option", [{"label", "Moderators only"}],
[{xmlelement, "value", [], [{xmlcdata, "moderators"}]}]},
{xmlelement, "option", [{"label", "Anyone"}],
[{xmlelement, "value", [], [{xmlcdata, "anyone"}]}]}]},
?BOOLXFIELD("Make room members-only", ?BOOLXFIELD("Make room members-only",
"members_only", "muc#roomconfig_membersonly",
Config#config.members_only), Config#config.members_only),
?BOOLXFIELD("Make room moderated", ?BOOLXFIELD("Make room moderated",
"moderated", "muc#roomconfig_moderatedroom",
Config#config.moderated), Config#config.moderated),
?BOOLXFIELD("Default users as participants", ?BOOLXFIELD("Default users as participants",
"members_by_default", "members_by_default",
Config#config.members_by_default), Config#config.members_by_default),
?BOOLXFIELD("Allow users to change subject", ?BOOLXFIELD("Allow users to change subject",
"allow_change_subj", "muc#roomconfig_changesubject",
Config#config.allow_change_subj), Config#config.allow_change_subj),
?BOOLXFIELD("Allow users to send private messages", ?BOOLXFIELD("Allow users to send private messages",
"allow_private_messages", "allow_private_messages",
@ -2146,7 +2161,7 @@ get_config(Lang, StateData, From) ->
"allow_query_users", "allow_query_users",
Config#config.allow_query_users), Config#config.allow_query_users),
?BOOLXFIELD("Allow users to send invites", ?BOOLXFIELD("Allow users to send invites",
"allow_user_invites", "muc#roomconfig_allowinvites",
Config#config.allow_user_invites) Config#config.allow_user_invites)
] ++ ] ++
case mod_muc_log:check_access_log( case mod_muc_log:check_access_log(
@ -2154,7 +2169,7 @@ get_config(Lang, StateData, From) ->
allow -> allow ->
[?BOOLXFIELD( [?BOOLXFIELD(
"Enable logging", "Enable logging",
"logging", "muc#roomconfig_enablelogging",
Config#config.logging)]; Config#config.logging)];
_ -> [] _ -> []
end, end,
@ -2201,36 +2216,48 @@ set_config(XEl, StateData) ->
set_xoption([], Config) -> set_xoption([], Config) ->
Config; Config;
set_xoption([{"title", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_roomname", [Val]} | Opts], Config) ->
?SET_STRING_XOPT(title, Val); ?SET_STRING_XOPT(title, Val);
set_xoption([{"allow_change_subj", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_changesubject", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(allow_change_subj, Val); ?SET_BOOL_XOPT(allow_change_subj, Val);
set_xoption([{"allow_query_users", [Val]} | Opts], Config) -> set_xoption([{"allow_query_users", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(allow_query_users, Val); ?SET_BOOL_XOPT(allow_query_users, Val);
set_xoption([{"allow_private_messages", [Val]} | Opts], Config) -> set_xoption([{"allow_private_messages", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(allow_private_messages, Val); ?SET_BOOL_XOPT(allow_private_messages, Val);
set_xoption([{"public", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_publicroom", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(public, Val); ?SET_BOOL_XOPT(public, Val);
set_xoption([{"public_list", [Val]} | Opts], Config) -> set_xoption([{"public_list", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(public_list, Val); ?SET_BOOL_XOPT(public_list, Val);
set_xoption([{"persistent", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_persistentroom", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(persistent, Val); ?SET_BOOL_XOPT(persistent, Val);
set_xoption([{"moderated", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_moderatedroom", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(moderated, Val); ?SET_BOOL_XOPT(moderated, Val);
set_xoption([{"members_by_default", [Val]} | Opts], Config) -> set_xoption([{"members_by_default", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(members_by_default, Val); ?SET_BOOL_XOPT(members_by_default, Val);
set_xoption([{"members_only", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_membersonly", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(members_only, Val); ?SET_BOOL_XOPT(members_only, Val);
set_xoption([{"allow_user_invites", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_allowinvites", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(allow_user_invites, Val); ?SET_BOOL_XOPT(allow_user_invites, Val);
set_xoption([{"password_protected", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_passwordprotectedroom", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(password_protected, Val); ?SET_BOOL_XOPT(password_protected, Val);
set_xoption([{"password", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_roomsecret", [Val]} | Opts], Config) ->
?SET_STRING_XOPT(password, Val); ?SET_STRING_XOPT(password, Val);
set_xoption([{"anonymous", [Val]} | Opts], Config) -> set_xoption([{"anonymous", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(anonymous, Val); ?SET_BOOL_XOPT(anonymous, Val);
set_xoption([{"logging", [Val]} | Opts], Config) -> set_xoption([{"muc#roomconfig_whois", [Val]} | Opts], Config) ->
case Val of
"moderators" ->
?SET_BOOL_XOPT(anonymous, "1");
"anyone" ->
?SET_BOOL_XOPT(anonymous, "0");
_ ->
{error, ?ERR_BAD_REQUEST}
end;
set_xoption([{"muc#roomconfig_enablelogging", [Val]} | Opts], Config) ->
?SET_BOOL_XOPT(logging, Val); ?SET_BOOL_XOPT(logging, Val);
set_xoption([{"FORM_TYPE", _} | Opts], Config) ->
%% Ignore our FORM_TYPE
set_xoption(Opts, Config);
set_xoption([_ | _Opts], _Config) -> set_xoption([_ | _Opts], _Config) ->
{error, ?ERR_BAD_REQUEST}. {error, ?ERR_BAD_REQUEST}.