protected function getAllProperties() { $propertiesModel = new \User2property(); $userId = Yii::app()->user->getState('id'); $propertiesLinks = $propertiesModel->with('property')->findAllByAttributes(array('userId' => $userId)); //Delete deleted properties foreach ($propertiesLinks as $key => $link) { if ($link->property->getAttribute('isdeactivated') == 1) { unset($propertiesLinks[$key]); } } //Formating data foreach ($propertiesLinks as $key => $propertiLink) { $this->properties[$key] = $propertiLink->getAttributes(); $this->properties[$key]['property'] = $propertiLink->property->getAttributes(); $this->properties[$key]['property']['members'] = array(); $this->properties[$key]['property']['guests'] = array(); foreach ($propertiLink->property->user2properties as $index => $link) { if ($link->getAttribute('access') <= \UserAccessTable::BASIC_ACCESS) { $this->properties[$key]['property']['members'][$index] = $link->getAttributes(); } else { $this->properties[$key]['property']['guests'][$index] = $link->getAttributes(); } } $this->properties[$key]['property']['members_count'] = count($this->properties[$key]['property']['members']); $this->properties[$key]['property']['guests_count'] = count($this->properties[$key]['property']['guests']); $galleryModel = new Gallery(); $primaryImage = $galleryModel->with('file')->findByAttributes(array('propertyid' => $this->properties[$key]['property']['id']), array('order' => 't.index')); if ($primaryImage) { $this->properties[$key]['property']['minimage'] = basePath('propertyfile/') . $primaryImage->file->getAttribute('systempath') . '?propertyid=' . $this->properties[$key]['property']['id'] . "&thumb=true"; $this->properties[$key]['property']['image'] = basePath('propertyfile/') . $primaryImage->file->getAttribute('systempath') . '?propertyid=' . $this->properties[$key]['property']['id']; } else { $this->properties[$key]['property']['minimage'] = basePath('images/property-placeholder.png'); $this->properties[$key]['property']['image'] = basePath('images/property-placeholder.png'); } $this->properties[$key]['access_name'] = UserAccessTable::accessLevelToString($this->properties[$key]['access']); } }