2 /***************************************************************************
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: topic_review.php,v 1.5.2.3 2004/11/18 17:49:45 acydburn Exp $
12 ***************************************************************************/
14 /***************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
22 ***************************************************************************/
24 function topic_review($topic_id, $is_inline_review)
26 global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
27 global $userdata, $user_ip;
28 global $orig_word, $replacement_word;
31 if ( !$is_inline_review )
33 if ( !isset($topic_id) || !$topic_id)
35 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
41 $sql = "SELECT t.topic_title, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments
42 FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
43 WHERE t.topic_id = $topic_id
44 AND f.forum_id = t.forum_id";
45 if ( !($result = $db->sql_query($sql)) )
47 message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
50 if ( !($forum_row = $db->sql_fetchrow($result)) )
52 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
54 $db->sql_freeresult($result);
56 $forum_id = $forum_row['forum_id'];
57 $topic_title = $forum_row['topic_title'];
60 // Start session management
62 $userdata = session_pagestart($user_ip, $forum_id);
63 init_userprefs($userdata);
65 // End session management
69 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
71 if ( !$is_auth['auth_read'] )
73 message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']));
78 // Define censored word matches
80 if ( empty($orig_word) && empty($replacement_word) )
83 $replacement_word = array();
85 obtain_word_list($orig_word, $replacement_word);
89 // Dump out the page header and load viewtopic body template
91 if ( !$is_inline_review )
93 $gen_simple_header = TRUE;
95 $page_title = $lang['Topic_review'] . ' - ' . $topic_title;
96 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
98 $template->set_filenames(array(
99 'reviewbody' => 'posting_topic_review.tpl')
104 // Go ahead and pull all data for this topic
106 $sql = "SELECT u.username, u.user_id, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
107 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
108 WHERE p.topic_id = $topic_id
109 AND p.poster_id = u.user_id
110 AND p.post_id = pt.post_id
111 ORDER BY p.post_time DESC
112 LIMIT " . $board_config['posts_per_page'];
113 if ( !($result = $db->sql_query($sql)) )
115 message_die(GENERAL_ERROR, 'Could not obtain post/user information', '', __LINE__, __FILE__, $sql);
119 // Okay, let's do the loop, yeah come on baby let's do the loop
120 // and it goes like this ...
122 if ( $row = $db->sql_fetchrow($result) )
124 $mini_post_img = $images['icon_minipost'];
125 $mini_post_alt = $lang['Post'];
130 $poster_id = $row['user_id'];
131 $poster = $row['username'];
133 $post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
136 // Handle anon users posting with usernames
138 if( $poster_id == ANONYMOUS && $row['post_username'] != '' )
140 $poster = $row['post_username'];
141 $poster_rank = $lang['Guest'];
143 elseif ( $poster_id == ANONYMOUS )
145 $poster = $lang['Guest'];
149 $post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : '';
151 $message = $row['post_text'];
152 $bbcode_uid = $row['bbcode_uid'];
155 // If the board has HTML off but the post has HTML
156 // on then we process it, else leave it alone
158 if ( !$board_config['allow_html'] && $row['enable_html'] )
160 $message = preg_replace('#(<)([\/]?.*?)(>)#is', '<\2>', $message);
163 if ( $bbcode_uid != "" )
165 $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
168 $message = make_clickable($message);
170 if ( count($orig_word) )
172 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
173 $message = preg_replace($orig_word, $replacement_word, $message);
176 if ( $board_config['allow_smilies'] && $row['enable_smilies'] )
178 $message = smilies_pass($message);
181 $message = str_replace("\n", '<br />', $message);
184 // Again this will be handled by the templating
185 // code at some point
187 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
188 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
190 $template->assign_block_vars('postrow', array(
191 'ROW_COLOR' => '#' . $row_color,
192 'ROW_CLASS' => $row_class,
194 'MINI_POST_IMG' => $mini_post_img,
195 'POSTER_NAME' => $poster,
196 'POST_DATE' => $post_date,
197 'POST_SUBJECT' => $post_subject,
198 'MESSAGE' => $message,
200 'L_MINI_POST_ALT' => $mini_post_alt)
205 while ( $row = $db->sql_fetchrow($result) );
209 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist', '', __LINE__, __FILE__, $sql);
211 $db->sql_freeresult($result);
213 $template->assign_vars(array(
214 'L_AUTHOR' => $lang['Author'],
215 'L_MESSAGE' => $lang['Message'],
216 'L_POSTED' => $lang['Posted'],
217 'L_POST_SUBJECT' => $lang['Post_subject'],
218 'L_TOPIC_REVIEW' => $lang['Topic_review'])
221 if ( !$is_inline_review )
223 $template->pparse('reviewbody');
224 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);