diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5db02b774a..3f01b8a024 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -195,7 +195,7 @@ function gen_forum_rules($mode, &$forum_id) foreach ($rules as $rule) { $template->assign_block_vars('rules', array( - 'RULE' => ($auth->acl_gets('f_' . $rule, 'm_', 'a_', $forum_id)) ? $user->lang['RULES_' . strtoupper($rule) . '_CAN'] : $user->lang['RULES_' . strtoupper($rule) . '_CANNOT']) + 'RULE' => ($auth->acl_gets('f_' . $rule, 'm_', 'a_', intval($forum_id))) ? $user->lang['RULES_' . strtoupper($rule) . '_CAN'] : $user->lang['RULES_' . strtoupper($rule) . '_CANNOT']) ); } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4d62320c09..f9e59efefb 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -507,4 +507,43 @@ function generate_smilies($mode) } } +// Generate Topic Icons +function generate_topic_icons($mode, $enable_icons) +{ + global $template, $config; + + if (!$enable_icons) + { + return (false); + } + + $result = false; + + // Grab icons + $icons = array(); + obtain_icons($icons); + + if (sizeof($icons)) + { + $result = true; + + foreach ($icons as $id => $data) + { + if ($data['display']) + { + $template->assign_block_vars('topic_icon', array( + 'ICON_ID' => $id, + 'ICON_IMG' => $phpbb_root_path . $config['icons_path'] . '/' . $data['img'], + 'ICON_WIDTH' => $data['width'], + 'ICON_HEIGHT' => $data['height'], + + 'S_ICON_CHECKED' => ($id == $icon_id && $mode != 'reply') ? ' checked="checked"' : '') + ); + } + } + } + + return ($result); +} + ?> \ No newline at end of file diff --git a/phpBB/language/en/lang_main.php b/phpBB/language/en/lang_main.php index cd64140dd0..c423b69fba 100644 --- a/phpBB/language/en/lang_main.php +++ b/phpBB/language/en/lang_main.php @@ -310,6 +310,7 @@ $lang = array_merge($lang, array( 'POST_TOPIC' => 'Post a new topic', 'POST_REPLY' => 'Post a reply', 'POST_TOPIC_AS' => 'Post topic as', + 'CHANGE_TOPIC_TO' => 'Change topic type to', 'EDIT_POST' => 'Edit post', 'OPTIONS' => 'Options', 'POST_NORMAL' => 'Normal', @@ -318,7 +319,7 @@ $lang = array_merge($lang, array( 'Confirm_delete_poll' => 'Are you sure you want to delete this poll?', 'Cannot_edit_time' => 'You can no longer edit or delete that post', 'FLOOD_ERROR' => 'You cannot make another post so soon after your last, please try again in a short while', - 'Empty_subject' => 'You must specify a subject when posting a new topic', + 'EMPTY_SUBJECT' => 'You must specify a subject when posting a new topic', 'To_long_subject' => 'The subject is too long it must be 60 characters or less', 'EMPTY_MESSAGE' => 'You must enter a message when posting', 'TOO_FEW_CHARS' => 'Your message contains too few characters', @@ -342,9 +343,9 @@ $lang = array_merge($lang, array( 'No_such_post' => 'There is no such post, please return and try again', 'Empty_poll_title' => 'You must enter a title for your poll', - 'Too_few_poll_options' => 'You must enter at least two poll options', - 'Too_many_poll_options' => 'You have tried to enter too many poll options', - 'No_delete_poll_options' => 'You cannot delete existing poll options', + 'TOO_FEW_POLL_OPTIONS' => 'You must enter at least two poll options', + 'TOO_MANY_POLL_OPTIONS' => 'You have tried to enter too many poll options', + 'NO_DELETE_POLL_OPTIONS' => 'You cannot delete existing poll options', 'Post_has_no_poll' => 'This post has no poll', 'Already_voted' => 'You have already voted in this poll', 'No_vote_option' => 'You must specify an option when voting', diff --git a/phpBB/posting.php b/phpBB/posting.php index 7b044a34d9..cd2653c67d 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -53,6 +53,8 @@ $post_id = (!empty($_REQUEST['p'])) ? intval($_REQUEST['p']) : false; $topic_id = (!empty($_REQUEST['t'])) ? intval($_REQUEST['t']) : false; $forum_id = (!empty($_REQUEST['f'])) ? intval($_REQUEST['f']) : false; +$submit = (!empty($_POST['post'])) ? true : false; + // Was cancel pressed? If so then redirect to the appropriate page if (!empty($_REQUEST['cancel'])) { @@ -73,9 +75,9 @@ switch ($mode) trigger_error($user->lang['NO_FORUM']); } - $sql = 'SELECT forum_id, forum_name, forum_parents, forum_status, forum_postable, enable_icons, enable_post_count, enable_moderate - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_id; + $sql = "SELECT forum_id, forum_name, parent_id, forum_parents, forum_status, forum_postable, enable_icons, enable_post_count, enable_moderate + FROM " . FORUMS_TABLE . " + WHERE forum_id = " . $forum_id; break; case 'reply': @@ -84,7 +86,7 @@ switch ($mode) trigger_error($user->lang['NO_TOPIC']); } - $sql = 'SELECT t.*, f.forum_name, f.forum_parents, f.forum_status, f.forum_postable, f.enable_icons, f.enable_post_count, f.enable_moderate + $sql = 'SELECT t.*, f.forum_id, f.forum_name, f.parent_id, f.forum_parents, f.forum_status, f.forum_postable, f.enable_icons, f.enable_post_count, f.enable_moderate FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f WHERE t.topic_id = ' . $topic_id . ' AND f.forum_id = t.forum_id'; @@ -98,7 +100,7 @@ switch ($mode) trigger_error($user->lang['NO_POST']); } - $sql = 'SELECT t.*, p.*, f.forum_name, f.forum_parents, f.forum_status, f.forum_postable, f.enable_icons, f.enable_post_count, f.enable_moderate + $sql = 'SELECT t.*, p.*, f.forum_id, f.forum_name, f.parent_id, f.forum_parents, f.forum_status, f.forum_postable, f.enable_icons, f.enable_post_count, f.enable_moderate FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f WHERE p.post_id = ' . $post_id . ' AND t.topic_id = p.topic_id @@ -184,14 +186,22 @@ if (($mode == 'edit' || $mode == 'delete') && !empty($config['edit_time']) && $p trigger_error($user->lang['CANNOT_EDIT_TIME']); } +// Do we want to edit our post ? +if ( ($mode == 'edit') && (!$auth->acl_get('m_edit', 'a_', intval($forum_id))) ) +{ + if ( ($user->data['user_id'] != $poster_id) ) + { + trigger_error($user->lang['USER_CANNOT_EDIT']); + } +} + // PERMISSION CHECKS // ----------------- - // -------------- // PROCESS SUBMIT -if (isset($_REQUEST['post'])) +if ($submit) { // If replying/quoting and last post id has changed // give user option of continuing submit or return to post @@ -232,7 +242,7 @@ if (isset($_REQUEST['post'])) // Parse message $bbcode_uid = (!empty($bbcode_uid)) ? $bbcode_uid : ''; - if(($result = $parse_msg->parse($message, $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies)) != '') + if (($result = $parse_msg->parse($message, $enable_html, $enable_bbcode, $bbcode_uid, $enable_urls, $enable_smilies)) != '') { $err_msg .= ((!empty($err_msg)) ? '
' : '') . $result; } @@ -270,7 +280,7 @@ if (isset($_REQUEST['post'])) // Parse subject if (($subject = trim(htmlspecialchars(strip_tags($subject)))) == '' && ($mode == 'post' || ($mode == 'edit' && $topic_first_post_id == $post_id))) { - $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['Empty_subject']; + $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['EMPTY_SUBJECT']; } // Process poll options @@ -284,15 +294,15 @@ if (isset($_REQUEST['post'])) if (sizeof($poll_options) == 1) { - $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['Too_few_poll_options']; + $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['TOO_FEW_POLL_OPTIONS']; } else if (sizeof($poll_options) > intval($config['max_poll_options'])) { - $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['Too_many_poll_options']; + $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['TOO_MANY_POLL_OPTIONS']; } else if (sizeof($poll_options) < $poll_options_size) { - $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['No_delete_poll_options']; + $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['NO_DELETE_POLL_OPTIONS']; } $poll_subject = (!empty($poll_subject)) ? trim(htmlspecialchars(strip_tags($poll_subject))) : ''; @@ -305,20 +315,20 @@ if (isset($_REQUEST['post'])) $auth_option = ''; switch ($topic_type) { - case POST_NEWS; - $auth_option = 'news'; + case POST_NEWS: + $auth_option = 'NEWS'; break; - case POST_ANNOUNCE; - $auth_option = 'announce'; + case POST_ANNOUNCE: + $auth_option = 'ANNOUNCE'; break; - case POST_STICKY; - $auth_option = 'sticky'; + case POST_STICKY: + $auth_option = 'STICKY'; break; } if (!$auth->acl_gets('f_' . $auth_option, 'm_', 'a_', intval($forum_id))) { - $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['Cannot_post_' . $auth_option]; + $err_msg .= ((!empty($err_msg)) ? '
' : '') . $user->lang['CANNOT_POST_' . $auth_option]; } } @@ -534,36 +544,44 @@ if (isset($_REQUEST['post'])) // ----------- // DECODE TEXT -> This will/should be handled by bbcode.php eventually -$server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://'; -$server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/'; +if ($mode != 'post') +{ + $server_protocol = ($config['cookie_secure']) ? 'https://' : 'http://'; + $server_port = ($config['server_port'] <> 80) ? ':' . trim($config['server_port']) . '/' : '/'; -$match = array( - '#(.*?)#s', - '#(.*?)#s', - '#.*?#', - '#.*?#', - '#.*?#', - '#.*?#', - '#.*?#', + '#.*?#', + '#.*?#', + '#.*?#', + '#acl_gets('f_sticky', 'm_', 'a_', intval($forum_id))) + $topic_types = array( + 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), + 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT') + ); + + @reset($topic_types); + while (list($auth_key, $topic_value) = each($topic_types)) { - $topic_type_toggle .= 'acl_gets('f_' . $auth_key, 'm_', 'a_', intval($forum_id))) { - $topic_type_toggle .= ' checked="checked"'; + $topic_type_toggle .= 'lang[$topic_value['lang']] . '  '; } - $topic_type_toggle .= ' /> ' . $user->lang['POST_STICKY'] . '  '; - } - - if ($auth->acl_gets('f_announce', 'm_', 'a_', intval($forum_id))) - { - $topic_type_toggle .= 'lang['POST_ANNOUNCEMENT'] . '  '; } if ($topic_type_toggle != '') { - $topic_type_toggle = $user->lang['POST_TOPIC_AS'] . ': ' . $user->lang['POST_NORMAL'] . '  ' . $topic_type_toggle; + $topic_type_toggle = (($mode == 'edit') ? $user->lang['CHANGE_TOPIC_TO'] : $user->lang['POST_TOPIC_AS']) . ': ' . $user->lang['POST_NORMAL'] . '  ' . $topic_type_toggle; } } @@ -654,6 +645,7 @@ switch ($mode) $page_title = $user->lang['POST_TOPIC']; break; + case 'quote': case 'reply': $page_title = $user->lang['POST_REPLY']; $s_action .= '&t=' . intval($topic_id); @@ -665,11 +657,16 @@ switch ($mode) break; } - // Build navigation links +$forum_data = array( + 'parent_id' => intval($parent_id), + 'forum_parents' => $forum_parents, + 'forum_name' => $forum_name, + 'forum_id' => intval($forum_id), + 'forum_desc' => '' +); generate_forum_nav($forum_data); - // Start assigning vars for main posting page ... $template->assign_vars(array( 'FORUM_NAME' => $forum_name, @@ -678,11 +675,11 @@ $template->assign_vars(array( 'USERNAME' => $post_username, 'SUBJECT' => (!empty($topic_title)) ? $topic_title : $post_subject, 'MESSAGE' => trim($post_text), - 'HTML_STATUS' => ($html_status) ? $user->lang['HTML_is_ON'] : $user->lang['HTML_is_OFF'], - 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCode_is_ON'], '', '') : sprintf($user->lang['BBCode_is_OFF'], '', ''), - 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['Smilies_are_ON'] : $user->lang['Smilies_are_OFF'], - 'IMG_STATUS' => ($img_status) ? $user->lang['Images_are_ON'] : $user->lang['Images_are_OFF'], - 'FLASH_STATUS' => ($flash_status) ? $user->lang['Flash_is_ON'] : $user->lang['Flash_is_OFF'], + 'HTML_STATUS' => ($html_status) ? $user->lang['HTML_IS_ON'] : $user->lang['HTML_IS_OFF'], + 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_OFF'], '', ''), + 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], + 'IMG_STATUS' => ($img_status) ? $user->lang['IMAGES_ARE_ON'] : $user->lang['IMAGES_ARE_OFF'], + 'FLASH_STATUS' => ($flash_status) ? $user->lang['FLASH_IS_ON'] : $user->lang['FLASH_IS_OFF'], 'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : $user->lang['NONE'], 'L_POST_A' => $page_title, @@ -742,11 +739,9 @@ if ($auth->acl_gets('f_attach', 'm_edit', 'a_', $forum_id)) ); } - // Output page ... include($phpbb_root_path . 'includes/page_header.'.$phpEx); - $template->set_filenames(array( 'body' => 'posting_body.html') ); @@ -831,7 +826,7 @@ function topic_review($topic_id, $is_inline_review = false) if($poster_id == ANONYMOUS && $row['post_username'] != '') { $poster = $row['post_username']; - $poster_rank = $user->lang['Guest']; + $poster_rank = $user->lang['GUEST']; } $post_subject = ($row['post_subject'] != '') ? $row['post_subject'] : ''; @@ -840,7 +835,7 @@ function topic_review($topic_id, $is_inline_review = false) if ($row['enable_smilies']) { - $message = str_replace('sql_freeresult($result); $template->assign_vars(array( - 'L_MESSAGE' => $user->lang['Message'], - 'L_POSTED' => $user->lang['Posted'], - 'L_POST_SUBJECT'=> $user->lang['Post_subject'], - 'L_TOPIC_REVIEW'=> $user->lang['Topic_review']) + 'L_MESSAGE' => $user->lang['MESSAGE'], + 'L_POSTED' => $user->lang['POSTED'], + 'L_POST_SUBJECT'=> $user->lang['POST_SUBJECT'], + 'L_TOPIC_REVIEW'=> $user->lang['TOPIC_REVIEW']) ); if (!$is_inline_review) { - $page_title = $user->lang['Topic_review'] . ' - ' . $topic_title; + $page_title = $user->lang['TOPIC_REVIEW'] . ' - ' . $topic_title; include($phpbb_root_path . 'includes/page_header.'.$phpEx); $template->set_filenames(array( diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 9193b7fe92..7471dbfe9e 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -139,13 +139,12 @@ if (!$topic_data = $db->sql_fetchrow($result)) trigger_error('NO_TOPIC'); } extract($topic_data); - +$forum_id = intval($forum_id); // Configure style, language, etc. $user->setup(false, intval($forum_style)); $auth->acl($user->data, intval($forum_id)); - // Start auth check if (!$auth->acl_gets('f_read', 'm_', 'a_', intval($forum_id))) { @@ -258,7 +257,6 @@ if (isset($_GET['highlight'])) $s_forum_rules = ''; gen_forum_rules('topic', $forum_id); - // Quick mod tools $topic_mod = ''; $topic_mod .= ($auth->acl_gets('m_lock', 'a_', $forum_id)) ? ((intval($topic_status) == ITEM_UNLOCKED) ? '' : '') : '';