public function actionDelete($id) { if (Yii::app()->user->isGuest) { throw new CHttpException(403, 'You are not authorized.'); } $wishlist = PropertyWishlistApi::getWishlistUserOnProperty($id, Yii::app()->user->id); if ($wishlist) { if ($wishlist->user_id !== Yii::app()->user->id) { throw new CHttpException(403, 'You are not authorized.'); } if (PropertyWishlist::model()->deleteByPk($wishlist->id)) { Yii::app()->user->setFlash('success', 'The property was removed from your wishlist.'); } else { Yii::app()->user->setFlash('error', 'The property could not be removed from your wishlist. Please contact the admin.'); } } else { Yii::app()->user->setFlash('error', 'The property could not be removed from your wishlist. Please contact the admin.'); } $this->redirect('/wishlists'); }
public function actionView($id) { Yii::beginProfile('property_view'); $session = Yii::app()->session; $property = PropertyApi::getPropertyById($id); if (!$property) { throw new CHttpException(404, 'The requested page does not exist.'); } if (!$property->furnished) { $property->furnished = '-'; } if (!$property->floor_number) { $property->floor_number = '-'; } if (!$property->total_floors) { $property->total_floors = '-'; } if (!$property->facing) { $property->facing = '-'; } $recentlyViewed = UserApi::getUserProfileDetails($property->recently_viewed); $propertyAgentInfo = AgentProfileApi::getAgentDetails($property->user_id); $propertyUser = ""; $propertyAgent = ""; $propertyBuilder = ""; $propertyBuilderInfo = ""; $propertySpecialist = ""; $propertySpecialistInfo = ""; $propertyRating = ""; $propertyRating = PropertyRatingApi::getRating($id); if ($propertyAgentInfo) { $propertyAgent = UserApi::getUserProfileDetails($propertyAgentInfo->user_id); } else { $propertyBuilderInfo = BuilderProfileApi::getBuilderDetails($property->user_id); if ($propertyBuilderInfo) { $propertyBuilder = UserApi::getUserProfileDetails($propertyBuilderInfo->user_id); } else { $propertySpecialistInfo = SpecialistProfileApi::getSpecialistDetails($property->user_id); if ($propertySpecialistInfo) { $propertySpecialist = UserApi::getUserProfileDetails($propertySpecialistInfo->user_id); } else { $propertyUser = UserApi::getUser($property->user_id); } } } $propertySimilar = PropertyApi::getSimilarProperties($property, 3, $id); $propertySimilarAddress = ""; $propertySimilarUser = ""; if ($propertySimilar) { foreach ($propertySimilar as $similar) { $propertySimilarAddress[$similar->id] = PropertyApi::getLocation($similar->id); $propertySimilarUser[$similar->id] = UserApi::getUserProfileDetails($similar->user_id); } } $recentlyViewedIds[] = ''; $recentlyViewedIds_total = $session['properties']; if ($recentlyViewedIds_total) { $re_array = array_reverse($recentlyViewedIds_total); $i = 0; foreach ($re_array as $re) { $recentlyViewedIds = $re; $i++; if ($i > 2) { break; } } } $property_ids[] = $recentlyViewedIds; $property_ids[] = $id; $session['properties'] = array_unique($property_ids); $propertyRecentlyViewed = ""; $propertyRecentlyViewedAddress = ""; $propertyRecentlyViewedUser = ""; if ($recentlyViewedIds) { foreach ($recentlyViewedIds as $recent) { $modelProperty = PropertyApi::getPropertyById($recent); if ($modelProperty) { $propertyRecentlyViewed[] = $modelProperty; $propertyRecentlyViewedAddress[] = PropertyApi::getLocation($recent); $propertyRecentlyViewedUser[] = UserApi::getUserProfileDetails($modelProperty->user_id); } } } $propertyImages = PropertyImagesApi::getAllImages($property->id); $propertyType = PropertyTypesApi::getPropertyTypeById($property->property_type_id); $transactionType = PropertyTransactionTypesApi::getTransactionTypeById($property->transaction_type_id); $ownershipType = OwnershipTypesApi::getOwnershipTypeById($property->ownership_type_id); $propertyAge = PropertyAgeOfConstructionApi::getpropertyAgeById($property->age_of_construction); $propertyAmenities = PropertyAmenitiesApi::getAmenitiesForProperty($property->id); $propertyAddress = PropertyApi::getLocation($property->id); $propertyRating = PropertyRatingApi::getRating($property->id); $propertyWishlist = PropertyWishlistApi::getWishlistUserOnProperty($property->id, Yii::app()->user->id); $this->render('view', array('property' => $property, 'recentlyViewed' => $recentlyViewed, 'propertyAgentInfo' => $propertyAgentInfo, 'propertyBuilderInfo' => $propertyBuilderInfo, 'propertySpecialistInfo' => $propertySpecialistInfo, 'propertyUser' => $propertyUser, 'propertyAgent' => $propertyAgent, 'propertyBuilder' => $propertyBuilder, 'propertySpecialist' => $propertySpecialist, 'propertySimilar' => $propertySimilar, 'propertySimilarAddress' => $propertySimilarAddress, 'propertySimilarUser' => $propertySimilarUser, 'propertyRecentlyViewed' => $propertyRecentlyViewed, 'propertyRecentlyViewedAddress' => $propertyRecentlyViewedAddress, 'propertyRecentlyViewedUser' => $propertyRecentlyViewedUser, 'propertyImages' => $propertyImages, 'propertyType' => $propertyType, 'propertyAddress' => $propertyAddress, 'transactionType' => $transactionType, 'ownershipType' => $ownershipType, 'propertyAge' => $propertyAge, 'propertyAmenities' => $propertyAmenities, 'propertyRating' => $propertyRating, 'propertyWishlist' => $propertyWishlist)); Yii::endProfile('property_view'); }