Файл: Arhmobi_esdcms/sys/widgets/n_forum/index.php
Строк: 53
<?php
defined('DCMS') or die;
global $user;
$db = DB::me();
if (false === ($new_posts = cache_counters::get('forum.new_posts.' . $user->group))) {
$res = $db->prepare("SELECT COUNT(*)
FROM `forum_themes` AS `th`
INNER JOIN `forum_topics` AS `tp` ON `tp`.`id` = `th`.`id_topic` AND `tp`.`theme_view` = :v
LEFT JOIN `forum_categories` AS `cat` ON `cat`.`id` = `th`.`id_category`
WHERE `th`.`group_show` <= :g
AND `tp`.`group_show` <= :g
AND `cat`.`group_show` <= :g
AND `th`.`time_last` > :t");
$res->execute(Array(':v' => 1, ':g' => $user->group, ':t' => NEW_TIME));
$new_posts = $res->fetchColumn();
cache_counters::set('forum.new_posts.' . $user->group, $new_posts, 60);
}
if (false === ($new_themes = cache_counters::get('forum.new_themes.' . $user->group))) {
$res = $db->prepare("SELECT COUNT(*)
FROM `forum_themes` AS `th`
INNER JOIN `forum_topics` AS `tp` ON `tp`.`id` = `th`.`id_topic` AND `tp`.`theme_view` = :v
LEFT JOIN `forum_categories` AS `cat` ON `cat`.`id` = `th`.`id_category`
WHERE `th`.`group_show` <= :g
AND `tp`.`group_show` <= :g
AND `cat`.`group_show` <= :g
AND `th`.`time_create` > :t");
$res->execute(Array(':v' => 1, ':g' => $user->group, ':t' => NEW_TIME));
$new_themes = $res->fetchColumn();
cache_counters::set('forum.new_themes.' . $user->group, $new_themes, 60);
}
$res = $db->query("SELECT COUNT(*) FROM `users_online` WHERE `request` LIKE '/forum/%'");
$users = $res->fetchColumn();
$listing = new listing();
$post = $listing->post();
$post->highlight = true;
$post->title = __('- Последние обсуждения');
/*
$post->icon('forum');
$post->url = '/forum/last.posts.php';
$post->title = __('Темы с новыми сообщениями');
if ($new_posts)
$post->counter = '+' . $new_posts;
$post = $listing->post();
$post->icon('forum');
$post->url = '/forum/last.themes.php';
$post->title = __('Новые темы');
if ($new_themes)
$post->counter = '+' . $new_themes;
*/
$listing->display();
$q = $db->prepare("SELECT `forum_themes`.*
FROM `forum_themes`
JOIN `forum_messages` ON `forum_messages`.`id_theme` = `forum_themes`.`id`
WHERE `forum_themes`.`group_show` <= ? AND `forum_messages`.`group_show` <= ?
GROUP BY `forum_themes`.`id`
ORDER BY `forum_themes`.`top`, `forum_themes`.`time_last` DESC LIMIT 2");
$q->execute(Array($user->group, $user->group));
$listing = new listing();
if ($arr = $q->fetchAll()) {
$themes_ids = array();
foreach ($arr AS $theme) {
$themes_ids[] = $theme['id'];
}
foreach ($arr AS $theme) {
$post = $listing->post();
$is_open = (int)($theme['group_write']);
$post->icon("forum.theme.{$theme['top']}.$is_open");
$post->title = text::toValue($theme['name']);
$post->url = '/forum/theme.php?id=' . $theme['id'];
$post->time = misc::when($theme['time_last']);
$autor = new user($theme['id_autor']);
$last_msg = new user($theme['id_last']);
$post->content = ($autor->id != $last_msg->id ? $autor->nick . '/' . $last_msg->nick : $autor->nick) . '<br />';
}
}
$listing->display(__('Доступных Вам тем нет'));