/**
  * Returns an array of moduleId and the their states (enabled, disabled, force enabled)
  * for given space id. If space id is 0 or empty, the default states will be returned.
  *
  * @param int $roomId
  * @return array State of Module Ids
  */
 public static function getStates($roomId = 0)
 {
     if (isset(self::$_states[$roomId])) {
         return self::$_states[$roomId];
     }
     $states = Yii::app()->cache->get(self::STATES_CACHE_ID_PREFIX . $roomId);
     if ($states === false) {
         $states = array();
         foreach (RoomApplicationModule::model()->findAllByAttributes(array('room_id' => $roomId)) as $roomModule) {
             $states[$roomModule->module_id] = $roomModule->state;
         }
         Yii::app()->cache->set(self::STATES_CACHE_ID_PREFIX . $roomId, $states);
     }
     self::$_states[$roomId] = $states;
     return self::$_states[$roomId];
 }
 /**
  * Uninstalls a Module
  */
 public function disableModule($moduleId)
 {
     // Not enabled globally
     if (!array_key_exists($moduleId, $this->getAvailableModules())) {
         return false;
     }
     // Already enabled module
     if (!$this->isModuleEnabled($moduleId)) {
         Yii::log("Room->disableModule(" . $moduleId . ") module is not enabled");
         return false;
     }
     // New Way: Handle it directly in module class
     $module = Yii::app()->moduleManager->getModule($moduleId);
     $module->disableRoomModule($this->getOwner());
     $roomModule = RoomApplicationModule::model()->findByAttributes(array('room_id' => $this->getOwner()->id, 'module_id' => $moduleId));
     if ($roomModule == null) {
         $roomModule = new RoomApplicationModule();
         $roomModule->room_id = $this->getOwner()->id;
         $roomModule->module_id = $moduleId;
     }
     $roomModule->state = RoomApplicationModule::STATE_DISABLED;
     $roomModule->save();
     return true;
 }