コード例 #1
0
 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']);
     }
 }
コード例 #2
0
 public function get_index()
 {
     $galleries = Gallery::with('organisations')->order_by('sort_order', 'asc')->get();
     return View::make('user.galleries.galleries')->with('galleries', $galleries);
 }
コード例 #3
0
 protected function getImages()
 {
     $model = new Gallery();
     $property_id = Yii::app()->user->getState('property_id');
     $images = $model->with('file')->findAllByAttributes(array('propertyid' => $property_id), array('order' => 't.index'));
     $resultData = array();
     foreach ($images as $key => $image) {
         $resultData[$key] = (array) $image->getAttributes();
         $resultData[$key]['file'] = (array) $image->file->getAttributes();
     }
     return $resultData;
 }