/**
  * Before deletion of a Room
  */
 protected function beforeDelete()
 {
     foreach (RoomSetting::model()->findAllByAttributes(array('room_id' => $this->id)) as $roomSetting) {
         $roomSetting->delete();
     }
     // Disable all enabled modules
     foreach ($this->getAvailableModules() as $moduleId => $module) {
         if ($this->isModuleEnabled($moduleId)) {
             $this->disableModule($moduleId);
         }
     }
     Yii::app()->search->delete($this);
     $this->getProfileImage()->delete();
     // Remove all Follwers
     //UserFollow::model()->deleteAllByAttributes(array('object_id' => $this->id, 'object_model' => 'Room'));
     //Delete all memberships:
     //First select, then delete - done to make sure that RoomsMembership::beforeDelete() is triggered
     $roomMemberships = RoomMembership::model()->findAllByAttributes(array('room_id' => $this->id));
     foreach ($roomMemberships as $roomMembership) {
         $roomMembership->delete();
     }
     UserInvite::model()->deleteAllByAttributes(array('room_invite_id' => $this->id));
     // Delete all content objects of this room
     foreach (Content::model()->findAllByAttributes(array('room_id' => $this->id)) as $content) {
         $content->delete();
     }
     // When this room is used in a group as default room, delete the link
     foreach (Group::model()->findAllByAttributes(array('room_id' => $this->id)) as $group) {
         $group->room_id = "";
         $group->save();
     }
     Wall::model()->deleteAllByAttributes(array('id' => $this->wall_id));
     return parent::beforeDelete();
 }
 /**
  * Sets an SpaceSetting
  *
  * @param String $name
  * @param String $value
  * @param String $moduleId
  */
 public function setSetting($name, $value, $moduleId = "")
 {
     RoomSetting::Set($this->getOwner()->id, $name, $value, $moduleId);
 }