Нормальная реализация избранного

This commit is contained in:
Krivchikov Dmitry 2014-09-28 20:17:22 +04:00
parent 7a762de04d
commit 28d10be26f
3 changed files with 15 additions and 12 deletions

View File

@ -154,7 +154,6 @@ abstract class Model
$sql .= isset($params['where'])&&$params['where'] ? ' WHERE ' . $params['where'] : '';
$sql .= isset($params['order'])&&$params['order'] ? ' ORDER BY ' . $params['order'] : '';
$sql .= isset($params['limit'])&&$params['limit'] ? ' LIMIT ' . $params['limit'] : '';
$res = App::DB()->query($sql);
$ready = array();
@ -176,12 +175,10 @@ abstract class Model
*/
function getOne($whereField, $whereValue)
{
return array_shift(
$this->getAll(array(
return $this->getAll(array(
'where' => '`' . $whereField . '` = "' . $whereValue . '"',
'limit' => 1
))
);
));
}
/**

View File

@ -117,7 +117,6 @@ class IndexController extends Controller
{
$source = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
$uLoginUser = json_decode($source, true);
//var_dump($uLoginUser);die;
$uLoginUser['identity'] = md5($uLoginUser['uid'] . $uLoginUser['network'] . '=P');
$user = User::model()->getByUID($uLoginUser['identity']);

View File

@ -13,6 +13,7 @@
<?php if ($user): ?>
<div class="glyphicon glyphicon-map-marker _t" id="addPointButton" title="Добавить точку" onclick="activateAddPoint()"></div>
<div class="glyphicon glyphicon-star _c boxButtonFavorites" onclick="openBox('Favorites')" title="Хочу посетить"></div>
<div class="glyphicon glyphicon-cloud-download _c boxButtonRoutes" onclick="openBox('Routes')" title="Мои маршруты"></div>
<div class="glyphicon glyphicon-user _b boxButtonUser" onclick="openBox('User')" title="Профиль"></div>
<?php else:?>
@ -63,6 +64,18 @@
<?php endif; ?>
</div>
<?php if ($user): ?>
<div id="boxFavorites">
<h3>Хочу посетить</h3>
<div id="favorites">
<?php if ($favorites): ?>
<?php foreach ($favorites as $favorite) : ?>
<a onclick="showInfo(<?= $favorite->pointId ?>)" class="btn btn-link"><?= $favorite->point->name ?></a><br/>
<?php endforeach; ?>
<?php else: ?>
Ваши закладки пока пусты.
<?php endif; ?>
</div>
</div>
<div id="boxRoutes">
<h3>Мои маршруты</h3>
<div id="routes">
@ -80,12 +93,6 @@
<h3>Профиль</h3>
<a class="btn btn-default" type="button" href="/index/logout"><span class="glyphicon glyphicon-ban-circle"></span> Выйти</a>
<hr/>
<?php var_dump($favorite); ?>
<?php if (false && $favorites): ?>
<?php foreach ($favorites as $favorite) : ?>
<?= $favorite->point->name ?><br/>
<?php endforeach; ?>
<?php endif; ?>
</div>
</div>
<?= $user ? '' : self::renderPartial('modals/login.php', null, true) ?>