ALTER TABLE bb_topics ADD `topic_show_first_post` tinyint(1) unsigned NOT NULL default '0'; Закрепление первого поста git-svn-id: https://torrentpier2.googlecode.com/svn/trunk@308 a8ac35ab-4ca4-ca47-4c2d-a49a94f06293
This commit is contained in:
fly.dvorkin 2011-11-12 16:55:54 +00:00
commit e04c1fcf9f
7 changed files with 120 additions and 2 deletions

View file

@ -1270,6 +1270,7 @@ CREATE TABLE `bb_topics` (
`topic_reported` tinyint(1) NOT NULL default '0', `topic_reported` tinyint(1) NOT NULL default '0',
`topic_dl_type` tinyint(1) NOT NULL default '0', `topic_dl_type` tinyint(1) NOT NULL default '0',
`topic_last_post_time` int(11) NOT NULL default '0', `topic_last_post_time` int(11) NOT NULL default '0',
`topic_show_first_post` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`topic_id`), PRIMARY KEY (`topic_id`),
KEY `forum_id` (`forum_id`), KEY `forum_id` (`forum_id`),
KEY `topic_last_post_id` (`topic_last_post_id`), KEY `topic_last_post_id` (`topic_last_post_id`),

View file

@ -53,8 +53,8 @@ $bb_cfg = $tr_cfg = $page_cfg = array();
// Increase number of revision after update // Increase number of revision after update
$bb_cfg['tp_version'] = '2.2 Beta'; $bb_cfg['tp_version'] = '2.2 Beta';
$bb_cfg['tp_release_state'] = 'R307'; $bb_cfg['tp_release_state'] = 'R308';
$bb_cfg['tp_release_date'] = '10-11-2011'; $bb_cfg['tp_release_date'] = '12-11-2011';
// Database // Database
$charset = 'utf8'; $charset = 'utf8';

View file

@ -1693,3 +1693,9 @@ $lang['DL_ULR'] = 'ULR';
$lang['DL_STOPPED'] = 'stopped'; $lang['DL_STOPPED'] = 'stopped';
$lang['DL_UPD'] = 'upd: '; $lang['DL_UPD'] = 'upd: ';
$lang['DL_INFO'] = 'shows data <i><b>only for the current session</b></i>'; $lang['DL_INFO'] = 'shows data <i><b>only for the current session</b></i>';
// Post PIN
$lang['POST_PIN'] = 'Pin first post';
$lang['POST_UNPIN'] = 'Unpin first post';
$lang['POST_PINNED'] = 'First post pinned';
$lang['POST_UNPINNED'] = 'First post unpinned';

View file

@ -1701,3 +1701,9 @@ $lang['DL_ULR'] = 'ULR';
$lang['DL_STOPPED'] = 'Остановил Скачивание/Раздачу'; $lang['DL_STOPPED'] = 'Остановил Скачивание/Раздачу';
$lang['DL_UPD'] = 'Подключён: '; $lang['DL_UPD'] = 'Подключён: ';
$lang['DL_INFO'] = 'показаны данные <i><b>только за текущую сессию</b></i>'; $lang['DL_INFO'] = 'показаны данные <i><b>только за текущую сессию</b></i>';
// Post PIN
$lang['POST_PIN'] = 'Закрепить первый пост';
$lang['POST_UNPIN'] = 'Открепить первый пост';
$lang['POST_PINNED'] = 'Первый пост закреплён';
$lang['POST_UNPINNED'] = 'Первый пост откреплён';

View file

