1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-13 20:28:44 +01:00

finish bump topic feature...

git-svn-id: file:///svn/phpbb/trunk@4634 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2003-11-01 16:10:21 +00:00
parent bd508e5a27
commit f79d8a3694
7 changed files with 86 additions and 30 deletions

View File

@ -1113,6 +1113,37 @@ function login_forum_box(&$forum_data)
page_footer();
}
// Bump Topic Check - used by posting and viewtopic (do not want another included file)
function bump_topic_allowed($forum_id, $topic_bumped, $last_post_time, $topic_poster, $last_topic_poster)
{
global $config, $auth, $user;
// Check permission and make sure the last post was not already bumped
if (!$auth->acl_get('f_bump', $forum_id) || $topic_bumped)
{
return false;
}
// Check bump time range, is the user really allowed to bump the topic at this time?
preg_match('#^([0-9]+)(m|h|d)$#', $config['bump_interval'], $match);
$bump_time = ($match[2] == 'm') ? $match[1] * 60 : (($match[2] == 'h') ? $match[1] * 3600 : $match[1] * 86400);
// Check bump time
if ($last_post_time + $bump_time > time())
{
return false;
}
// Check bumper, only topic poster and last poster are allowed to bump
if ($topic_poster != $user->data['user_id'] && $last_topic_poster != $user->data['user_id'])
{
return false;
}
// A bump time of 0 will completely disable the bump feature... not intended but might be useful.
return $bump_time;
}
// Error and message handler, call with trigger_error if reqd
function msg_handler($errno, $msg_text, $errfile, $errline)
{

View File

@ -70,6 +70,27 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
return $forum_list;
}
// Generate size select form
function size_select($select_name, $size_compare)
{
global $user;
$size_types_text = array($user->lang['BYTES'], $user->lang['KB'], $user->lang['MB']);
$size_types = array('b', 'kb', 'mb');
$select_field = '<select name="' . $select_name . '">';
for ($i = 0; $i < count($size_types_text); $i++)
{
$selected = ($size_compare == $size_types[$i]) ? ' selected="selected"' : '';
$select_field .= '<option value="' . $size_types[$i] . '"' . $selected . '>' . $size_types_text[$i] . '</option>';
}
$select_field .= '</select>';
return ($select_field);
}
// Obtain authed forums list
function get_forum_list($acl_list = 'f_list', $id_only = TRUE, $postable_only = FALSE, $no_cache = FALSE)
{

View File

@ -523,7 +523,6 @@ function create_thumbnail($source, $new_file, $mimetype)
return TRUE;
}
//
// TODO
//

View File

