Первый вариант МОДЕРАЦИИ ТОЧЕК. Готово: отдельная иконка, добавляемые точки отправляются на модерацию, можно опубликовать или скрыть точку, автор видит свои неопубликованные точки
This commit is contained in:
parent
6ecf6ae31e
commit
89c53fe881
|
|
@ -61,7 +61,7 @@ class IndexController extends Controller
|
|||
|
||||
self::addVar('isAdmin', (int) (App::$user && App::$user->isAdmin == 1));
|
||||
|
||||
$res = App::DB()->query("SELECT COUNT(`id`) pointsCount FROM `points`")->fetch(PDO::FETCH_ASSOC);
|
||||
$res = App::DB()->query("SELECT COUNT(`id`) pointsCount FROM `points` where `moderate` = 1")->fetch(PDO::FETCH_ASSOC);
|
||||
App::setConfig('title', $res['pointsCount'] . ' или даже больше поводов не сидеть дома');
|
||||
self::addVar('pointsCount', $res['pointsCount']);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ class JsonController extends Controller
|
|||
*/
|
||||
static function actionPoints()
|
||||
{
|
||||
$points = Point::model()->getAll();
|
||||
if (App::$user && App::$user->isAdmin == 1) {
|
||||
$points = Point::model()->getAll();
|
||||
} else {
|
||||
$points = Point::model()->getAllPublished();
|
||||
}
|
||||
|
||||
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true));
|
||||
|
||||
$result = array();
|
||||
|
|
@ -22,6 +27,7 @@ class JsonController extends Controller
|
|||
$result[$id]['lng'] = $point->lng;
|
||||
$result[$id]['categoryId'] = $point->categoryId;
|
||||
$result[$id]['categoryIcon'] = $categories[$point->categoryId]['icon'];
|
||||
$result[$id]['moderate'] = $point->moderate ? 'show' : 'hide';
|
||||
}
|
||||
|
||||
self::renderPartial('json.php', array(
|
||||
|
|
|
|||
|
|
@ -88,5 +88,11 @@ class Point extends Model
|
|||
{
|
||||
return $this->getAll(array('where' => "`name` LIKE '%$search%' OR `description` LIKE '%$search%'", 'limit' => 20));
|
||||
}
|
||||
|
||||
public function getAllPublished()
|
||||
{
|
||||
$userId = App::$user ? App::$user->id : 0;
|
||||
return $this->getAll(array('where' => "`moderate` = 1 OR `author` = ".$userId));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<div class="form-group extraImage asLink">
|
||||
<label class="control-label" for="imgs">Файлы и ссылки на изображения</label>
|
||||
<label class="control-label error" for="imgs">(Что-то не так с изображениями!)</label>
|
||||
<span class="btn btn-sm add button" onclick="addNewImage()" title="Добавить ещё одно изображение"><span class="glyphicon glyphicon-plus"></span></span>
|
||||
<span class="btn btn-sm add button" onclick="addNewImage()" title="Добавить ещё одно изображение"><span class="glyphicon glyphicon-plus"></span> <span class="glyphicon glyphicon-camera"></span></span>
|
||||
</div>
|
||||
<div id="imgsContainer">
|
||||
</div>
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
|
|
@ -22,6 +22,13 @@ categories.im = L.icon({
|
|||
popupAnchor: [0, 1]
|
||||
});
|
||||
|
||||
categories.lock = L.icon({
|
||||
iconUrl: '/ico/lock.png',
|
||||
iconSize: [32, 37],
|
||||
iconAnchor: [16, 37],
|
||||
popupAnchor: [0, 1]
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
|
@ -134,10 +141,17 @@ function init(lat, lng) {
|
|||
*/
|
||||
function constructPoint(data)
|
||||
{
|
||||
console.log(data);
|
||||
id = data['id'];
|
||||
|
||||
icon = categories[data['categoryId']];
|
||||
if (data['moderate'] != 'show') {
|
||||
icon = categories.lock;
|
||||
data['name'] = 'На модерации: '+data['name'];
|
||||
}
|
||||
|
||||
points[id] = L.marker(
|
||||
[data['lat'], data['lng']], {icon: categories[data['categoryId']], title: data['name'], id: id, categoryId: data['categoryId']}
|
||||
[data['lat'], data['lng']], {icon: icon, title: data['name'], id: id, categoryId: data['categoryId']}
|
||||
).on('click', function (e) {
|
||||
showInfo(e.target.options.id);
|
||||
});
|
||||
|
|
@ -214,7 +228,12 @@ function showInfo(id)
|
|||
photos = '<img src="' + data.img + '" onclick="showImage(\'' + id + '\')" />';
|
||||
}
|
||||
|
||||
description = '<div class="infoCard">' + '<h3>' + data.name + '</h3>' + photos;
|
||||
onModerate = '';
|
||||
if (data.moderate != 'show') {
|
||||
onModerate = 'На модерации: ';
|
||||
}
|
||||
|
||||
description = '<div class="infoCard">' + '<h3>' + onModerate + data.name + '</h3>' + photos;
|
||||
description += data.descriptionHtml;
|
||||
description += '</div><div class="clear"></div>';
|
||||
description += '<div class="btn-group control">';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Let's GO!
|
||||
*/
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue