Файл: app/user/mail/index.php
Строк: 22
<?php
Core::only('user');
$smarty->header('Сообщения');
$listing[] = [
'title' => Lang::word('Написать сообщение'),
'url' => '/user/mail/send',
'icon' => 'mail2',
'div' => 'block'
];
$all = $db->query("SELECT e.id_user, IF(e.id_user = '$user[id]', e.id_profile, e.id_user) FROM users_mail AS e WHERE (e.id_profile = '$user[id]' OR e.id_user = '$user[id]') AND `delete` != '$user[id]' GROUP BY IF(e.id_user = '$user[id]', e.id_profile, e.id_user)")->rowCount();
$pages = new Pages($all, $config['pages']);
$query = $db->query("SELECT *, IF(`id_user` = '$user[id]', `id_profile`, `id_user`) AS contact FROM `users_mail` AS e ,
(SELECT MAX(id) AS id FROM `users_mail` WHERE (`id_profile` = '$user[id]' OR `id_user` = '$user[id]') AND `delete` != '$user[id]' GROUP BY IF(`id_user` = '$user[id]', `id_profile`, `id_user`))t
WHERE e.id = t.id AND (`id_profile` = '$user[id]' OR `id_user` = '$user[id]') AND `delete` != '$user[id]'
GROUP BY IF(`id_user` = '$user[id]', `id_profile`, `id_user`)
ORDER BY e.id DESC
LIMIT " . $start . ", " . $config['pages']);
while ($list = $query->fetch())
{
$posts[] = [
'url' => '/user/mail/chat?id=' . $list['contact'],
'div' => $list['read'] == 0 ? 'listing2' : 'listing',
'image' => User::photo($list['contact']),
'title' => User::login($list['contact'], false),
'post' => Filter::output($list['text']),
'time' => Core::time($list['time']),
];
}
if ($all == 0)
$posts[] = [
'title' => Lang::word('Нет сообщений.')
];
Core::show('error');
$smarty->assign([
'post' => $posts,
'listing' => $listing
]);
$smarty->display('listing.tpl');
$smarty->display('posts.tpl');
$pages->view('?');
$smarty->footer();