]> granicus.if.org Git - ejabberd/commitdiff
* src/mod_muc/mod_muc_room.erl: Fix to allow a server admin to add
authorBadlop <badlop@process-one.net>
Thu, 17 Jul 2008 17:32:11 +0000 (17:32 +0000)
committerBadlop <badlop@process-one.net>
Thu, 17 Jul 2008 17:32:11 +0000 (17:32 +0000)
himself as owner of a room (EJAB-687)

SVN Revision: 1460

ChangeLog
src/mod_muc/mod_muc_room.erl

index b097338c58fc5d15e7009539fb14b39f56c60c46..2fe69f5dcf42f0415eba7a05d26f2a7e1a87c4da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +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)
+
        * src/Makefile.in: ejabberctl doesn't use the erl found by the
        configure script (EJAB-676)
        * src/ejabberdctl.template: Likewise
index 9e6e13918cd65887f844554750064f39be3685b7..fdd26565a19f34875656b4247a7e5fef4d952e0a 100644 (file)
@@ -2157,11 +2157,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 ->
@@ -2212,11 +2214,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 ->
@@ -2262,143 +2266,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.