From c92c3a83da1b60d73a0b4ab88f0ee2cf729b2b5e Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Sat, 7 May 2016 19:27:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BB=D1=8F=20=D0=BF=D0=BB=D0=B0=D1=82?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D1=82=D0=BE=D1=87=D0=B5=D0=BA=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D1=8F=D1=82=D1=81=D1=8F?= =?UTF-8?q?=20=D1=82=D0=BE=D1=87=D0=BA=D0=B8=20=D1=82=D0=BE=D0=B3=D0=BE-?= =?UTF-8?q?=D0=B6=D0=B5=20=D1=82=D0=B8=D0=BF=D0=B0=20=D0=B2=20=D0=B1=D0=BB?= =?UTF-8?q?=D0=BE=D0=BA=D0=B5=20=D0=BF=D0=BE=D0=B1=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/PointController.php | 7 ++++++- models/Point.php | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/controllers/PointController.php b/controllers/PointController.php index 123399d..1aae319 100644 --- a/controllers/PointController.php +++ b/controllers/PointController.php @@ -81,8 +81,13 @@ class PointController extends Controller } $photoLinksRes = implode('; ', array_keys($photoLinksRes)); + $categoryId = 0; + if (array_search($point->categoryId, Category::$paidIds) !== FALSE) { + $categoryId = $point->categoryId; + } + $similarPoints = Point::model()->getAll(array('where' => '`status` = "published" AND categoryId = ' . $point->categoryId . ' AND `id` <> ' . $point->id . ' ORDER BY RAND() LIMIT 6;')); - $closestPoints = Point::model()->getClosestPoints($pointId); + $closestPoints = Point::model()->getClosestPoints($pointId, $categoryId); $randomPoint = Point::model()->getRandom(); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = Helper::replaceLinks($randomPoint->description); diff --git a/models/Point.php b/models/Point.php index 54f038b..6b6f0e6 100644 --- a/models/Point.php +++ b/models/Point.php @@ -47,7 +47,7 @@ class Point extends Model return $this->getByPK($pointId); } - public function getClosestPoints($pointId) + public function getClosestPoints($pointId, $categoryNot = 0) { $degrees = 1; @@ -64,6 +64,8 @@ class Point extends Model WHERE `status` = "published" AND + `categoryId` != ' . $categoryNot . ' + AND `lat` BETWEEN :minLat AND :maxLat AND `lng` BETWEEN :minLng AND :maxLng