diff --git a/ground/controllers/IndexController.php b/ground/controllers/IndexController.php index e6a395b..578b9d6 100644 --- a/ground/controllers/IndexController.php +++ b/ground/controllers/IndexController.php @@ -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']); diff --git a/ground/controllers/JsonController.php b/ground/controllers/JsonController.php index 8a991d4..93431c9 100644 --- a/ground/controllers/JsonController.php +++ b/ground/controllers/JsonController.php @@ -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( diff --git a/ground/models/Point.php b/ground/models/Point.php index 4184609..cf26597 100644 --- a/ground/models/Point.php +++ b/ground/models/Point.php @@ -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)); + } } diff --git a/ground/views/modals/addPoint.php b/ground/views/modals/addPoint.php index b61cc7a..5817901 100644 --- a/ground/views/modals/addPoint.php +++ b/ground/views/modals/addPoint.php @@ -23,7 +23,7 @@
diff --git a/public/ico/lock.png b/public/ico/lock.png new file mode 100644 index 0000000..8581605 Binary files /dev/null and b/public/ico/lock.png differ diff --git a/public/js/map.js b/public/js/map.js index 7326189..b2a7291 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -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 = ''; } - description = '
' + '

' + data.name + '

' + photos; + onModerate = ''; + if (data.moderate != 'show') { + onModerate = 'На модерации: '; + } + + description = '
' + '

' + onModerate + data.name + '

' + photos; description += data.descriptionHtml; description += '
'; description += '
'; diff --git a/public/js/mapPoint.js b/public/js/mapPoint.js index 51d8138..a45867f 100644 --- a/public/js/mapPoint.js +++ b/public/js/mapPoint.js @@ -1,4 +1,4 @@ -/* +/* * Let's GO! */