From 89c53fe8815f77d71fb4ef1bd8e2e68e2f262662 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Tue, 26 May 2015 16:23:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=20=D0=9C=D0=9E=D0=94=D0=95?= =?UTF-8?q?=D0=A0=D0=90=D0=A6=D0=98=D0=98=20=D0=A2=D0=9E=D0=A7=D0=95=D0=9A?= =?UTF-8?q?.=20=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE:=20=D0=BE=D1=82=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D0=B8=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D0=BA=D0=B0,=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=D1=8B=D0=B5=20=D1=82=D0=BE=D1=87=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D1=8F=D1=8E=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BD=D0=B0=20=D0=BC=D0=BE=D0=B4=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8E,=20=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=BE=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=B8=D0=BB=D0=B8=20=D1=81=D0=BA=D1=80=D1=8B?= =?UTF-8?q?=D1=82=D1=8C=20=D1=82=D0=BE=D1=87=D0=BA=D1=83,=20=D0=B0=D0=B2?= =?UTF-8?q?=D1=82=D0=BE=D1=80=20=D0=B2=D0=B8=D0=B4=D0=B8=D1=82=20=D1=81?= =?UTF-8?q?=D0=B2=D0=BE=D0=B8=20=D0=BD=D0=B5=D0=BE=D0=BF=D1=83=D0=B1=D0=BB?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ground/controllers/IndexController.php | 2 +- ground/controllers/JsonController.php | 8 +++++++- ground/models/Point.php | 6 ++++++ ground/views/modals/addPoint.php | 2 +- public/ico/lock.png | Bin 0 -> 1051 bytes public/js/map.js | 23 +++++++++++++++++++++-- public/js/mapPoint.js | 2 +- 7 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 public/ico/lock.png 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 0000000000000000000000000000000000000000..85816054f072b56c7e308bde04583360b3030d5a GIT binary patch literal 1051 zcmV+$1mydPP)$=yT#bPlMi3AG^3(U>UO(N09 z^n^B1?Y&-)dcDrPVQ}}=D>4rrkjUi#u#b;veE7g`FJ4fu*U4tHBT4u<6GiFGW|Mit zpz!e{Y9@2-St6Gs|M)RCO_Lw*->2DZVi-oKbz@OPw7kBKn#s`E+v9zqKuOmr={oNV z1sZ#MsF@7Q>+3j<6IvUg3AnC{v9ba{d2J25QbE^sbX~`;R4A{l0bs1G4CrHAMEcky zvRMGm4-Z*dT0&7202D>xkHf=jbEckwV0hrc>!=aq3&$5H5K05JS`C28%a;RV{s=zL z=kwDO;SZ;${p;JSt7GThUR|Z6>(f64{`jZW;`q%Q0CEo>GM`S*ZVQIR=k0BNdHx)L zE7#?lr%(T10$)9P#6`8*zn=Lia2kzk_w(sAk}M<1@<957bN@2|Ns>4(mj}jAc6T}1 z-5nS|FPD)dX?g_W@i^6uje+s@(Gl&Vqk-}2#s=|te0l^@sT3zWJJdEe2acxycmmWm zH#ynaA(cu^PlTGLp=lZi&z|w;yLWv3L6F%^J0d0*orxWbC z*Zb|;&%;Rg!0(E;^!C|LV7NUW7lN27bdnMze)W^^fqyH&+oCxh(8$kx7*P!&k@7MD z_}{!81w1r?Atcg*#DNg*JptN^0v?G#fP^NRSC4l@>Mx^!M!R4 literal 0 HcmV?d00001 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! */