Merge 0.9->0.10
[prosody.git] / plugins / muc / mod_muc.lua
index cb967c908a0f7b369ceee91183d642c498cbaf4a..c514bafd375b36e810ba3d9887e460f19984abee 100644 (file)
@@ -52,8 +52,9 @@ local function is_admin(jid)
        return um_is_admin(jid, module.host);
 end
 
-local _set_affiliation = muc_new_room.room_mt.set_affiliation;
-local _get_affiliation = muc_new_room.room_mt.get_affiliation;
+room_mt = muclib.room_mt; -- Yes, global.
+local _set_affiliation = room_mt.set_affiliation;
+local _get_affiliation = room_mt.get_affiliation;
 function muclib.room_mt:get_affiliation(jid)
        if is_admin(jid) then return "owner"; end
        return _get_affiliation(self, jid);
@@ -164,7 +165,7 @@ function stanza_handler(event)
                        return true;
                end
                if not(restrict_room_creation) or
-                 (restrict_room_creation == "admin" and is_admin(stanza.attr.from)) or
+                 is_admin(stanza.attr.from) or
                  (restrict_room_creation == "local" and select(2, jid_split(stanza.attr.from)) == module.host:gsub("^[^%.]+%.", "")) then
                        room = create_room(bare);
                end
@@ -172,6 +173,7 @@ function stanza_handler(event)
        if room then
                room:handle_stanza(origin, stanza);
                if not next(room._occupants) and not persistent_rooms[room.jid] then -- empty, non-persistent room
+                       module:fire_event("muc-room-destroyed", { room = room });
                        rooms[bare] = nil; -- discard room
                end
        else