Файл: app/user/notification/index.php
Строк: 31
<?php
Core::only('user');
$smarty->header('Уведомления');
$all = $db->query("SELECT * FROM `users_notification` WHERE `id_profile` = '" . $user['id'] . "' ")->rowCount();
$pages = new Pages($all, $config['pages']);
$query = $db->query("SELECT * FROM `users_notification` WHERE `id_profile` = '" . $user['id'] . "' ORDER BY`time` DESC LIMIT " . $start . ", " . $config['pages']);
while ($list = $query->fetch())
{
if ($list['type'] == 'minichat')
{
$post = $db->query("SELECT * FROM `minichat` WHERE `id` = '" . $list['id_post']."' LIMIT 1")->fetch();
$title = User::login($list['id_user'], false) . ' ответил Вам в мини-чате';
$url = '/minichat/';
}
if ($list['type'] == 'news_comments')
{
$post = $db->query("SELECT * FROM `news_comments` WHERE `id` = '" . $list['id_post']."' LIMIT 1")->fetch();
$news = $db->query("SELECT `title`, `id` FROM `news` WHERE `id` = '" . $post['id_news']."' LIMIT 1")->fetch();
$title = User::login($list['id_user'], false) . ' ответил Вам в новостях';
$url = '/news/read?id=' . $news['id'];
}
if (isset($post['id']))
{
$posts[] = [
'url' => $url,
'image' => User::photo($list['id_user']),
'title' => $title,
'post' => Filter::output($post['text']),
'time' => Core::time($list['time']),
];
}
else
{
$posts[] = [
'title' => Lang::word('Сообщение уже удалено.'),
];
$db->query("DELETE FROM `users_notification` WHERE `id` = '" . $list['id']."' LIMIT 1");
}
$db->query("UPDATE `users_notification` SET `read` = '1' WHERE `id` = '" . $list['id']."' LIMIT 1");
}
if ($all == 0)
$posts[] = [
'title' => Lang::word('Нет уведомлений.')
];
$smarty->assign([
'post' => $posts
]);
$smarty->display('posts.tpl');
$pages->view('?');
$smarty->footer();