'Change room affiliation.'

def setAffiliation(self, room, jid=None, nick=None, affiliation='member', ifrom=None):

    if (affiliation not in ('outcast', 'member', 'admin', 'owner', 'none')):
        raise TypeError
    query = ET.Element('{http://jabber.org/protocol/muc#admin}query')
    if (nick is not None):
        item = ET.Element('{http://jabber.org/protocol/muc#admin}item', {'affiliation': affiliation, 'nick': nick})
    else:
        item = ET.Element('{http://jabber.org/protocol/muc#admin}item', {'affiliation': affiliation, 'jid': jid})
    query.append(item)
    iq = self.xmpp.makeIqSet(query)
    iq['to'] = room
    iq['from'] = ifrom
    try:
        result = iq.send()
    except IqError:
        return False
    except IqTimeout:
        return False
    return True
