diff --git a/controllers/IndexController.php b/controllers/IndexController.php index 6c9839a..aff3986 100644 --- a/controllers/IndexController.php +++ b/controllers/IndexController.php @@ -43,6 +43,7 @@ class IndexController extends Controller self::addScript('//ulogin.ru/js/ulogin.js'); $category = Category::model()->getAll(array('order' => 'ord ASC')); + $categoryArray = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true)); $routes = array(); $favorites = array(); @@ -60,11 +61,6 @@ class IndexController extends Controller self::addVar('pointLat', (isset($_GET['lat'])?floatval($_GET['lat']):0)); self::addVar('pointLng', (isset($_GET['lng'])?floatval($_GET['lng']):0)); - $categoryArray = array(); - foreach ($category as $cat) { - $categoryArray[] = $cat->getValues(); - } - $og = array(); if (isset($_GET['point']) && $_GET['point'] && is_numeric($_GET['point'])) { $id = (int) $_GET['point']; @@ -98,14 +94,6 @@ class IndexController extends Controller )); } - static function actionUser() - { - App::error404(); - $routes = Route::model()->getByAuthor(App::$user->id); - - var_dump($routes); - } - static function actionLogout() { App::userLogout(); diff --git a/controllers/JsonController.php b/controllers/JsonController.php index abbfdf1..1f22e97 100644 --- a/controllers/JsonController.php +++ b/controllers/JsonController.php @@ -225,7 +225,7 @@ class JsonController extends Controller $_POST['description'] = strip_tags($_POST['description']); } - if (!( isset($_POST['name']) && $_POST['name'] && strlen($_POST['name']) > 5 )) { + if (!( isset($_POST['name']) && $_POST['name'] && strlen($_POST['name']) >= 5 )) { $errors[1] = 'Неверное название точки'; } diff --git a/models/Category.php b/models/Category.php index a0ca786..56e84ad 100644 --- a/models/Category.php +++ b/models/Category.php @@ -3,6 +3,7 @@ class Category extends Model { private static $categories = NULL; + private static $paidIds = array(24,25); function __construct($fromArray = array()) { @@ -25,4 +26,18 @@ class Category extends Model return (isset(self::$categories[$id])) ? self::$categories[$id]['icon'] : NULL; } + public function getCategoriesForChoise() + { + if (App::$user && App::$user->isAdmin == 1) { + return $this->getAll(array('order' => 'ord ASC', 'asArray' => true)); + } else { + return $this->getAll(array('where' => '`id` NOT IN ('. implode(',', $this->paidIds).')', 'order' => 'ord ASC', 'asArray' => true)); + } + } + + public static function isPaidCategory($id) + { + return array_search($id, self::$paidIds) !== FALSE; + } + } diff --git a/models/Point.php b/models/Point.php index 81ce1ae..346d198 100644 --- a/models/Point.php +++ b/models/Point.php @@ -146,4 +146,9 @@ class Point extends Model return self::statusModeration; } } + + public function isPaid() + { + return Category::isPaidCategory($this->categoryId); + } } diff --git a/public/ico/color b/public/ico/color new file mode 100644 index 0000000..d73c924 --- /dev/null +++ b/public/ico/color @@ -0,0 +1 @@ +ff7112 diff --git a/public/ico/hotel_c.png b/public/ico/hotel_c.png new file mode 100644 index 0000000..15c166c Binary files /dev/null and b/public/ico/hotel_c.png differ diff --git a/public/ico/restaurant_c.png b/public/ico/restaurant_c.png new file mode 100644 index 0000000..5a0f392 Binary files /dev/null and b/public/ico/restaurant_c.png differ diff --git a/public/js/app.js b/public/js/app.js index 7e4f27d..79bacf2 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -173,8 +173,9 @@ function showRandomPoint() runner = 0; for (var key in points) { - if (runner++ >= roundIndex) - return showInfo(key); + if (runner++ >= roundIndex) { + return showInfo(key); + } } } diff --git a/views/indexTemplate.php b/views/indexTemplate.php index d7026af..1b1c9d5 100644 --- a/views/indexTemplate.php +++ b/views/indexTemplate.php @@ -136,7 +136,7 @@ if (App::$user) { - $categories), true) : '' ?> + Category::model()->getCategoriesForChoise()), true) : '' ?> $categories), true) ?> diff --git a/views/modals/addPoint.php b/views/modals/addPoint.php index 7b1c22b..c1fede5 100644 --- a/views/modals/addPoint.php +++ b/views/modals/addPoint.php @@ -42,7 +42,7 @@