mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
Forum level annoucements and sticky topics are done.
Added topic_type field to the topics database in order to handle ordering. Would have used topic_status but that would have messed up the ordering when topics were locked git-svn-id: file:///svn/phpbb/trunk@437 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
f49da7909b
commit
1010b488ca
11 changed files with 193 additions and 108 deletions
|
@ -38,7 +38,7 @@ INSERT INTO phpbb_auth_forums (forum_id, auth_view, auth_read, auth_post, auth_r
|
|||
INSERT INTO phpbb_auth_access (group_id, forum_id, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_announce, auth_sticky, auth_votecreate, auth_vote, auth_mod) VALUES (2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
|
||||
|
||||
# -- Demo Topic
|
||||
INSERT INTO phpbb_topics VALUES(1, 1, 'Demo Topic', 1, NOW(), 0, 0, 0, 0, 1);
|
||||
INSERT INTO phpbb_topics VALUES(1, 1, 'Demo Topic', 1, NOW(), 0, 0, 0, 0, 0, 1);
|
||||
|
||||
# -- Demo Post
|
||||
INSERT INTO phpbb_posts VALUES(1, 1, 1, 1, NOW(), '127.0.0.1' , LEFT(MD5('42'), 10));
|
||||
|
|
|
@ -407,6 +407,7 @@ CREATE TABLE phpbb_topics (
|
|||
topic_views int(10) DEFAULT '0' NOT NULL,
|
||||
topic_replies int(11) DEFAULT '0' NOT NULL,
|
||||
topic_status tinyint(3) DEFAULT '0' NOT NULL,
|
||||
topic_type tinyint(3) DEFAULT '0' NOT NULL,
|
||||
topic_notify tinyint(3) DEFAULT '0',
|
||||
topic_last_post_id int(11) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (topic_id),
|
||||
|
|
|
@ -404,6 +404,7 @@ CREATE TABLE phpbb_topics (
|
|||
topic_replies int4 DEFAULT '0' NOT NULL,
|
||||
forum_id int4 DEFAULT '0' NOT NULL,
|
||||
topic_status int2 DEFAULT '0' NOT NULL,
|
||||
topic_type int2 DEFAULT '0' NOT NULL,
|
||||
topic_notify int2 DEFAULT '0',
|
||||
topic_last_post_id int4 DEFAULT '0' NOT NULL,
|
||||
CONSTRAINT phpbb_topics_pkey PRIMARY KEY (topic_id)
|
||||
|
|
|
@ -40,6 +40,13 @@ define(ADMIN, 1);
|
|||
define(UNLOCKED, 0);
|
||||
define(LOCKED, 1);
|
||||
|
||||
// Topic types
|
||||
define(NORMAL, 0);
|
||||
define(STICKY, 1);
|
||||
define(ANNOUCE, 2);
|
||||
define(GLOB_ANNOUNCE, 3);
|
||||
|
||||
|
||||
// Ban time types
|
||||
define(SECONDS, 1);
|
||||
define(MINUTES, 2);
|
||||
|
|
|
@ -126,6 +126,8 @@ $lang['Forum_Index'] = "Forum Index";
|
|||
//
|
||||
// Viewforum
|
||||
//
|
||||
$lang['Annoucement'] = "<b>Annoucement:</b>";
|
||||
$lang['Sticky'] = "<b>Sticky:</b>";
|
||||
|
||||
//
|
||||
// Viewtopic
|
||||
|
@ -140,6 +142,9 @@ $lang['Empty_subj'] = "You must specifiy a subject when posting a new topic.";
|
|||
$lang['Empty_msg'] = "You must enter a message when posting!";
|
||||
$lang['Postnew'] = "Post New Topic";
|
||||
$lang['Post_new_in'] = "Post New Topic in:"; // Followed by forum name
|
||||
$lang['Post_Annoucement'] = "Post as an annoucement";
|
||||
$lang['Post_Sticky'] = "Stick this topic";
|
||||
$lang['Annouce_and_sticky'] = "You cannot post a topic that is both an annoucement and a sticky topic";
|
||||
|
||||
|
||||
//
|
||||
|
|
|
@ -90,11 +90,27 @@ init_userprefs($userdata);
|
|||
switch($mode)
|
||||
{
|
||||
case 'newtopic':
|
||||
$auth_type = AUTH_POST;
|
||||
if(isset($HTTP_POST_VARS['annouce']))
|
||||
{
|
||||
$auth_type = AUTH_ANNOUCE;
|
||||
$is_auth_type = "auth_announce";
|
||||
$error_string = "post annoucements";
|
||||
}
|
||||
else if(isset($HTTP_POST_VARS['sticky']))
|
||||
{
|
||||
$auth_type = AUTH_STICKY;
|
||||
$is_auth_type = "auth_sticky";
|
||||
$error_string = "post sticky topics";
|
||||
}
|
||||
else
|
||||
{
|
||||
$auth_type = AUTH_ALL;
|
||||
$is_auth_type = "auth_post";
|
||||
$error_string = "post new topics";
|
||||
}
|
||||
break;
|
||||
case 'reply':
|
||||
|
||||
$auth_type = AUTH_REPLY;
|
||||
$is_auth_type = "auth_reply";
|
||||
$error_string = "reply to topics";
|
||||
|
@ -110,8 +126,8 @@ switch($mode)
|
|||
$error_string = "delete topics";
|
||||
break;
|
||||
default:
|
||||
$auth_type = AUTH_POST;
|
||||
$is_auth_type = "auth_post";
|
||||
$auth_type = AUTH_ALL;
|
||||
$is_auth_type = "auth_all";
|
||||
$error_string = "post new topics";
|
||||
break;
|
||||
}
|
||||
|
@ -153,6 +169,21 @@ $disable_bbcode = (isset($HTTP_POST_VARS['disable_bbcode'])) ? $HTTP_POST_VARS['
|
|||
$disable_smilies = (isset($HTTP_POST_VARS['disable_smile'])) ? $HTTP_POST_VARS['disable_smile'] : !$userdata['user_allowsmile'];
|
||||
$attach_sig = (isset($HTTP_POST_VARS['attach_sig'])) ? $HTTP_POST_VARS['attach_sig'] : $userdata['user_attachsig'];
|
||||
$notify = (isset($HTTP_POST_VARS['notify'])) ? $HTTP_POST_VARS['notify'] : $userdata["always_notify"];
|
||||
$annouce = (isset($HTTP_POST_VARS['annouce'])) ? $HTTP_POST_VARS['annouce'] : "";
|
||||
$sticky = (isset($HTTP_POST_VARS['sticky'])) ? $HTTP_POST_VARS['sticky'] : "";
|
||||
|
||||
if($annouce)
|
||||
{
|
||||
$topic_type = ANNOUCE;
|
||||
}
|
||||
else if($sticky)
|
||||
{
|
||||
$topic_type = STICKY;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_type = NORMAL;
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare our message and subject on a 'submit'
|
||||
|
@ -195,6 +226,17 @@ if(isset($HTTP_POST_VARS['submit']))
|
|||
$error_msg .= $lang['Empty_subj'];
|
||||
}
|
||||
|
||||
// You can't make it both an annoumcement and a stick topic
|
||||
if($annouce && $sticky)
|
||||
{
|
||||
$error = TRUE;
|
||||
if(isset($error_msg))
|
||||
{
|
||||
$error_msg .= "<br />";
|
||||
}
|
||||
$error_msg .= $lang['Annouce_and_sticky'];
|
||||
}
|
||||
|
||||
if(!empty($HTTP_POST_VARS['message']))
|
||||
{
|
||||
if(!$error)
|
||||
|
@ -274,8 +316,8 @@ switch($mode)
|
|||
{
|
||||
$topic_time = get_gmt_ts();
|
||||
$topic_notify = ($HTTP_POST_VARS['notify']) ? $HTTP_POST_VARS['notify'] : 0;
|
||||
$sql = "INSERT INTO ".TOPICS_TABLE." (topic_title, topic_poster, topic_time, forum_id, topic_notify, topic_status)
|
||||
VALUES ('$subject', ".$userdata['user_id'].", ".$topic_time.", $forum_id, $topic_notify, ".UNLOCKED.")";
|
||||
$sql = "INSERT INTO ".TOPICS_TABLE." (topic_title, topic_poster, topic_time, forum_id, topic_notify, topic_status, topic_type)
|
||||
VALUES ('$subject', ".$userdata['user_id'].", ".$topic_time.", $forum_id, $topic_notify, ".UNLOCKED.", ".$topic_type.")";
|
||||
|
||||
if($db->sql_query($sql))
|
||||
{
|
||||
|
@ -807,20 +849,6 @@ if($error)
|
|||
}
|
||||
$forum_info = $db->sql_fetchrow($result);
|
||||
$forum_name = stripslashes($forum_info['forum_name']);
|
||||
$forum_access = $forum_info['forum_access'];
|
||||
|
||||
if($forum_access == ANONALLOWED)
|
||||
{
|
||||
$about_posting = "$l_anonusers $l_inthisforum $l_anonhint";
|
||||
}
|
||||
if($forum_access == REGONLY)
|
||||
{
|
||||
$about_posting = "$l_regusers $l_inthisforum";
|
||||
}
|
||||
if($forum_access == MODONLY)
|
||||
{
|
||||
$about_posting = "$l_modusers $l_inthisforum";
|
||||
}
|
||||
|
||||
$template->set_filenames(array(
|
||||
"body" => "posting_body.tpl",
|
||||
|
@ -905,6 +933,31 @@ if($error)
|
|||
}
|
||||
$sig_toggle .= "> $l_attachsig";
|
||||
|
||||
if($mode == 'newtopic')
|
||||
{
|
||||
if($is_auth['auth_announce'])
|
||||
{
|
||||
$annouce_toggle = '<input type="checkbox" name="annouce" ';
|
||||
if($annouce)
|
||||
{
|
||||
$announce_toggle .= "checked";
|
||||
}
|
||||
$annouce_toggle .= '> '.$lang['Post_Annoucement'];
|
||||
}
|
||||
|
||||
|
||||
if($is_auth['auth_sticky'])
|
||||
{
|
||||
$sticky_toggle = '<input type="checkbox" name="sticky" ';
|
||||
if($sticky)
|
||||
{
|
||||
$sticky_toggle .= "checked";
|
||||
}
|
||||
$sticky_toggle .= '> '.$lang['Post_Sticky'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($mode == 'newtopic' || ($mode == 'editpost' && $notify))
|
||||
{
|
||||
$notify_toggle = '<input type="checkbox" name="notify" ';
|
||||
|
@ -923,7 +976,6 @@ if($error)
|
|||
$hidden_form_fields = "<input type=\"hidden\" name=\"mode\" value=\"$mode\"><input type=\"hidden\" name=\"".POST_FORUM_URL."\" value=\"$forum_id\"><input type=\"hidden\" name=\"".POST_TOPIC_URL."\" value=\"$topic_id\"><input type=\"hidden\" name=\"".POST_POST_URL."\" value=\"$post_id\">";
|
||||
|
||||
$template->assign_vars(array(
|
||||
"L_ABOUT_POST" => $l_aboutpost,
|
||||
"L_SUBJECT" => $l_subject,
|
||||
"L_MESSAGE_BODY" => $l_body,
|
||||
"L_OPTIONS" => $l_options,
|
||||
|
@ -931,7 +983,6 @@ if($error)
|
|||
"L_SUBMIT" => $l_submit,
|
||||
"L_CANCEL" => $l_cancelpost,
|
||||
|
||||
"ABOUT_POSTING" => $about_posting,
|
||||
"USERNAME_INPUT" => $username_input,
|
||||
"PASSWORD_INPUT" => $password_input,
|
||||
"SUBJECT_INPUT" => $subject_input,
|
||||
|
@ -940,6 +991,8 @@ if($error)
|
|||
"HTML_TOGGLE" => $html_toggle,
|
||||
"SMILE_TOGGLE" => $smile_toggle,
|
||||
"SIG_TOGGLE" => $sig_toggle,
|
||||
"ANNOUNCE_TOGGLE" => $annouce_toggle,
|
||||
"STICKY_TOGGLE" => $sticky_toggle,
|
||||
"NOTIFY_TOGGLE" => $notify_toggle,
|
||||
"BBCODE_TOGGLE" => $bbcode_toggle,
|
||||
"BBCODE_STATUS" => $bbcode_status,
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<!-- BEGIN topicrow -->
|
||||
<tr bgcolor="#DDDDDD" class="tablebody">
|
||||
<td width="5%" align="center" valign="middle">{topicrow.FOLDER}</td>
|
||||
<td><a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a> {topicrow.GOTO_PAGE}</td>
|
||||
<td>{topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a> {topicrow.GOTO_PAGE}</td>
|
||||
<td width="5%" align="center" valign="middle">{topicrow.REPLIES}</td>
|
||||
<td width="10%" align="center" valign="middle">{topicrow.TOPIC_POSTER}</td>
|
||||
<td width="5%" align="center" valign="middle">{topicrow.VIEWS}</td>
|
||||
|
|
|
@ -34,7 +34,7 @@ function insertCode(formObj, selectObj){
|
|||
</tr>
|
||||
<tr>
|
||||
<td bgcolor="{T_TD_COLOR1}"><font face="{T_FONTFACE1}" size="{T_FONTSIZE2}"><b>{L_OPTIONS}</b></font></td>
|
||||
<td bgcolor="{T_TD_COLOR2}"><font face="{T_FONTFACE1}" size="{T_FONTSIZE2}">{HTML_TOGGLE}<br>{BBCODE_TOGGLE}<br>{SMILE_TOGGLE}<br>{SIG_TOGGLE}<br>{NOTIFY_TOGGLE}</font></td>
|
||||
<td bgcolor="{T_TD_COLOR2}"><font face="{T_FONTFACE1}" size="{T_FONTSIZE2}">{HTML_TOGGLE}<br>{BBCODE_TOGGLE}<br>{SMILE_TOGGLE}<br>{SIG_TOGGLE}<br>{STICKY_TOGGLE}<br>{ANNOUNCE_TOGGLE}<br>{NOTIFY_TOGGLE}</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" bgcolor="{T_TH_COLOR3}" align="center">{S_HIDDEN_FORM_FIELDS}<input type="submit" name="preview" value="{L_PREVIEW}"> <input type="submit" name="submit" value="{L_SUBMIT}"> <input type="submit" name="cancel" value="{L_CANCEL}"></td>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<!-- BEGIN topicrow -->
|
||||
<tr>
|
||||
<td bgcolor="{T_TD_COLOR1}" align="center" valign="middle"> {topicrow.FOLDER} </td>
|
||||
<td bgcolor="{T_TD_COLOR2}"><font face="{T_FONTFACE1}" size="{T_FONTSIZE1}"> <a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a> {topicrow.GOTO_PAGE}</td>
|
||||
<td bgcolor="{T_TD_COLOR2}"><font face="{T_FONTFACE1}" size="{T_FONTSIZE1}"> {topicrow.TOPIC_TYPE}<a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a> {topicrow.GOTO_PAGE}</td>
|
||||
<td bgcolor="{T_TD_COLOR1}" align="center" valign="middle"><font face="{T_FONTFACE1}" size="{T_FONTSIZE2}">{topicrow.REPLIES}</font></td>
|
||||
<td bgcolor="{T_TD_COLOR2}" align="center" valign="middle"><font face="{T_FONTFACE1}" size="{T_FONTSIZE2}"><a href="{topicrow.U_TOPIC_POSTER_PROFILE}">{topicrow.TOPIC_POSTER}</a></font></td>
|
||||
<td bgcolor="{T_TD_COLOR1}" align="center" valign="middle"><font face="{T_FONTFACE1}" size="{T_FONTSIZE2}">{topicrow.VIEWS}</font></td>
|
||||
|
|
|
@ -198,8 +198,9 @@ $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as i
|
|||
AND t.topic_poster = u.user_id
|
||||
AND p.post_id = t.topic_last_post_id
|
||||
AND p.poster_id = u2.user_id
|
||||
AND t.topic_type <> ".GLOB_ANNOUNCE."
|
||||
$limit_posts_time
|
||||
ORDER BY p.post_time DESC
|
||||
ORDER BY t.topic_type DESC, p.post_time DESC
|
||||
LIMIT $start, ".$board_config['topics_per_page'];
|
||||
if(!$t_result = $db->sql_query($sql))
|
||||
{
|
||||
|
@ -291,6 +292,22 @@ if($total_topics)
|
|||
for($x = 0; $x < $total_topics; $x++)
|
||||
{
|
||||
$topic_title = stripslashes($topic_rowset[$x]['topic_title']);
|
||||
|
||||
$topic_type = $topic_rowset[$x]['topic_type'];
|
||||
|
||||
if($topic_type == ANNOUCE)
|
||||
{
|
||||
$topic_type = $lang['Annoucement'] . " ";
|
||||
}
|
||||
else if($topic_type == STICKY)
|
||||
{
|
||||
$topic_type = $lang['Sticky'] . " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_type = "";
|
||||
}
|
||||
|
||||
$topic_id = $topic_rowset[$x]['topic_id'];
|
||||
|
||||
$replies = $topic_rowset[$x]['topic_replies'];
|
||||
|
@ -359,6 +376,7 @@ if($total_topics)
|
|||
"GOTO_PAGE" => $goto_page,
|
||||
"REPLIES" => $replies,
|
||||
"TOPIC_TITLE" => $topic_title,
|
||||
"TOPIC_TYPE" => $topic_type,
|
||||
"VIEWS" => $views,
|
||||
"LAST_POST_TIME" => $last_post_time,
|
||||
"LAST_POST_USER" => $last_post_user,
|
||||
|
|
Loading…
Add table
Reference in a new issue