@ -373,23 +373,9 @@ $img_status = ($auth->acl_get('f_img', $forum_id)) ? TRUE : FALSE;
$flash_status = ($auth->acl_get('f_flash', $forum_id)) ? TRUE : FALSE;
$quote_status = ($config['allow_quote'] && $auth->acl_get('f_quote', $forum_id)) ? TRUE : FALSE;
// Bump Topic
if ($mode == 'bump' && !$auth->acl_get('f_bump', $forum_id))
if ($mode == 'bump' && ($bump_time = bump_topic_allowed($forum_id, $topic_bumped, $topic_last_post_time, $topic_poster, $topic_last_poster_id)))
{
trigger_error('USER_CANNOT_BUMP');
}
else if ($mode == 'bump')
{
// Check bump time range, is the user really allowed to bump the topic at this time?
preg_match('#^([0-9]+)(m|h|d)$#', $config['bump_interval'], $match);
$bump_time = ($match[2] == 'm') ? $match[1] * 60 : (($match[2] == 'h') ? $match[1] * 3600 : $match[1] * 86400);
if ($topic_last_post_time + $bump_time > $current_time)
{
trigger_error('BUMP_ERROR');
}
$db->sql_transaction();
$db->sql_query('UPDATE ' . POSTS_TABLE . "
@ -398,7 +384,9 @@ else if ($mode == 'bump')
AND topic_id = $topic_id");
$db->sql_query('UPDATE ' . TOPICS_TABLE . "
SET topic_last_post_time = $current_time
SET topic_last_post_time = $current_time,
topic_bumped = 1,
topic_bumper = " . $user->data['user_id'] . "
WHERE topic_id = $topic_id");
$db->sql_query('UPDATE ' . FORUMS_TABLE . '
@ -413,13 +401,17 @@ else if ($mode == 'bump')
markread('post', $forum_id, $topic_id, $current_time);
add_log('mod', $forum_id, $topic_id, sprintf('LOGM_BUMP', $topic_title));
add_log('mod', $forum_id, $topic_id, sprintf($user->lang['LOGM_BUMP'], $topic_title));
meta_refresh(3, "viewtopic.$phpEx$SID&amp;f=$forum_id&amp;t=$topic_id&amp;p=$topic_last_post_id#$topic_last_post_id");
$message = $user->lang['TOPIC_BUMPED'] . '<br /><br />' . sprintf($user->lang['VIEW_MESSAGE'], '<a href="viewtopic.' . $phpEx . $SID . "&amp;f=$forum_id&amp;t=$topic_id&amp;p=$topic_last_post_id#$topic_last_post_id\">", '</a>') . '<br /><br />' . sprintf($user->lang['RETURN_FORUM'], '<a href="viewforum.' . $phpEx . $SID .'&amp;f=' . $forum_id . '">', '</a>');
trigger_error($message);
}
else if ($mode == 'bump')
{
trigger_error('BUMP_ERROR');
}
// Save Draft
@ -1571,7 +1563,7 @@ function delete_post($mode, $post_id, $topic_id, $forum_id, $data)
{
$sql_data['forum'] .= ($sql_data['forum'] != '') ? ', ' . implode(', ', $update) : implode(', ', $update);
}
$sql_data['topic'] = 'topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
$sql_data['topic'] = 'topic_bumped = 0, topic_bumper = 0, topic_replies_real = topic_replies_real - 1' . (($data['post_approved']) ? ', topic_replies = topic_replies - 1' : '');
$update = update_last_post_information('topic', $topic_id);
if (sizeof($update))
{
@ -1764,6 +1756,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
case 'reply':
$sql_data['topic']['stat'][] = 'topic_replies_real = topic_replies_real + 1' . ((!$auth->acl_get('f_moderate', $data['forum_id'])) ? ', topic_replies = topic_replies + 1' : '');
$sql_data['topic']['stat'][] = 'topic_bumped = 0, topic_bumper = 0';
$sql_data['user']['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id'])) ? ', user_posts = user_posts + 1' : '');
$sql_data['forum']['stat'][] = 'forum_posts = forum_posts + 1'; //(!$auth->acl_get('f_moderate', $data['forum_id'])) ? 'forum_posts = forum_posts + 1' : '';
break;
@ -1789,7 +1782,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
break;
}
// $db->sql_transaction();
$db->sql_transaction();
// Submit new topic
if ($post_mode == 'post')
@ -1991,7 +1984,7 @@ function submit_post($mode, $message, $subject, $username, $topic_type, $bbcode_
}
// $db->sql_transaction('commit');
$db->sql_transaction('commit');
if ($post_mode == 'post' || $post_mode == 'reply' || $post_mode == 'edit_last_post')
{

View File

@ -38,6 +38,7 @@ function checkForm()
return true;
}
}
//-->
</script>
<script language="javascript" type="text/javascript" src="styles/subSilver/template/editor.js"></script>

View File

@ -162,6 +162,7 @@
<!-- IF postrow.S_DISPLAY_NOTICE --><span class="gensmall" style="color:red;"><br /><br />{L_DOWNLOAD_NOTICE}</span><!-- ENDIF -->
<!-- IF postrow.SIGNATURE --><span class="postbody"><br />_________________<br />{postrow.SIGNATURE}</span><!-- ENDIF -->
<span class="gensmall">{postrow.EDITED_MESSAGE}</span>
<span class="gensmall">{postrow.BUMPED_MESSAGE}</span>
</td>
</tr>
<tr>

View File

