虎!
投稿入門者さん

|
PHPBB2.0.22 でAdvanced Topic Type を使用することができました。
下記、その方法です。
ダウンロード先: Advanced Topic Type
ダウンロードしたファイルの中のdb_update.phpの下記の部分を検索します。
"INSERT INTO ". TOPIC_ADD_TYPE_TABLE ." VALUES ('announce', 0, -1, 0, -1, 'FF0000', '', '')",
"INSERT INTO ". TOPIC_ADD_TYPE_TABLE ." VALUES ('sticky', 0, -1, 0, -1, 'FAD400', '', '')",
"ALTER TABLE ". TOPICS_TABLE ." ADD topic_type_active TINYINT(1) NOT NULL DEFAULT '0' AFTER topic_type"
); |
この部分を下記のcodeに置き換える。
"INSERT INTO ". TOPIC_ADD_TYPE_TABLE ." VALUES ('sticky', 1, -1, 0, -1, 'FAD400', '', '')",
"INSERT INTO ". TOPIC_ADD_TYPE_TABLE ." VALUES ('announce', 2, -1, 0, -1, 'FF0000', '', '')",
"ALTER TABLE ". TOPICS_TABLE ." ADD topic_type_active TINYINT(1) NOT NULL DEFAULT '0' AFTER topic_type"
); |
advanced_topic_type_v1.0.1.txtの下記の
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
|
この部分より下を下記のcodeに置き換える。
#
#-----[ COPY ]----------------------------------------------
#
copy root/admin/admin_topic_type.php to admin/admin_topic_type.php
copy root/templates/subSilver/admin/topic_type_body.tpl to templates/subSilver/admin/topic_type_body.tpl
copy root/templates/subSilver/admin/admin_edit_topic_type.tpl to templates/subSilver/admin/admin_edit_topic_type.tpl
copy root/templates/subSilver/images/folder_topic_type.gif to templates/subSilver/images/folder_topic_type.gif
copy root/templates/subSilver/images/folder_topic_type_new.gif to templates/subSilver/images/folder_topic_type_new.gif
copy db_update.php to /db_update.php
#
#-----[ OPEN ]----------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]----------------------------------------------
#
define('THEMES_NAME_TABLE', $table_prefix.'themes_name');
#
#-----[ AFTER, ADD ]----------------------------------------------
#
define('TOPIC_ADD_TYPE_TABLE', $table_prefix.'topic_add_type');
#
#-----[ OPEN ]----------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]----------------------------------------------
#
if ($mode == 'newtopic' || $mode == 'reply' || $mode == 'editpost')
#
#-----[ BEFORE, ADD ]----------------------------------------------
#
// BEGIN Advanced Topic Type MOD
if ( $topic_type >= POST_GLOBAL_ANNOUNCE)
{
$sql_tt = "SELECT * FROM ". TOPIC_ADD_TYPE_TABLE ." WHERE topic_type_id = ". intval($topic_type) ;
if ( !$result_tt = $db->sql_query($sql_tt) )
{
message_die(GENERAL_ERROR, 'Could not get topic type info', '', __LINE__, __FILE__, $sql_tt);
}
while( $tt_row = $db->sql_fetchrow($result_tt) )
{
$topic_type_active = $tt_row['topic_type_active'];
}
}
else
{
$topic_type_active = 0;
}
// END Advanced Topic Type MOD
#
#-----[ FIND ]----------------------------------------------
#
$sql = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE .
#
#-----[ IN-LINE FIND ]----------------------------------------------
#
topic_status, topic_type
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------------------
#
, topic_type_active
#
#-----[ IN-LINE FIND ]----------------------------------------------
#
, $topic_type
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------------------
#
, $topic_type_active
#
#-----[ IN-LINE FIND ]----------------------------------------------
#
topic_type = $topic_type
#
#-----[ IN-LINE AFTER, ADD ]----------------------------------------------
#
, topic_type_active = $topic_type_active
#
#-----[ OPEN ]----------------------------------------------
#
posting.php
#
#-----[ FIND ]----------------------------------------------
#
$topic_type = ( !empty($HTTP_POST_VARS['topictype']) ) ? intval($HTTP_POST_VARS['topictype']) : POST_NORMAL;
$topic_type = ( in_array($topic_type, array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE)) ) ? $topic_type : POST_NORMAL;
#
#-----[ REPLACE WITH ]----------------------------------------------
#
$topic_type_id_list = array(POST_NORMAL, POST_STICKY, POST_ANNOUNCE);
$sql_tt = "SELECT * FROM ". TOPIC_ADD_TYPE_TABLE ." WHERE `topic_type_id` > '0'";
$result_tt = $db->sql_query($sql_tt);
while( $add_type = $db->sql_fetchrow($result_tt) )
{
$topic_type_id_list[] = intval( $add_type['topic_type_id'] );
}
$topic_type = ( !empty($HTTP_POST_VARS['topictype']) ) ? intval($HTTP_POST_VARS['topictype']) : POST_NORMAL;
$topic_type = ( in_array($topic_type, $topic_type_id_list) ) ? $topic_type : POST_NORMAL;
#
#-----[ FIND ]----------------------------------------------
#
$topic_type = ( $topic_type != $post_data['topic_type'] && !$is_auth['auth_sticky'] && !$is_auth['auth_announce'] ) ? $post_data['topic_type'] : $topic_type;
#
#-----[ REPLACE WITH ]----------------------------------------------
#
// $topic_type = ( $topic_type != $post_data['topic_type'] && !$is_auth['auth_sticky'] && !$is_auth['auth_announce'] ) ? $post_data['topic_type'] : $topic_type;
#
#-----[ FIND ]----------------------------------------------
#
//
// Topic type selection
//
$topic_type_toggle = '';
if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) )
{
$template->assign_block_vars('switch_type_toggle', array());
if( $is_auth['auth_sticky'] )
{
$topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_STICKY . '"';
if ( $post_data['topic_type'] == POST_STICKY || $topic_type == POST_STICKY )
{
$topic_type_toggle .= ' checked="checked"';
}
$topic_type_toggle .= ' /> ' . $lang['Post_Sticky'] . ' ';
}
if( $is_auth['auth_announce'] )
{
$topic_type_toggle .= '<input type="radio" name="topictype" value="' . POST_ANNOUNCE . '"';
if ( $post_data['topic_type'] == POST_ANNOUNCE || $topic_type == POST_ANNOUNCE )
{
$topic_type_toggle .= ' checked="checked"';
}
$topic_type_toggle .= ' /> ' . $lang['Post_Announcement'] . ' ';
}
if ( $topic_type_toggle != '' )
{
$topic_type_toggle = $lang['Post_topic_as'] . ': <input type="radio" name="topictype" value="' . POST_NORMAL .'"' . ( ( $post_data['topic_type'] == POST_NORMAL || $topic_type == POST_NORMAL ) ? ' checked="checked"' : '' ) . ' /> ' . $lang['Post_Normal'] . ' ' . $topic_type_toggle;
}
}
#
#-----[ REPLACE WITH ]----------------------------------------------
#
// BEGIN Advanced Topic Type MOD
//
// Topic type selection
//
$topic_type_toggle = '';
if ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['first_post'] ) )
{
$template->assign_block_vars('switch_type_toggle', array());
$topic_type_toggle .= '<select name="topictype">';
$topic_type_toggle .= '<option value="'. POST_NORMAL .'"' . ( ( $post_data['topic_type'] == POST_NORMAL || $topic_type == POST_NORMAL ) ? ' selected' : '' ) . '>'. $lang['Post_Normal'] .'</option>';
if( $is_auth['auth_sticky'] )
{
$topic_type_toggle .= '<option value="' . POST_STICKY . '"';
if ( $post_data['topic_type'] == POST_STICKY || $topic_type == POST_STICKY )
{
$topic_type_toggle .= ' selected';
}
$topic_type_toggle .= '>'. $lang['Post_Sticky'] . '</option>';
}
if( $is_auth['auth_announce'] )
{
$topic_type_toggle .= '<option value="' . POST_ANNOUNCE . '"';
if ( $post_data['topic_type'] == POST_ANNOUNCE || $topic_type == POST_ANNOUNCE )
{
$topic_type_toggle .= ' selected';
}
$topic_type_toggle .= '>'. $lang['Post_Announcement'] . '</option>';
}
$sql_tt = "SELECT * FROM ". TOPIC_ADD_TYPE_TABLE;
$result_tt = $db->sql_query($sql_tt);
while( $add_type = $db->sql_fetchrow($result_tt) )
{
if( ( ( $userdata['user_level'] >= $add_type['topic_type_auth'] && $add_type['topic_type_auth'] != ADMIN ) || $userdata['user_level'] == ADMIN ) && ( $add_type['topic_type_name'] != 'announce' && $add_type['topic_type_name'] != 'sticky' ) )
{
$topic_add_type = intval( $add_type['topic_type_id'] );
$topic_type_toggle .= '<option value="' . $topic_add_type . '"';
if ( $post_data['topic_type'] == $topic_add_type || $topic_type == $topic_add_type )
{
$topic_type_toggle .= ' selected';
}
$topic_type_toggle .= '>'. stripslashes($add_type['topic_type_name']) . '</option>';
}
}
$topic_type_toggle .= '</select>';
$topic_type_toggle = $lang['Post_topic_as'] . ': '. $topic_type_toggle;
}
// END Advanced Topic Type MOD
#
#-----[ OPEN ]----------------------------------------------
#
viewforum.php
#
#-----[ FIND ]----------------------------------------------
#
AND t.topic_type <> " . POST_ANNOUNCE . "
$limit_topics_time
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
LIMIT $start, ".$board_config['topics_per_page'];
#
#-----[ REPLACE WITH ]----------------------------------------------
#
AND t.topic_type = " . POST_STICKY . "
$limit_topics_time
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC ";
#
#-----[ FIND ]----------------------------------------------
#
$total_topics++;
#
#-----[ REPLACE WITH ]----------------------------------------------
#
$total_stickys++;
#
#-----[ FIND ]----------------------------------------------
#
//
// Total topics ...
//
#
#-----[ BEFORE, ADD ]----------------------------------------------
#
// BEGIN Advanced Topic Type MOD
//
// All topic types added
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type >= " . POST_GLOBAL_ANNOUNCE . "
AND t.topic_type_active = 1
$limit_topics_time
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC ";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
$total_add_types = 0;
while( $row = $db->sql_fetchrow($result) )
{
$topic_rowset[] = $row;
$total_add_types++;
}
$db->sql_freeresult($result);
//
// All normal posts and inactive topic types
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND ( (t.topic_type >= ". POST_GLOBAL_ANNOUNCE ." AND t.topic_type_active = 0 ) OR t.topic_type = " . POST_NORMAL . " )
$limit_topics_time
ORDER BY t.topic_last_post_id DESC
LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
$total_non_active = 0;
while( $row = $db->sql_fetchrow($result) )
{
$topic_rowset[] = $row;
$total_non_active++;
}
$db->sql_freeresult($result);
// END Advanced Topic Type MOD
#
#-----[ FIND ]----------------------------------------------
#
$total_topics += $total_announcements;
#
#-----[ AFTER, ADD ]----------------------------------------------
#
// BEGIN Advanced Topic Type MOD
$total_topics += $total_stickys;
$total_topics += $total_add_types;
$total_topics += $total_non_active;
// END Advanced Topic Type MOD
#
#-----[ FIND ]----------------------------------------------
#
if( $total_topics )
{
for($i = 0; $i < $total_topics; $i++)
{
$topic_id = $topic_rowset[$i]['topic_id'];
$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
$replies = $topic_rowset[$i]['topic_replies'];
$topic_type = $topic_rowset[$i]['topic_type'];
if( $topic_type == POST_ANNOUNCE )
{
$topic_type = $lang['Topic_Announcement'] . ' ';
}
else if( $topic_type == POST_STICKY )
{
$topic_type = $lang['Topic_Sticky'] . ' ';
}
#
#-----[ REPLACE WITH ]----------------------------------------------
#
// BEGIN Advanced Topic Type MOD
$sql = "SELECT t.*, t1.topic_type_color AS announce_color, t2.topic_type_color AS sticky_color
FROM ". TOPIC_ADD_TYPE_TABLE ." t,". TOPIC_ADD_TYPE_TABLE ." t1, ". TOPIC_ADD_TYPE_TABLE ." t2
WHERE t1.topic_type_name = 'announce'
AND t2.topic_type_name = 'sticky'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
while ($tt_row = $db->sql_fetchrow($result))
{
$row[] = $tt_row;
$announce_color = '#'.$tt_row['announce_color'];
$sticky_color = '#'.$tt_row['sticky_color'];
}
// END Advanced Topic Type MOD
if( $total_topics )
{
for($i = 0; $i < $total_topics; $i++)
{
$topic_id = $topic_rowset[$i]['topic_id'];
$topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
$replies = $topic_rowset[$i]['topic_replies'];
$topic_type = $topic_rowset[$i]['topic_type'];
if( $topic_type == POST_ANNOUNCE )
{
$topic_type = '<span style="color:'. $announce_color .'">'. $lang['Topic_Announcement'] . ' </span>';
}
else if( $topic_type == POST_STICKY )
{
$topic_type = '<span style="color:'. $sticky_color .'">'. $lang['Topic_Sticky'] . ' </span>';
}
// BEGIN Advanced Topic Type MOD
//////////////////////////////////////////////////////////////////////////////////////
// little bugfix by lugsciath - without any warranty //
// the bug is very easy: only sticky and announce will be counted - that´s the bug. //
// just do it without any borders and see: it works. //
//////////////////////////////////////////////////////////////////////////////////////
else if ( $topic_type >= POST_GLOBAL_ANNOUNCE)
{
$sql = "SELECT * FROM ". TOPIC_ADD_TYPE_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
while ($tt_row = $db->sql_fetchrow($result))
{
$row[] = $tt_row;
}
///////////////////// End Lugsciath
for($j = 0; $j < count($row); $j++ )
{
if( intval($topic_type) == $row[$j]['topic_type_id'] )
{
$topic_type ='<span style="color:#'. $row[$j]['topic_type_color'] .'"><b>'. $row[$j]['topic_type_name'] .'</b>:</span>';
if( $row[$j]['topic_type_image'] != '' )
{
$folder = $row[$j]['topic_type_image'];
$folder_new = $row[$j]['topic_type_image_new'];
}
else
{
$folder = $images['folder_topic_type'];
$folder_new = $images['folder_topic_type_new']; }
}
}
}
// END Advanced Topic Type MOD
#
#-----[ FIND ]----------------------------------------------
#
else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
else
#
#-----[ REPLACE WITH ]----------------------------------------------
#
else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
{
$folder = $images['folder_locked'];
$folder_new = $images['folder_locked_new'];
}
else if ( $topic_rowset[$i]['topic_type'] < POST_GLOBAL_ANNOUNCE)
#
#-----[ FIND ]----------------------------------------------
#
$topics_count -= $total_announcements;
#
#-----[ REPLACE WITH ]----------------------------------------------
#
$topics_count -= $total_announcements + $total_stickys + $total_add_types;
#
#-----[ OPEN ]----------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]----------------------------------------------
#
?>
#
#-----[ BEFORE, ADD ]----------------------------------------------
#
// BEGIN Advanced Topic Type MOD
$lang['admin_topic_type'] = 'Topic Type Admin';
$lang['Topic_type_gestion'] = 'Topic types management';
$lang['Topic_type_gestion_explain'] = 'This feature allows you to add topic types.';
$lang['Topic_type_name'] = 'Topic type name';
$lang['Color'] = 'Topic type color';
$lang['Topic_type_order'] = 'Topic types order';
$lang['already_first'] = 'Topic type is already first';
$lang['already_last'] = 'Topic type is already last';
$lang['Click_return_admintopictype'] = 'Click %shere%s to go to topic type management';
$lang['tt_updated'] = 'Topic type has been successfully updated';
$lang['tt_added'] = 'Topic type has been successfully added';
$lang['tt_Deleted'] = 'Topic type has been successfuly deleted';
$lang['Add_topic_type'] = 'Add topic type';
$lang['topic_type_active'] = 'Put on top';
$lang['active_explain'] = 'You can choose if you want to put on top the posts with this topic type in viewforum. If you choose not, topic type will be considered as a normal post.';
$lang['topic_type_folder'] = 'Topic type image ( phpBB path )';
$lang['folder_explain'] = 'If no image is associated, a default icon will be shown';
$lang['edit_topic_type'] = 'Edit topic type';
$lang['edit_topic_type_explain'] = 'You can here modify the informations of the topic types';
$lang['Not_active'] = 'Not put on top';
$lang['Actual_color'] = 'Actual color: ';
$lang['Change_color'] = 'Changer color';
$lang['tt_Announce'] = 'Announce';
$lang['topic_type_folder_new'] = 'Topic type image for a new post';
$lang['folder_new_explain'] = 'This icon will be shown when a new message is posted';
// END Advanced Topic Type MOD
#
#-----[ OPEN ]----------------------------------------------
#
templates/subSilver/subSilver.cfg
#
#-----[ FIND ]----------------------------------------------
#
$images['folder_locked_new'] = "$current_template_images/folder_lock_new.gif";
#
#-----[ AFTER, ADD ]----------------------------------------------
#
$images['folder_topic_type'] = "$current_template_images/folder_topic_type.gif";
$images['folder_topic_type_new'] = "$current_template_images/folder_topic_type_new.gif";
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
|
今のところ不具合はありません。
管理者以外でも利用することができます。
以上。
|