В ближайших и похожих точках выводятся только отмодерированные точки

This commit is contained in:
Krivchikov Dmitry 2015-08-08 23:56:31 +03:00
parent 1d67daa932
commit c70d82c57d
2 changed files with 28 additions and 34 deletions

View File

@ -80,8 +80,7 @@ class PageController extends Controller
self::$layout = 'layoutPage.php';
$pointId = (int) App::getParam('id');
if ($pointId)
{
if ($pointId) {
self::addScript('/js/jquery-2.1.0.min.js');
self::addScript('/js/jquery-ui-1.10.4.custom.min.js');
self::addScript('/js/bootstrap.min.js');
@ -110,8 +109,7 @@ class PageController extends Controller
$point = Point::model()->getByPK($pointId);
if ($point->id == NULL)
{
if ($point->id == NULL) {
App::error404();
}
@ -144,7 +142,7 @@ class PageController extends Controller
}
$photoLinksRes = implode('; ', array_keys($photoLinksRes));
$similarPoints = Point::model()->getAll(array('where' => 'categoryId = '.$point->categoryId.' AND `id` <> '.$point->id.' ORDER BY RAND() LIMIT 6;'));
$similarPoints = Point::model()->getAll(array('where' => '`moderate` = 1 AND categoryId = ' . $point->categoryId . ' AND `id` <> ' . $point->id . ' ORDER BY RAND() LIMIT 6;'));
$closestPoints = Point::model()->getClosestPoints($pointId);
$randomPoint = Point::model()->getRandom();
$randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8');
@ -164,8 +162,7 @@ class PageController extends Controller
'user' => App::$user,
'photoLinks' => $photoLinksRes,
));
} else
{
} else {
App::error404();
}
}
@ -175,8 +172,7 @@ class PageController extends Controller
self::$layout = 'layoutPage.php';
$articleId = (int) App::getParam('id');
if ($articleId)
{
if ($articleId) {
self::addScript('/js/jquery-2.1.0.min.js');
self::addScript('/js/jquery-ui-1.10.4.custom.min.js');
self::addScript('/js/bootstrap.min.js');
@ -192,8 +188,7 @@ class PageController extends Controller
$article = Article::model()->getByPK($articleId);
if ($article->id == NULL)
{
if ($article->id == NULL) {
App::error404();
}
@ -205,8 +200,7 @@ class PageController extends Controller
// 'og' => Helper::buildOG($point),
// 'user' => App::$user,
));
} else
{
} else {
App::error404();
}
}
@ -214,12 +208,10 @@ class PageController extends Controller
static function actionVkpoint()
{
$pointId = (int) App::getParam('id');
if (App::$user && App::$user->isAdmin == 1 && $pointId)
{
if (App::$user && App::$user->isAdmin == 1 && $pointId) {
$point = Point::model()->getByPK($pointId);
if ($point->id == NULL)
{
if ($point->id == NULL) {
App::error404();
}
@ -234,8 +226,7 @@ class PageController extends Controller
'point' => $point,
'photos' => $point->photos,
));
} else
{
} else {
App::error404();
}
}
@ -246,4 +237,5 @@ class PageController extends Controller
'point' => Point::model()->getRandom(),
));
}
}

View File

@ -55,6 +55,8 @@ class Point extends Model
SQRT(POW(`lat`-:lat,2)+POW(`lng`-:lng,2))
) AS `dist` FROM `' . $this->_tableName_ . '`
WHERE
`moderate` = 1
AND
`lat` BETWEEN :minLat AND :maxLat
AND
`lng` BETWEEN :minLng AND :maxLng