@ -194,6 +194,8 @@ switch ($mode)
case 'unlock': case 'unlock':
case 'set_download': case 'set_download':
case 'unset_download': case 'unset_download':
case 'post_stick':
case 'post_unstick':
if (empty($_POST['topic_id_list']) && empty($topic_id)) if (empty($_POST['topic_id_list']) && empty($topic_id))
{ {
@ -743,6 +745,80 @@ switch ($mode)
$template->set_filenames(array('body' => 'modcp.tpl')); $template->set_filenames(array('body' => 'modcp.tpl'));
break; break;
case 'post_pin':
case 'post_unpin':
$pin = ($mode == 'post_pin');
$new_topic_status = ($pin) ? 1 : 0;
if(count($topic_csv))
{
$sql = "
SELECT topic_id, topic_title
FROM ". BB_TOPICS ."
WHERE topic_id IN($topic_csv)
AND forum_id = $forum_id
AND topic_show_first_post != ". TOPIC_MOVED ."
AND topic_show_first_post != $new_topic_status
";
$topic_csv = array();
foreach (DB()->fetch_rowset($sql) as $row)
{
$topic_csv[] = $row['topic_id'];
$log_topics[$row['topic_id']] = $row['topic_title'];
}
if (!$topic_csv = get_id_csv($topic_csv))
{
message_die(GENERAL_MESSAGE, $lang['NONE_SELECTED']);
}
DB()->query("
UPDATE ". BB_TOPICS ." SET
topic_show_first_post = $new_topic_status
WHERE topic_id IN($topic_csv)
");
$msg = ($pin) ? $lang['POST_PINNED'] : $lang['POST_UNPINNED'];
message_die(GENERAL_MESSAGE, return_msg_mcp($msg));
}
elseif ($topic_id)
{
$sql = "
SELECT topic_id, topic_title
FROM ". BB_TOPICS ."
WHERE topic_id = $topic_id
AND forum_id = $forum_id
AND topic_show_first_post != ". TOPIC_MOVED ."
AND topic_show_first_post != $new_topic_status
LIMIT 1
";
$topic_csv = array();
foreach (DB()->fetch_rowset($sql) as $row)
{
$topic_csv[] = $row['topic_id'];
$log_topics[$row['topic_id']] = $row['topic_title'];
}
if (!$topic_csv = get_id_csv($topic_csv))
{
message_die(GENERAL_MESSAGE, $lang['NONE_SELECTED']);
}
DB()->query("
UPDATE ". BB_TOPICS ." SET
topic_show_first_post = $new_topic_status
WHERE topic_id IN($topic_csv)
");
$msg = ($pin) ? $lang['POST_PINNED'] : $lang['POST_UNPINNED'];
message_die(GENERAL_MESSAGE, return_msg_mcp($msg));
}
break;
default: default:
bb_die('invalid action'); bb_die('invalid action');
break; break;

View file

@ -115,6 +115,8 @@ function set_hid_chbox (id)
<!-- IF AUTH_MOD --> <!-- IF AUTH_MOD -->
<td class="small bold nowrap" style="padding: 0px 0px 0px 4px;"> <td class="small bold nowrap" style="padding: 0px 0px 0px 4px;">
<!-- IF IN_MODERATION -->{L_MODERATE_TOPIC}<!-- ELSE --><a href="{PAGE_URL}&amp;mod=1&amp;start={PAGE_START}" class="small bold">{L_MODERATE_TOPIC}</a><!-- ENDIF --> <!-- IF IN_MODERATION -->{L_MODERATE_TOPIC}<!-- ELSE --><a href="{PAGE_URL}&amp;mod=1&amp;start={PAGE_START}" class="small bold">{L_MODERATE_TOPIC}</a><!-- ENDIF -->
&nbsp;|&nbsp;
<a class="small bold" href="{PIN_HREF}">{PIN_TITLE}</a>
</td> </td>
<!-- IF SELECT_PPP --> <!-- IF SELECT_PPP -->
<td class="med" style="padding: 0px 4px 2px 4px;">|</td> <td class="med" style="padding: 0px 4px 2px 4px;">|</td>

View file

@ -368,6 +368,28 @@ $post_order = (isset($_POST['postorder']) && $_POST['postorder'] !== 'asc') ? 'd
// //
// Go ahead and pull all data for this topic // Go ahead and pull all data for this topic
// //
// 1. Add first post of topic if it pinned and page of topic not first
$first_post = false;
if ($t_data['topic_show_first_post'] && ( $start != 0))
{
$first_post = DB()->fetch_rowset("
SELECT
u.username, u.user_id, u.user_posts, u.user_from,
u.user_regdate, u.user_rank, u.user_sig,
u.user_avatar, u.user_avatar_type,
u.user_opt,
p.*,
h.post_html, IF(h.post_html IS NULL, pt.post_text, NULL) AS post_text
FROM ". BB_POSTS ." p
LEFT JOIN ". BB_USERS ." u ON(u.user_id = p.poster_id)
LEFT JOIN ". BB_POSTS_TEXT ." pt ON(pt.post_id = p.post_id)
LEFT JOIN ". BB_POSTS_HTML ." h ON(h.post_id = p.post_id)
WHERE
p.post_id = {$t_data['topic_first_post_id']}
LIMIT 1
");
}
// 2. All others posts
$sql = " $sql = "
SELECT SELECT
u.username, u.user_id, u.user_posts, u.user_from, u.username, u.user_id, u.user_posts, u.user_from,
@ -394,6 +416,7 @@ $sql = "
if ($postrow = DB()->fetch_rowset($sql)) if ($postrow = DB()->fetch_rowset($sql))
{ {
if ($first_post) $postrow = array_merge($first_post, $postrow);
$total_posts = count($postrow); $total_posts = count($postrow);
} }
else else
@ -591,6 +614,10 @@ $template->assign_vars(array(
'HIDE_RANK_IMG_DIS' => !$bb_cfg['show_rank_image'], 'HIDE_RANK_IMG_DIS' => !$bb_cfg['show_rank_image'],
'PINNED_FIRST_POST' => ($t_data['topic_show_first_post']),
'PIN_HREF' => $t_data['topic_show_first_post'] ? "modcp.php?t=$topic_id&amp;mode=post_unpin" : "modcp.php?t=$topic_id&amp;mode=post_pin",
'PIN_TITLE' => $t_data['topic_show_first_post'] ? $lang['POST_UNPIN'] : $lang['POST_PIN'],
'AUTH_MOD' => $is_auth['auth_mod'], 'AUTH_MOD' => $is_auth['auth_mod'],
'IN_MODERATION' => $moderation, 'IN_MODERATION' => $moderation,
'SELECT_PPP' => ($moderation && $select_ppp && $total_replies > $posts_per_page) ? build_select('ppp', $select_ppp, $posts_per_page, null, null, 'onchange="$(\'#ppp\').submit();"') : '', 'SELECT_PPP' => ($moderation && $select_ppp && $total_replies > $posts_per_page) ? build_select('ppp', $select_ppp, $posts_per_page, null, null, 'onchange="$(\'#ppp\').submit();"') : '',