25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

* src/mod_muc/mod_muc_room.erl: Fix to allow a server admin to add

himself as owner of a room (EJAB-687)

SVN Revision: 1460
This commit is contained in:
Badlop 2008-07-17 17:32:11 +00:00
parent e361835cea
commit 1b7a36bf64
2 changed files with 51 additions and 37 deletions

View File

@ -1,3 +1,8 @@
2008-07-17 Badlop <badlop@process-one.net>
* src/mod_muc/mod_muc_room.erl: Fix to allow a server admin to add
himself as owner of a room (EJAB-687)
2008-07-17 Christophe Romain <christophe.romain@process-one.net>
* src/web/Makefile.in: use -DSSL39 if compiling with R12

View File

@ -886,9 +886,8 @@ process_groupchat_message(From, {xmlelement, "message", Attrs, _Els} = Packet,
%% Check the mod_muc option access_message_nonparticipant and wether this JID
%% is allowed or denied
is_user_allowed_message_nonparticipant(JID, StateData) ->
{_AccessRoute, _AccessCreate, AccessAdmin, _AccessPersistent} = StateData#state.access,
case acl:match_rule(StateData#state.server_host, AccessAdmin, JID) of
allow ->
case get_service_affiliation(JID, StateData) of
owner ->
true;
_ -> false
end.
@ -2187,11 +2186,13 @@ find_changed_items(UJID, UAffiliation, URole,
[StrAffiliation]),
{error, ?ERRT_NOT_ACCEPTABLE(Lang, ErrText1)};
SAffiliation ->
ServiceAf = get_service_affiliation(JID, StateData),
CanChangeRA =
case can_change_ra(
UAffiliation, URole,
TAffiliation, TRole,
affiliation, SAffiliation) of
affiliation, SAffiliation,
ServiceAf) of
nothing ->
nothing;
true ->
@ -2242,11 +2243,13 @@ find_changed_items(UJID, UAffiliation, URole,
[StrRole]),
{error, ?ERRT_BAD_REQUEST(Lang, ErrText1)};
SRole ->
ServiceAf = get_service_affiliation(JID, StateData),
CanChangeRA =
case can_change_ra(
UAffiliation, URole,
TAffiliation, TRole,
role, SRole) of
role, SRole,
ServiceAf) of
nothing ->
nothing;
true ->
@ -2292,143 +2295,149 @@ find_changed_items(_UJID, _UAffiliation, _URole, _Items,
{error, ?ERR_BAD_REQUEST}.
can_change_ra(_FAffiliation, _FRole,
owner, _TRole,
affiliation, owner, owner) ->
%% A room owner tries to add as persistent owner a
%% participant that is already owner because he is MUC admin
true;
can_change_ra(_FAffiliation, _FRole,
TAffiliation, _TRole,
affiliation, Value)
affiliation, Value, _ServiceAf)
when (TAffiliation == Value) ->
nothing;
can_change_ra(_FAffiliation, _FRole,
_TAffiliation, TRole,
role, Value)
role, Value, _ServiceAf)
when (TRole == Value) ->
nothing;
can_change_ra(FAffiliation, _FRole,
outcast, _TRole,
affiliation, none)
affiliation, none, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(FAffiliation, _FRole,
outcast, _TRole,
affiliation, member)
affiliation, member, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(owner, _FRole,
outcast, _TRole,
affiliation, admin) ->
affiliation, admin, _ServiceAf) ->
true;
can_change_ra(owner, _FRole,
outcast, _TRole,
affiliation, owner) ->
affiliation, owner, _ServiceAf) ->
true;
can_change_ra(FAffiliation, _FRole,
none, _TRole,
affiliation, outcast)
affiliation, outcast, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(FAffiliation, _FRole,
none, _TRole,
affiliation, member)
affiliation, member, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(owner, _FRole,
none, _TRole,
affiliation, admin) ->
affiliation, admin, _ServiceAf) ->
true;
can_change_ra(owner, _FRole,
none, _TRole,
affiliation, owner) ->
affiliation, owner, _ServiceAf) ->
true;
can_change_ra(FAffiliation, _FRole,
member, _TRole,
affiliation, outcast)
affiliation, outcast, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(FAffiliation, _FRole,
member, _TRole,
affiliation, none)
affiliation, none, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(owner, _FRole,
member, _TRole,
affiliation, admin) ->
affiliation, admin, _ServiceAf) ->
true;
can_change_ra(owner, _FRole,
member, _TRole,
affiliation, owner) ->
affiliation, owner, _ServiceAf) ->
true;
can_change_ra(owner, _FRole,
admin, _TRole,
affiliation, _Affiliation) ->
affiliation, _Affiliation, _ServiceAf) ->
true;
can_change_ra(owner, _FRole,
owner, _TRole,
affiliation, _Affiliation) ->
affiliation, _Affiliation, _ServiceAf) ->
check_owner;
can_change_ra(_FAffiliation, _FRole,
_TAffiliation, _TRole,
affiliation, _Value) ->
affiliation, _Value, _ServiceAf) ->
false;
can_change_ra(_FAffiliation, moderator,
_TAffiliation, visitor,
role, none) ->
role, none, _ServiceAf) ->
true;
can_change_ra(_FAffiliation, moderator,
_TAffiliation, visitor,
role, participant) ->
role, participant, _ServiceAf) ->
true;
can_change_ra(FAffiliation, _FRole,
_TAffiliation, visitor,
role, moderator)
role, moderator, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(_FAffiliation, moderator,
_TAffiliation, participant,
role, none) ->
role, none, _ServiceAf) ->
true;
can_change_ra(_FAffiliation, moderator,
_TAffiliation, participant,
role, visitor) ->
role, visitor, _ServiceAf) ->
true;
can_change_ra(FAffiliation, _FRole,
_TAffiliation, participant,
role, moderator)
role, moderator, _ServiceAf)
when (FAffiliation == owner) or (FAffiliation == admin) ->
true;
can_change_ra(_FAffiliation, _FRole,
owner, moderator,
role, visitor) ->
role, visitor, _ServiceAf) ->
false;
can_change_ra(owner, _FRole,
_TAffiliation, moderator,
role, visitor) ->
role, visitor, _ServiceAf) ->
true;
can_change_ra(_FAffiliation, _FRole,
admin, moderator,
role, visitor) ->
role, visitor, _ServiceAf) ->
false;
can_change_ra(admin, _FRole,
_TAffiliation, moderator,
role, visitor) ->
role, visitor, _ServiceAf) ->
true;
can_change_ra(_FAffiliation, _FRole,
owner, moderator,
role, participant) ->
role, participant, _ServiceAf) ->
false;
can_change_ra(owner, _FRole,
_TAffiliation, moderator,
role, participant) ->
role, participant, _ServiceAf) ->
true;
can_change_ra(_FAffiliation, _FRole,
admin, moderator,
role, participant) ->
role, participant, _ServiceAf) ->
false;
can_change_ra(admin, _FRole,
_TAffiliation, moderator,
role, participant) ->
role, participant, _ServiceAf) ->
true;
can_change_ra(_FAffiliation, _FRole,
_TAffiliation, _TRole,
role, _Value) ->
role, _Value, _ServiceAf) ->
false.