@ -162,7 +162,7 @@ if ($user->data['user_id'] != ANONYMOUS)
// whereupon we join on the forum_id passed as a parameter ... this
// is done so navigation, forum name, etc. remain consistent with where
// user clicked to view a global topic
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_attachment, t.topic_status, t.topic_approved, ' . (($auth->acl_get('m_approve')) ? 't.topic_replies_real AS topic_replies' : 't.topic_replies') . ', t.topic_last_post_id, t.topic_last_post_time, t.topic_poster, t.topic_time, t.topic_time_limit, t.topic_type, t.poll_max_options, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style, f.forum_password' . $extra_fields . '
$sql = 'SELECT t.topic_id, t.forum_id, t.topic_title, t.topic_attachment, t.topic_status, t.topic_approved, ' . (($auth->acl_get('m_approve')) ? 't.topic_replies_real AS topic_replies' : 't.topic_replies') . ', t.topic_last_post_id, t.topic_last_poster_id, t.topic_last_post_time, t.topic_poster, t.topic_time, t.topic_time_limit, t.topic_type, t.topic_bumped, t.topic_bumper, t.poll_max_options, t.poll_start, t.poll_length, t.poll_title, f.forum_name, f.forum_desc, f.forum_parents, f.parent_id, f.left_id, f.right_id, f.forum_status, f.forum_id, f.forum_style, f.forum_password' . $extra_fields . '
FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f' . $join_sql_table . "
WHERE $join_sql
AND (f.forum_id = t.forum_id
@ -446,11 +446,6 @@ if (sizeof($censors))
$topic_title = preg_replace($censors['match'], $censors['replace'], $topic_title);
}
// Bump topic allowed?
preg_match('#^([0-9]+)(m|h|d)$#', $config['bump_interval'], $match);
$bump_time = ($match[2] == 'm') ? $match[1] * 60 : (($match[2] == 'h') ? $match[1] * 3600 : $match[1] * 86400);
unset($match);
// Send vars to template
$template->assign_vars(array(
'FORUM_ID' => $forum_id,
@ -507,7 +502,7 @@ $template->assign_vars(array(
'U_POST_NEW_TOPIC' => "posting.$phpEx$SID&amp;mode=post&amp;f=$forum_id",
'U_POST_REPLY_TOPIC' => "posting.$phpEx$SID&amp;mode=reply&amp;f=$forum_id&amp;t=$topic_id",
'U_BUMP_TOPIC' => ($topic_last_post_time + $bump_time < time() && $auth->acl_get('f_bump', $forum_id)) ? "posting.$phpEx$SID&amp;mode=bump&amp;f=$forum_id&amp;t=$topic_id" : '')
'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_bumped, $topic_last_post_time, $topic_poster, $topic_last_poster_id)) ? "posting.$phpEx$SID&amp;mode=bump&amp;f=$forum_id&amp;t=$topic_id" : '')
);
// Does this topic contain a poll?
@ -846,7 +841,8 @@ do
'icq' => '',
'aim' => '',
'msn' => '',
'search' => ''
'search' => '',
'username' => ($row['user_colour']) ? '<span style="color:#' . $row['user_colour'] . '">' . $poster . '</span>' : $poster
);
}
else
@ -881,7 +877,8 @@ do
'msn' => ($row['user_msnm']) ? "memberlist.$phpEx$SID&amp;mode=contact&amp;action=msnm&amp;u=$poster_id" : '',
'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . $row['user_yim'] . '&.src=pg' : '',
'jabber' => ($row['user_jabber']) ? "memberlist.$phpEx$SID&amp;mode=contact&amp;action=jabber&amp;u=$poster_id" : '',
'search' => ($auth->acl_get('u_search')) ? "search.$phpEx$SID&amp;search_author=" . urlencode($row['username']) .'&amp;showresults=posts' : ''
'search' => ($auth->acl_get('u_search')) ? "search.$phpEx$SID&amp;search_author=" . urlencode($row['username']) .'&amp;showresults=posts' : '',
'username' => ($row['user_colour']) ? '<span style="color:#' . $row['user_colour'] . '">' . $poster . '</span>' : $poster
);
if ($row['user_avatar'] && $user->optionget('viewavatars'))
@ -1161,6 +1158,18 @@ foreach ($rowset as $i => $row)
$l_edited_by = '';
}
// Bump information
if ($topic_bumped && $row['post_id'] == $topic_last_post_id)
{
// It is safe to grab the username from the user cache array, we are at the last
// post and only the topic poster and last poster are allowed to bump
$l_bumped_by = '<br /><br />' . sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_bumper]['username'], $user->format_date($topic_last_post_time));
}
else
{
$l_bumped_by = '';
}
// Dump vars into template
$template->assign_block_vars('postrow', array(
'POSTER_NAME' => $row['poster'],
@ -1177,6 +1186,7 @@ foreach ($rowset as $i => $row)
'MESSAGE' => $message,
'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '',
'EDITED_MESSAGE'=> $l_edited_by,
'BUMPED_MESSAGE'=> $l_bumped_by,
'MINI_POST_IMG' => ($row['post_time'] > $user->data['user_lastvisit'] && $row['post_time'] > $topic_last_read && $user->data['user_id'] != ANONYMOUS) ? $user->img('icon_post_new', $user->lang['NEW_POST']) : $user->img('icon_post', $user->lang['POST']),
'POST_ICON_IMG' => (!empty($row['icon_id'])) ? '<img src="' . $config['icons_path'] . '/' . $icons[$row['icon_id']]['img'] . '" width="' . $icons[$row['icon_id']]['width'] . '" height="' . $icons[$row['icon_id']]['height'] . '" alt="" title="" />' : '',