Файл: modules/forum/view/razdel.php
Строк: 185
<?php
/* DCMS Special
* Дата последнего редактирования 15.12.2015
* Модифицировал densnet
* Автор yadalay
*/
$forum = mysql_fetch_object(mysql_query('SELECT * FROM `forum` WHERE `id` = ' . intval($_GET['forum'])));
$razdel = mysql_fetch_object(mysql_query('SELECT * FROM `forum_razdels` WHERE `id_forum` = ' . $forum->id . ' AND `id` = ' . intval($_GET['razdel'])));
if (!$razdel || !$forum || ($forum->access == 1 && $user['group_access'] < 8) || ($forum->access == 2 && $user['group_access'] < 3)) {
header('Location: ' . DIR_FORUM);
exit;
} else {
$set['title'] = (isset($_GET['create_theme'])) ? toOutput($razdel->name, 1, 1, 0, 0, 0) . ' - Создание темы' : 'Раздел - ' . toOutput($razdel->name, 1, 1, 0, 0, 0);
if (isset($user) && isset($_GET['create_theme'])) {
require_once 'action/create_theme.php'; #Создание темы.
}
if (isset($_SESSION['msg'])) {
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
if (isset($user)) {
$new_journal = '+' . mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `read` = "0" AND `id_user` = ' . $user['id']), 0) . "";
$f_journal = mysql_result(mysql_query('SELECT COUNT(*) FROM `f_journal` WHERE `id_user` = ' . $user['id']), 0);
$my_themes = (isset($user)) ? mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `id_user` = ' . $user['id']), 0) : NULL;
}
$new_themes = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `time` > ' . (time() - 60 * 60 * 24)), 0);
$reports = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_reports`'), 0);
#Навигация
echo "<ol class='breadcrumb'>";
echo "<li><a href='/'><span class='fa fa-home fa-fw'></span></a></li>";
echo "<li><a href='" . DIR_FORUM . "'>Форум</a></li>";
echo "<li><a href='" . DIR_FORUM . "$forum->id/'>" . toOutput($forum->name, 1, 1, 0, 0, 0) . "</a></li>";
echo "<li class='active'>" . toOutput($razdel->name, 1, 1, 0, 0, 0) . "</li>";
echo "</ol>";
echo "<div class='list-group-item' style='color: grey;'><div class='bd-example'><span style='float: right;'>n";
if (IS_WEB) {
#Кнопка меню действий
if (isset($user) && $razdel->type == 0 || ($razdel->type == 1) && $user['group_access'] > 2) {
echo "<a data-toggle='modal' data-target='#them_add' href='/?users_set'><span data-toggle='tooltip' data-placement='left' title='Создать тему'><i class='fa fa-plus fa-fw'></i></span></a>";
}
echo "<a data-toggle='modal' data-target='#menu_forum' href='/?users_set'><span style='padding: 10px;' data-toggle='tooltip' data-placement='left' title='Выберите действие'><i class='fa fa-ellipsis-v fa-lg'></i></span></a>";
} else {
if (isset($user) && $razdel->type == 0 || ($razdel->type == 1) && $user['group_access'] > 2) {
echo "<a data-toggle='modal' data-target='#them_add' href='/?users_set'><span title='Создать тему'><i class='fa fa-plus fa-fw'></i></span></a>";
}
echo "<a data-toggle='modal' data-target='#menu_forum' href='/?users_set'><span style='padding: 10px;' title='Выберите действие'><i class='fa fa-ellipsis-v fa-lg'></i></span></a>";
}
echo "</span></div>n";
echo "Темы</div>n";
#Всплывающее меню
echo "<div class='modal fade' id='menu_forum' tabindex='-1' role='dialog' aria-hidden='true'>n";
echo "<div class='modal-dialog'>n";
echo "<div class='modal-content'>n";
echo "<div class='modal-header'>n";
echo "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>";
echo "<span aria-hidden='true'>×</span>";
echo "<span class='sr-only'>Close</span>";
echo "</button>";
echo "<h5 class='modal-title' id='exampleModalLabel'>Меню форума</h5>";
echo "</div>";
echo "<div class='list-group' style='margin-top: -1px;'>";
echo "<a href='" . DIR_FORUM . "search.html' class='list-group-item'><span class='fa fa-search fa-fw'></span> Поиск</a>n";
echo "<a href='" . DIR_FORUM . "new_themes.html' class='list-group-item'><span class='fa fa-asterisk fa-fw'></span> Новые темы <span class='label label-info pull-right'>$new_themes</span></a>n";
if (isset($user)) {
echo "<a href='" . DIR_FORUM . "my_themes.html' class='list-group-item'><span class='fa fa-user fa-fw'></span> Мои темы <span class='label label-info pull-right'>$my_themes</span></a>n";
echo "<a href='" . DIR_FORUM . "journal.php' class='list-group-item'><span class='fa fa-bell fa-fw'></span> Уведомления <span class='label label-info pull-right'>$f_journal $new_journal</span></a>n";
}
if (access('forum_them_edit')) {
echo "<a href='" . DIR_FORUM . "reports.html' class='list-group-item'><span class='fa fa-flag fa-fw'></span> Жалобы на темы <span class='label label-info pull-right'>$reports</span></a>n";
}
echo "</div>n";
echo "</div>n";
echo "</div>n";
echo "</div>n";
echo "<div class='modal fade' id='them_add' tabindex='-1' role='dialog' aria-labelledby='mySmallModalLabel' aria-hidden='true'>n";
echo "<div class='modal-dialog'>n";
echo "<div class='modal-content'>n";
echo "<div class='modal-header'>n";
echo "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>";
echo "<span aria-hidden='true'>×</span>";
echo "<span class='sr-only'>Close</span>";
echo "</button>";
echo "<h5 class='modal-title' id='exampleModalLabel'>Новая тема</h5>";
echo "</div>";
if (isset($user) && $razdel->type == 0 || ($razdel->type == 1) && $user['group_access'] > 2) {
echo "<form class='list-group-item' style='margin-top: -1px;' action='" . DIR_FORUM . "$forum->id/$razdel->id/create_theme.html' method='post'>";
echo "Название темы:<br />";
echo "<input type='text' class='form-control' name='name' value='' />";
echo "Содержание темы:<br />";
echo "<textarea name='description' rows='4' class='form-control'></textarea>";
if ($user['group_access'] > 7) {
echo "<div class='hr'></div>";
echo "Вывод темы в разделе:<br />";
echo "<label class='c-input c-checkbox'><input type='checkbox' name='type' value='1' /><span class='c-indicator'></span> Тема всегда вверху</label><br />";
}
echo "<div class='hr'></div>";
echo "<button name='create' class='btn btn-success'>Создать</button> ";
echo "<button name='cancel' class='btn btn-secondary'>Отмена</button>";
echo "</form>";
}
echo "</div>n";
echo "</div>n";
echo "</div>n";
$k_post = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_themes` WHERE `id_razdel` = ' . $razdel->id), 0);
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
if ($k_post == 0) {
echo "<div class='list-group-item'>";
echo "<span class='fa fa-info-circle fa-fw'></span> Нет результатов";
echo "</div>";
} else {
$themes = mysql_query('SELECT * FROM `forum_themes` WHERE `id_razdel` = ' . $razdel->id . ' ORDER BY `type` DESC, `time_post` DESC LIMIT ' . $start . ', ' . $set['p_str']);
while ($theme = mysql_fetch_object($themes)) {
$creater = mysql_fetch_object(mysql_query('SELECT `id`, `nick` FROM `user` WHERE `id` = ' . $theme->id_user));
$count_posts = mysql_result(mysql_query('SELECT COUNT(*) FROM `forum_posts` WHERE `id_theme` = ' . $theme->id), 0);
$hide = (access('forum_post_ed')) ? NULL : '`hide` = "0" AND';
$last_post = mysql_fetch_object(mysql_query('SELECT `id`, `hide`, `id_user`, `time` FROM `forum_posts` WHERE ' . $hide . ' `id_theme` = ' . $theme->id . ' ORDER BY `id` DESC'));
if ($last_post && $last_post->id_user != 0) {
$who = mysql_fetch_object(mysql_query('SELECT `id`, `nick` FROM `user` WHERE `id` = ' . $last_post->id_user));
$who_id = $who->id;
$who_nick = $who->nick;
} elseif ($last_post && $last_post->id_user == 0) {
$who_id = 0;
$who_nick = 'Система';
}
if ($theme->reason_close != NULL) {
$type = "<span class='fa fa-file-text fa-fw'></span> " . toOutput($theme->name, 1, 1, 0, 0, 0) . " <span class='fa fa-lock fa-fw'></span>";
} elseif ($theme->type == 1) {
$type = "<span class='fa fa-file-text fa-fw'></span> " . toOutput($theme->name, 1, 1, 0, 0, 0) . " <span class='fa fa-thumb-tack fa-fw'></span>";
} else {
$type = "<span class='fa fa-file-text fa-fw'></span> " . toOutput($theme->name, 1, 1, 0, 0, 0) . "";
}
echo "<div class='list-group-item'>";
echo "<span style='float:right;'><span class='fa fa-comment fa-fw'></span> <b>$count_posts</b></span>";
echo "<a href='" . DIR_FORUM . "$forum->id/$razdel->id/$theme->id.html'>$type</a><br />";
if ($last_post) {
echo user($theme->id_user);
echo " <span style = 'color: #9197a3;' data-toggle='tooltip' data-placement='top' title='" . date::time($theme->time) . "'>" . date::timek($theme->time) . "</span>";
} else {
$continue = (mb_strlen($theme->description) > 150) ? '...' : NULL;
echo "<span style='color: #9197a3;'>";
echo toOutput(mb_substr($theme->description, 0, 150), 1, 1, 0, 1, 1) . $continue;
echo "</span>";
}
echo "</div>";
}
if ($k_page > 1) {
echo "<div class='list-group-item'>";
str(DIR_FORUM . $forum->id . '/' . $razdel->id . '/', $k_page, $page);
echo "</div>";
}
}
}