From f0dea060972a48460ce64d3cdf885d82383763c6 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 5 Jan 2008 16:10:10 +0000 Subject: Correctly check empty subjects/messages (Bug #17915) Do not check usernames against word censor list. Disallowed usernames is already checked and word censor belong to posts. (Bug #17745) Additionally include non-postable forums for moderators forums shown within the teams list. (Bug #17265) git-svn-id: file:///svn/phpbb/trunk@8306 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1236361e18..9ddaf52acd 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -520,12 +520,12 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( } else { - if (!$subject || !utf8_clean_string($subject)) + if (utf8_clean_string($subject) === '') { $error[] = $user->lang['EMPTY_SUBJECT']; } - if (!$message) + if (utf8_clean_string($message) === '') { $error[] = $user->lang['TOO_FEW_CHARS']; } @@ -769,7 +769,7 @@ if ($submit || $preview || $refresh) } // Parse subject - if (!$preview && !$refresh && !utf8_clean_string($post_data['post_subject']) && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) + if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) { $error[] = $user->lang['EMPTY_SUBJECT']; } -- cgit v1.2.1 From 4b5fab372ff69a809144dee3a0a7f90c219fe400 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 30 Jan 2008 16:14:39 +0000 Subject: merge with revision #r8350 git-svn-id: file:///svn/phpbb/trunk@8351 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 9ddaf52acd..8a2ece6fde 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -478,7 +478,7 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( $subject = utf8_normalize_nfc(request_var('subject', '', true)); $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; $message = utf8_normalize_nfc(request_var('message', '', true)); - + if ($subject && $message) { if (confirm_box(true)) @@ -620,7 +620,7 @@ if ($submit || $preview || $refresh) $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " WHERE topic_id = $topic_id"; $db->sql_query($sql); - + $topic_sql = array( 'poll_title' => '', 'poll_start' => 0, @@ -674,7 +674,7 @@ if ($submit || $preview || $refresh) // Check checksum ... don't re-parse message if the same $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false; - + // Parse message if ($update_message) { @@ -1073,7 +1073,7 @@ if (!sizeof($error) && $preview) 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, 'POLL_QUESTION' => $parse_poll->message, - + 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options'])) ); @@ -1460,7 +1460,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) } else { - confirm_box(false, 'DELETE_MESSAGE', $s_hidden_fields); + confirm_box(false, 'DELETE_POST', $s_hidden_fields); } } -- cgit v1.2.1 From 9a4a3a089aa4e4384d5462c4bc39dbdd5ec82715 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 1 Feb 2008 13:15:50 +0000 Subject: cross-ci 8362; #15120, #16029 git-svn-id: file:///svn/phpbb/trunk@8363 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 8a2ece6fde..fc83659e3e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -582,7 +582,7 @@ if ($submit || $preview || $refresh) $post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; $post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; $post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1; - $post_data['enable_sig'] = (!$config['allow_sig']) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); + $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); if ($config['allow_topic_notify'] && $user->data['is_registered']) { @@ -1428,6 +1428,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) $data = array( 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], + 'topic_replies_real' => $post_data['topic_replies_real'], 'topic_approved' => $post_data['topic_approved'], 'topic_type' => $post_data['topic_type'], 'post_approved' => $post_data['post_approved'], @@ -1439,7 +1440,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data); - if ($post_data['topic_first_post_id'] == $post_data['topic_last_post_id']) + if ($next_post_id === false) { add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title']); -- cgit v1.2.1 From 65ba4fe94e983bb02d61357470141e959d6412b2 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 14 Feb 2008 12:35:57 +0000 Subject: cross-ci git-svn-id: file:///svn/phpbb/trunk@8382 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index fc83659e3e..dfe7b348a7 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -512,6 +512,7 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( 't' => $topic_id, 'subject' => $subject, 'message' => $message, + 'attachment_data' => $message_parser->attachment_data, ) ); -- cgit v1.2.1 From 2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 29 May 2008 12:25:56 +0000 Subject: ok... i hope i haven't messed too much with the code and everything is still working. Changes: - Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed. - A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added. git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 57 +++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 29 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index dfe7b348a7..af7e26d0db 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -12,12 +12,12 @@ * @ignore */ define('IN_PHPBB', true); -$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); -include($phpbb_root_path . 'includes/functions_posting.' . $phpEx); -include($phpbb_root_path . 'includes/functions_display.' . $phpEx); -include($phpbb_root_path . 'includes/message_parser.' . $phpEx); +if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './'); +if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); +include(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); +include(PHPBB_ROOT_PATH . 'includes/functions_display.' . PHP_EXT); +include(PHPBB_ROOT_PATH . 'includes/message_parser.' . PHP_EXT); // Start session management @@ -49,7 +49,7 @@ $current_time = time(); // Was cancel pressed? If so then redirect to the appropriate page if ($cancel || ($current_time - $lastclick < 2 && $submit)) { - $redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx"))); + $redirect = ($post_id) ? append_sid('viewtopic', 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid('viewtopic', 't=' . $topic_id) : (($forum_id) ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('index'))); redirect($redirect); } @@ -168,7 +168,7 @@ if ($post_data['forum_password']) // Check permissions if ($user->data['is_bot']) { - redirect(append_sid("{$phpbb_root_path}index.$phpEx")); + redirect(append_sid('index')); } // Is the user able to read within this forum? @@ -313,11 +313,11 @@ if ($mode == 'bump') add_log('mod', $forum_id, $topic_id, 'LOG_BUMP_TOPIC', $post_data['topic_title']); - $meta_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}"; + $meta_url = append_sid('viewtopic', "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}"; meta_refresh(3, $meta_url); $message = $user->lang['TOPIC_BUMPED'] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } @@ -493,13 +493,13 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( ); $db->sql_query($sql); - $meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); + $meta_info = ($mode == 'post') ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('viewtopic', "f=$forum_id&t=$topic_id"); meta_refresh(3, $meta_info); $message = $user->lang['DRAFT_SAVED'] . '

'; $message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' : ''; - $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } @@ -730,7 +730,7 @@ if ($submit || $preview || $refresh) // Validate username if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false) { @@ -894,7 +894,7 @@ if ($submit || $preview || $refresh) if (!$to_forum_id) { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + include_once(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT); $template->assign_vars(array( 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), @@ -994,8 +994,8 @@ if ($submit || $preview || $refresh) if ($mode == 'edit') { - $data['topic_replies_real'] = $post_data['topic_replies_real']; - $data['topic_replies'] = $post_data['topic_replies']; + $data['topic_replies_real'] = (int) $post_data['topic_replies_real']; + $data['topic_replies'] = (int) $post_data['topic_replies']; } unset($message_parser); @@ -1018,7 +1018,7 @@ if ($submit || $preview || $refresh) $message = $user->lang[$message] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); } - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } } @@ -1195,7 +1195,7 @@ $notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data $notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set); // Page title & action URL, include session_id for security purpose -$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=$forum_id", true, $user->session_id); +$s_action = append_sid('posting', "mode=$mode&f=$forum_id", true, $user->session_id); $s_action .= ($topic_id) ? "&t=$topic_id" : ''; $s_action .= ($post_id) ? "&p=$post_id" : ''; @@ -1250,7 +1250,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_c $template->assign_vars(array( 'S_CONFIRM_CODE' => true, 'CONFIRM_ID' => $confirm_id, - 'CONFIRM_IMAGE' => '', + 'CONFIRM_IMAGE' => '', 'L_POST_CONFIRM_EXPLAIN' => sprintf($user->lang['POST_CONFIRM_EXPLAIN'], '', ''), )); } @@ -1285,7 +1285,7 @@ $template->assign_vars(array( 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', 'SUBJECT' => $post_data['post_subject'], 'MESSAGE' => $post_data['post_text'], - 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_OFF'], '', ''), + 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_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'], 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], @@ -1295,10 +1295,10 @@ $template->assign_vars(array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], 'EDIT_REASON' => $post_data['post_edit_reason'], - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), - 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', - 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), - 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")), + 'U_VIEW_FORUM' => append_sid('viewforum', "f=$forum_id"), + 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid('viewtopic', "f=$forum_id&t=$topic_id") : '', + 'U_PROGRESS_BAR' => append_sid('posting', "f=$forum_id&mode=popup"), + 'UA_PROGRESS_BAR' => addslashes(append_sid('posting', "f=$forum_id&mode=popup")), 'S_PRIVMSGS' => false, 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, @@ -1372,7 +1372,7 @@ $template->set_filenames(array( 'body' => 'posting_body.html') ); -make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); +make_jumpbox(append_sid('viewforum')); // Topic review if ($mode == 'reply' || $mode == 'quote') @@ -1413,7 +1413,6 @@ function upload_popup($forum_style = 0) function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) { global $user, $db, $auth; - global $phpbb_root_path, $phpEx; // If moderator removing post or user itself removing post, present a confirmation screen if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'])) @@ -1445,19 +1444,19 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) { add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title']); - $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); + $meta_info = append_sid('viewforum', "f=$forum_id"); $message = $user->lang['POST_DELETED']; } else { add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject']); - $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; + $meta_info = append_sid('viewtopic', "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); } meta_refresh(3, $meta_info); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } else -- cgit v1.2.1 From 1aa40171e0677c5307f213f8c58b7156f5885d59 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 8 Jun 2008 21:44:59 +0000 Subject: merge... git-svn-id: file:///svn/phpbb/trunk@8624 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index af7e26d0db..076a9d764e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -998,8 +998,6 @@ if ($submit || $preview || $refresh) $data['topic_replies'] = (int) $post_data['topic_replies']; } - unset($message_parser); - $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); $post_need_approval = (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? true : false; @@ -1155,7 +1153,6 @@ if (sizeof($post_data['poll_options']) && $post_data['poll_title']) $message_parser->decode_message(); $post_data['poll_options'] = explode("\n", $message_parser->message); } -unset($message_parser); // MAIN POSTING PAGE BEGINS HERE -- cgit v1.2.1 From eeba8f456003cdcbdd4a6573b6a3b25250bbccef Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 13 Jun 2008 19:44:40 +0000 Subject: Fix some instances where we left db connections open (registration -> captcha for example) git-svn-id: file:///svn/phpbb/trunk@8656 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 076a9d764e..205f40ecc5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -114,8 +114,7 @@ switch ($mode) else { upload_popup(); - garbage_collection(); - exit_handler(); + exit; } break; @@ -146,7 +145,7 @@ if (!$post_data) if ($mode == 'popup') { upload_popup($post_data['forum_style']); - exit_handler(); + exit; } $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); @@ -277,7 +276,7 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) if ($mode == 'delete') { handle_post_delete($forum_id, $topic_id, $post_id, $post_data); - exit_handler(); + exit; } // Handle bump mode... @@ -1402,6 +1401,9 @@ function upload_popup($forum_style = 0) ); $template->display('popup'); + + garbage_collection(); + exit_handler(); } /** -- cgit v1.2.1 From 3a3b9eb8efe08f086bcbd1d88a34355e31df7650 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Thu, 21 Aug 2008 15:50:21 +0000 Subject: merge git-svn-id: file:///svn/phpbb/trunk@8776 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 205f40ecc5..27e465974c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -282,7 +282,8 @@ if ($mode == 'delete') // Handle bump mode... if ($mode == 'bump') { - if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id'])) + if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) + && check_link_hash(request_var('hash', ''),"topic_{$post_data['topic_id']}")) { $db->sql_transaction('begin'); -- cgit v1.2.1 From 44416f4744b9a55e35c7945a13759d3e7d71fd3d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 4 Sep 2008 14:04:30 +0000 Subject: - queue trigger feature - queued posts do not affect user_posts - show links to MCP + queued posts in ucp and acp git-svn-id: file:///svn/phpbb/trunk@8816 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 27e465974c..973ff4c52f 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -999,10 +999,9 @@ if ($submit || $preview || $refresh) } $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); - $post_need_approval = (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? true : false; - // If the post need approval we will wait a lot longer. - if ($post_need_approval) + // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. + if (($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts'] && !$auth->acl_get('m_approve', $data['forum_id'])) || !$auth->acl_get('f_noapprove', $data['forum_id'])) { meta_refresh(10, $redirect_url); $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; -- cgit v1.2.1 From 24da8c474dd1af6c846d79df243ecd4d2d24f0ee Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 18 Sep 2008 15:06:23 +0000 Subject: remove duplicate statement git-svn-id: file:///svn/phpbb/trunk@8884 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 973ff4c52f..947d34925e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1264,7 +1264,7 @@ if ($solved_captcha !== false) ); } -$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || @ini_get('file_uploads') == '0' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; +$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; add_form_key('posting'); -- cgit v1.2.1 From 461be11e8d0f5d4bd879cf95bd1472dbe985e0b6 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Fri, 19 Sep 2008 13:17:30 +0000 Subject: Okay, that is pretty raw, but better to have it in place than trying to play catch-up. Introducing an early stage of CAPTCHA modules. git-svn-id: file:///svn/phpbb/trunk@8889 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 62 +++++++++++++++---------------------------------------- 1 file changed, 17 insertions(+), 45 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 947d34925e..d1e6684152 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -45,7 +45,13 @@ $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var $error = $post_data = array(); $current_time = time(); - +if ($config['enable_post_confirm'] && !$user->data['is_registered']) +{ + include(PHPBB_ROOT_PATH . 'includes/captcha/captcha_factory.' . PHP_EXT); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_POST); +} + // Was cancel pressed? If so then redirect to the appropriate page if ($cancel || ($current_time - $lastclick < 2 && $submit)) { @@ -741,21 +747,10 @@ if ($submit || $preview || $refresh) if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) { - $confirm_id = request_var('confirm_id', ''); - $confirm_code = request_var('confirm_code', ''); - - $sql = 'SELECT code - FROM ' . CONFIRM_TABLE . " - WHERE confirm_id = '" . $db->sql_escape($confirm_id) . "' - AND session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_POST; - $result = $db->sql_query($sql); - $confirm_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (empty($confirm_row['code']) || strcasecmp($confirm_row['code'], $confirm_code) !== 0) + $vc_response = $captcha->validate(); + if ($vc_response) { - $error[] = $user->lang['CONFIRM_CODE_WRONG']; + $error += $vc_response; } else { @@ -999,7 +994,10 @@ if ($submit || $preview || $refresh) } $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); - + if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) + { + $captcha->reset(); + } // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. if (($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts'] && !$auth->acl_get('m_approve', $data['forum_id'])) || !$auth->acl_get('f_noapprove', $data['forum_id'])) { @@ -1220,34 +1218,11 @@ generate_forum_rules($post_data); if ($config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { - // Show confirm image - $sql = 'DELETE FROM ' . CONFIRM_TABLE . " - WHERE session_id = '" . $db->sql_escape($user->session_id) . "' - AND confirm_type = " . CONFIRM_POST; - $db->sql_query($sql); - - // Generate code - $code = gen_rand_string(mt_rand(5, 8)); - $confirm_id = md5(unique_id($user->ip)); - $seed = hexdec(substr(unique_id(), 4, 10)); - - // compute $seed % 0x7fffffff - $seed -= 0x7fffffff * floor($seed / 0x7fffffff); - - $sql = 'INSERT INTO ' . CONFIRM_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'confirm_id' => (string) $confirm_id, - 'session_id' => (string) $user->session_id, - 'confirm_type' => (int) CONFIRM_POST, - 'code' => (string) $code, - 'seed' => (int) $seed) - ); - $db->sql_query($sql); + $captcha->reset(); $template->assign_vars(array( 'S_CONFIRM_CODE' => true, - 'CONFIRM_ID' => $confirm_id, - 'CONFIRM_IMAGE' => '', - 'L_POST_CONFIRM_EXPLAIN' => sprintf($user->lang['POST_CONFIRM_EXPLAIN'], '', ''), + 'CONFIRM' => $captcha->get_template(), )); } @@ -1258,10 +1233,7 @@ $s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? ' request_var('confirm_id', ''), - 'confirm_code' => request_var('confirm_code', '')) - ); + $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); } $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; -- cgit v1.2.1 From 0f14f278d0fa9d765bb141ab79242a34fa73a883 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 22 Sep 2008 12:37:42 +0000 Subject: fixing some vC bugs (attempt counting and posting) and introducing prototype for reCaptcha git-svn-id: file:///svn/phpbb/trunk@8903 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index d1e6684152..34a46a05aa 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -750,7 +750,7 @@ if ($submit || $preview || $refresh) $vc_response = $captcha->validate(); if ($vc_response) { - $error += $vc_response; + $error[] = $vc_response; } else { -- cgit v1.2.1 From 0a4c62f12e9cfea1215150a580ca76961e1ac7f1 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Fri, 26 Sep 2008 09:28:12 +0000 Subject: Merge in r8924, r8925, r8926, r8936, r8938 git-svn-id: file:///svn/phpbb/trunk@8939 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 34a46a05aa..fc173e7dbd 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1274,7 +1274,7 @@ $template->assign_vars(array( 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) ? true : false, + 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, @@ -1383,10 +1383,10 @@ function upload_popup($forum_style = 0) */ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) { - global $user, $db, $auth; + global $user, $db, $auth, $config; // If moderator removing post or user itself removing post, present a confirmation screen - if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'])) + if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))) { $s_hidden_fields = build_hidden_fields(array( 'p' => $post_id, -- cgit v1.2.1 From ad4d7c036eb144559bbce553afa4952587c28e56 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Tue, 30 Sep 2008 15:18:35 +0000 Subject: merge r8956, r8957 and r8960 git-svn-id: file:///svn/phpbb/trunk@8961 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index fc173e7dbd..1ec693e16f 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -120,7 +120,7 @@ switch ($mode) else { upload_popup(); - exit; + return; } break; @@ -151,7 +151,7 @@ if (!$post_data) if ($mode == 'popup') { upload_popup($post_data['forum_style']); - exit; + return; } $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); @@ -282,7 +282,7 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) if ($mode == 'delete') { handle_post_delete($forum_id, $topic_id, $post_id, $post_data); - exit; + return; } // Handle bump mode... -- cgit v1.2.1 From 9d9d61b1a209098dc30d0905d88575a4f84cb197 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 8 Oct 2008 12:51:43 +0000 Subject: Merge revisions: r8974, r8975, r8976, r8977, r8978, r8979 git-svn-id: file:///svn/phpbb/trunk@8980 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1ec693e16f..32b03fb2f3 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1326,12 +1326,11 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ ); } +// Show attachment box for adding attachments if true +$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); + // Attachment entry -// Not using acl_gets here, because it is using OR logic -if ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype) -{ - posting_gen_attachment_entry($attachment_data, $filename_data); -} +posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); // Output page ... page_header($page_title); -- cgit v1.2.1 From ef0c0d4c82dadfb856357f6ae906263420d84791 Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Thu, 13 Nov 2008 13:04:54 +0000 Subject: been a while :( ... merge in r8997, r8998, r8999, r9000, r9001, r9002, r9003, r9004, r9005, r9007, r9008, r9009, r9010, r9011, r9012, r9013, r9014, r9015, r9022, r9023, r9029, r9030, r9034, r9048, r9049, r9054, r9056 git-svn-id: file:///svn/phpbb/trunk@9064 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 32b03fb2f3..9aec127873 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -999,7 +999,7 @@ if ($submit || $preview || $refresh) $captcha->reset(); } // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. - if (($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts'] && !$auth->acl_get('m_approve', $data['forum_id'])) || !$auth->acl_get('f_noapprove', $data['forum_id'])) + if ((($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) { meta_refresh(10, $redirect_url); $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; -- cgit v1.2.1 From d46e8e6f98054fc58a126c865184369198d9a2ed Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 22 Nov 2008 19:38:25 +0000 Subject: merge revisions i missed... hopefully not breaking things - did not check every change. git-svn-id: file:///svn/phpbb/trunk@9077 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 9aec127873..226cb31dfc 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -289,7 +289,7 @@ if ($mode == 'delete') if ($mode == 'bump') { if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) - && check_link_hash(request_var('hash', ''),"topic_{$post_data['topic_id']}")) + && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) { $db->sql_transaction('begin'); -- cgit v1.2.1 From 07e9b83a3de0264916a058b9cf180b91b297604f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 24 Nov 2008 00:20:33 +0000 Subject: - updated all code to use the request class instead of any direct access to super globals - disabled super globals in common.php. See commit r9101 for more information - cleaned up/simplified a few lines along the way. git-svn-id: file:///svn/phpbb/trunk@9102 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 226cb31dfc..db8fe3576d 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -32,14 +32,14 @@ $forum_id = request_var('f', 0); $draft_id = request_var('d', 0); $lastclick = request_var('lastclick', 0); -$submit = (isset($_POST['post'])) ? true : false; -$preview = (isset($_POST['preview'])) ? true : false; -$save = (isset($_POST['save'])) ? true : false; -$load = (isset($_POST['load'])) ? true : false; -$delete = (isset($_POST['delete'])) ? true : false; -$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; - -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$submit = request::is_set_post('post'); +$preview = request::is_set_post('preview'); +$save = request::is_set_post('save'); +$load = request::is_set_post('load'); +$delete = request::is_set_post('delete'); +$cancel = (request::is_set_post('cancel') && !request::is_set_post('save')) ? true : false; + +$refresh = (request::is_set_post('add_file') || request::is_set_post('delete_file') || request::is_set_post('cancel_unglobalise') || $save || $load) ? true : false; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); @@ -574,35 +574,37 @@ $solved_captcha = false; if ($submit || $preview || $refresh) { + $edit_reason = utf8_normalize_nfc(request_var('edit_reason', '', true)); + $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0); $post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true)); $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); - $post_data['post_edit_reason'] = (!empty($_POST['edit_reason']) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; + $post_data['post_edit_reason'] = (!empty($edit_reason) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? $edit_reason : ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); $post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); $post_data['icon_id'] = request_var('icon', 0); - $post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; - $post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; - $post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1; - $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); + $post_data['enable_bbcode'] = (!$bbcode_status || request::is_set_post('disable_bbcode')) ? false : true; + $post_data['enable_smilies'] = (!$smilies_status || request::is_set_post('disable_smilies')) ? false : true; + $post_data['enable_urls'] = request::is_set_post('disable_magic_url'); + $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((request::is_set_post('attach_sig') && $user->data['is_registered']) ? true : false); if ($config['allow_topic_notify'] && $user->data['is_registered']) { - $notify = (isset($_POST['notify'])) ? true : false; + $notify = request::is_set_post('notify'); } else { $notify = false; } - $topic_lock = (isset($_POST['lock_topic'])) ? true : false; - $post_lock = (isset($_POST['lock_post'])) ? true : false; - $poll_delete = (isset($_POST['poll_delete'])) ? true : false; + $topic_lock = request::is_set_post('lock_topic'); + $post_lock = request::is_set_post('lock_post'); + $poll_delete = request::is_set_post('poll_delete'); if ($submit) { @@ -652,7 +654,7 @@ if ($submit || $preview || $refresh) $post_data['poll_length'] = request_var('poll_length', 0); $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); $post_data['poll_max_options'] = request_var('poll_max_options', 1); - $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; + $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && request::is_set_post('poll_vote_change')) ? 1 : 0; } // If replying/quoting and last post id has changed @@ -1228,7 +1230,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_c $s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; $s_hidden_fields .= ''; -$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; +$s_hidden_fields .= ($draft_id || request::is_set('draft_loaded')) ? '' : ''; // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview if ($solved_captcha !== false) @@ -1269,7 +1271,7 @@ $template->assign_vars(array( 'UA_PROGRESS_BAR' => addslashes(append_sid('posting', "f=$forum_id&mode=popup")), 'S_PRIVMSGS' => false, - 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, + 'S_CLOSE_PROGRESS_WINDOW' => request::is_set_post('add_file'), 'S_EDIT_POST' => ($mode == 'edit') ? true : false, 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, @@ -1319,7 +1321,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ 'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], $config['max_poll_options']), 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', - 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', +// 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, 'POLL_LENGTH' => $post_data['poll_length']) -- cgit v1.2.1 From 5b9a3c9a7d8f8e4590dddf4440ac82c30ef3f730 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 25 Dec 2008 14:47:57 +0000 Subject: add nils' request and super globals class rename request:: to phpbb_request:: git-svn-id: file:///svn/phpbb/trunk@9230 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index db8fe3576d..e5bfc462ea 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -32,14 +32,14 @@ $forum_id = request_var('f', 0); $draft_id = request_var('d', 0); $lastclick = request_var('lastclick', 0); -$submit = request::is_set_post('post'); -$preview = request::is_set_post('preview'); -$save = request::is_set_post('save'); -$load = request::is_set_post('load'); -$delete = request::is_set_post('delete'); -$cancel = (request::is_set_post('cancel') && !request::is_set_post('save')) ? true : false; - -$refresh = (request::is_set_post('add_file') || request::is_set_post('delete_file') || request::is_set_post('cancel_unglobalise') || $save || $load) ? true : false; +$submit = phpbb_request::is_set_post('post'); +$preview = phpbb_request::is_set_post('preview'); +$save = phpbb_request::is_set_post('save'); +$load = phpbb_request::is_set_post('load'); +$delete = phpbb_request::is_set_post('delete'); +$cancel = (phpbb_request::is_set_post('cancel') && !phpbb_request::is_set_post('save')) ? true : false; + +$refresh = (phpbb_request::is_set_post('add_file') || phpbb_request::is_set_post('delete_file') || phpbb_request::is_set_post('cancel_unglobalise') || $save || $load) ? true : false; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); @@ -51,7 +51,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered']) $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST); } - + // Was cancel pressed? If so then redirect to the appropriate page if ($cancel || ($current_time - $lastclick < 2 && $submit)) { @@ -588,23 +588,23 @@ if ($submit || $preview || $refresh) $post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); $post_data['icon_id'] = request_var('icon', 0); - $post_data['enable_bbcode'] = (!$bbcode_status || request::is_set_post('disable_bbcode')) ? false : true; - $post_data['enable_smilies'] = (!$smilies_status || request::is_set_post('disable_smilies')) ? false : true; - $post_data['enable_urls'] = request::is_set_post('disable_magic_url'); - $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((request::is_set_post('attach_sig') && $user->data['is_registered']) ? true : false); + $post_data['enable_bbcode'] = (!$bbcode_status || phpbb_request::is_set_post('disable_bbcode')) ? false : true; + $post_data['enable_smilies'] = (!$smilies_status || phpbb_request::is_set_post('disable_smilies')) ? false : true; + $post_data['enable_urls'] = phpbb_request::is_set_post('disable_magic_url'); + $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && $user->data['is_registered']) ? true : false); if ($config['allow_topic_notify'] && $user->data['is_registered']) { - $notify = request::is_set_post('notify'); + $notify = phpbb_request::is_set_post('notify'); } else { $notify = false; } - $topic_lock = request::is_set_post('lock_topic'); - $post_lock = request::is_set_post('lock_post'); - $poll_delete = request::is_set_post('poll_delete'); + $topic_lock = phpbb_request::is_set_post('lock_topic'); + $post_lock = phpbb_request::is_set_post('lock_post'); + $poll_delete = phpbb_request::is_set_post('poll_delete'); if ($submit) { @@ -654,7 +654,7 @@ if ($submit || $preview || $refresh) $post_data['poll_length'] = request_var('poll_length', 0); $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); $post_data['poll_max_options'] = request_var('poll_max_options', 1); - $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && request::is_set_post('poll_vote_change')) ? 1 : 0; + $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && phpbb_request::is_set_post('poll_vote_change')) ? 1 : 0; } // If replying/quoting and last post id has changed @@ -1230,7 +1230,7 @@ if ($config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_c $s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; $s_hidden_fields .= ''; -$s_hidden_fields .= ($draft_id || request::is_set('draft_loaded')) ? '' : ''; +$s_hidden_fields .= ($draft_id || phpbb_request::is_set('draft_loaded')) ? '' : ''; // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview if ($solved_captcha !== false) @@ -1271,7 +1271,7 @@ $template->assign_vars(array( 'UA_PROGRESS_BAR' => addslashes(append_sid('posting', "f=$forum_id&mode=popup")), 'S_PRIVMSGS' => false, - 'S_CLOSE_PROGRESS_WINDOW' => request::is_set_post('add_file'), + 'S_CLOSE_PROGRESS_WINDOW' => phpbb_request::is_set_post('add_file'), 'S_EDIT_POST' => ($mode == 'edit') ? true : false, 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, -- cgit v1.2.1 From 19aed179e53f9660a7202e2e50816e1cef0f7be9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 28 Dec 2008 23:30:09 +0000 Subject: $config to phpbb::$config git-svn-id: file:///svn/phpbb/trunk@9242 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 72 +++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index e5bfc462ea..e2484dfd15 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -45,10 +45,10 @@ $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var $error = $post_data = array(); $current_time = time(); -if ($config['enable_post_confirm'] && !$user->data['is_registered']) +if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered']) { include(PHPBB_ROOT_PATH . 'includes/captcha/captcha_factory.' . PHP_EXT); - $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha = phpbb_captcha_factory::get_instance(phpbb::$config['captcha_plugin']); $captcha->init(CONFIRM_POST); } @@ -267,7 +267,7 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) trigger_error('USER_CANNOT_EDIT'); } - if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) + if (!($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) { trigger_error('CANNOT_EDIT_TIME'); } @@ -424,9 +424,9 @@ $post_data['enable_urls'] = $post_data['enable_magic_url']; if ($mode != 'edit') { - $post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false; - $post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false; - $post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; + $post_data['enable_sig'] = (phpbb::$config['allow_sig'] && $user->optionget('attachsig')) ? true: false; + $post_data['enable_smilies'] = (phpbb::$config['allow_smilies'] && $user->optionget('smilies')) ? true : false; + $post_data['enable_bbcode'] = (phpbb::$config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; $post_data['enable_urls'] = true; } @@ -453,7 +453,7 @@ if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == $check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); // Check if user is watching this topic -if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered']) +if ($mode != 'post' && phpbb::$config['allow_topic_notify'] && $user->data['is_registered']) { $sql = 'SELECT topic_id FROM ' . TOPICS_WATCH_TABLE . ' @@ -471,11 +471,11 @@ if ($mode == 'edit' && $post_data['bbcode_uid']) } // HTML, BBCode, Smilies, Images and Flash status -$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; -$smilies_status = ($bbcode_status && $config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; +$bbcode_status = (phpbb::$config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; +$smilies_status = ($bbcode_status && phpbb::$config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; $img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false; -$url_status = ($config['allow_post_links']) ? true : false; -$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false; +$url_status = (phpbb::$config['allow_post_links']) ? true : false; +$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && phpbb::$config['allow_post_flash']) ? true : false; $quote_status = ($auth->acl_get('f_reply', $forum_id)) ? true : false; // Save Draft @@ -591,9 +591,9 @@ if ($submit || $preview || $refresh) $post_data['enable_bbcode'] = (!$bbcode_status || phpbb_request::is_set_post('disable_bbcode')) ? false : true; $post_data['enable_smilies'] = (!$smilies_status || phpbb_request::is_set_post('disable_smilies')) ? false : true; $post_data['enable_urls'] = phpbb_request::is_set_post('disable_magic_url'); - $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && $user->data['is_registered']) ? true : false); + $post_data['enable_sig'] = (!phpbb::$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && $user->data['is_registered']) ? true : false); - if ($config['allow_topic_notify'] && $user->data['is_registered']) + if (phpbb::$config['allow_topic_notify'] && $user->data['is_registered']) { $notify = phpbb_request::is_set_post('notify'); } @@ -693,7 +693,7 @@ if ($submit || $preview || $refresh) $message_parser->warn_msg = array(); } - $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); + $message_parser->parse($post_data['enable_bbcode'], (phpbb::$config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, phpbb::$config['allow_post_links']); // On a refresh we do not care about message parsing errors if (sizeof($message_parser->warn_msg) && $refresh) @@ -706,7 +706,7 @@ if ($submit || $preview || $refresh) $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; } - if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) + if ($mode != 'edit' && !$preview && !$refresh && phpbb::$config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) { // Flood check $last_post_time = 0; @@ -720,7 +720,7 @@ if ($submit || $preview || $refresh) $sql = 'SELECT post_time AS last_post_time FROM ' . POSTS_TABLE . " WHERE poster_ip = '" . $user->ip . "' - AND post_time > " . ($current_time - $config['flood_interval']); + AND post_time > " . ($current_time - phpbb::$config['flood_interval']); $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) { @@ -729,7 +729,7 @@ if ($submit || $preview || $refresh) $db->sql_freeresult($result); } - if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) + if ($last_post_time && ($current_time - $last_post_time) < intval(phpbb::$config['flood_interval'])) { $error[] = $user->lang['FLOOD_ERROR']; } @@ -747,7 +747,7 @@ if ($submit || $preview || $refresh) } } - if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) + if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) { $vc_response = $captcha->validate(); if ($vc_response) @@ -849,7 +849,7 @@ if ($submit || $preview || $refresh) } // DNSBL check - if ($config['check_dnsbl'] && !$refresh) + if (phpbb::$config['check_dnsbl'] && !$refresh) { if (($dnsbl = $user->check_dnsbl('post')) !== false) { @@ -996,12 +996,12 @@ if ($submit || $preview || $refresh) } $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); - if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) + if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) { $captcha->reset(); } // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. - if ((($config['enable_queue_trigger'] && $user->data['user_posts'] < $config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) + if (((phpbb::$config['enable_queue_trigger'] && $user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) { meta_refresh(10, $redirect_url); $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; @@ -1033,14 +1033,14 @@ if (!sizeof($error) && $preview) $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; // Signature - if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) + if ($post_data['enable_sig'] && phpbb::$config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) { $parse_sig = new parse_message($preview_signature); $parse_sig->bbcode_uid = $preview_signature_uid; $parse_sig->bbcode_bitfield = $preview_signature_bitfield; // Not sure about parameters for bbcode/smilies/urls... in signatures - $parse_sig->format_display($config['allow_sig_bbcode'], true, $config['allow_sig_smilies']); + $parse_sig->format_display(phpbb::$config['allow_sig_bbcode'], true, phpbb::$config['allow_sig_smilies']); $preview_signature = $parse_sig->message; unset($parse_sig); } @@ -1179,15 +1179,15 @@ if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); } -$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); -$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1); +$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : ((phpbb::$config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); +$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : ((phpbb::$config['allow_smilies']) ? !$user->optionget('smilies') : 1); $urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; $sig_checked = $post_data['enable_sig']; $lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); $lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; // If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting -$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set']; +$notify_set = ($mode != 'edit' && phpbb::$config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set']; $notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set); // Page title & action URL, include session_id for security purpose @@ -1218,7 +1218,7 @@ generate_forum_nav($post_data); // Build Forum Rules generate_forum_rules($post_data); -if ($config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) +if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { $captcha->reset(); @@ -1238,7 +1238,7 @@ if ($solved_captcha !== false) $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); } -$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; +$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !phpbb::$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; add_form_key('posting'); @@ -1246,7 +1246,7 @@ add_form_key('posting'); $template->assign_vars(array( 'L_POST_A' => $page_title, 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', + 'L_MESSAGE_BODY_EXPLAIN' => (intval(phpbb::$config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval(phpbb::$config['max_post_chars'])) : '', 'FORUM_NAME' => $post_data['forum_name'], 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', @@ -1276,14 +1276,14 @@ $template->assign_vars(array( 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, + 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false, + 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && phpbb::$config['allow_sig'] && $user->data['is_registered']) ? true : false, 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true, + 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !phpbb::$config['allow_topic_notify'] || !phpbb::$config['email_enable']) ? false : true, 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', @@ -1318,7 +1318,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - 'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], $config['max_poll_options']), + 'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], phpbb::$config['max_poll_options']), 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', // 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', @@ -1329,7 +1329,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ } // Show attachment box for adding attachments if true -$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); +$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && phpbb::$config['allow_attachments'] && $form_enctype); // Attachment entry posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); @@ -1384,10 +1384,10 @@ function upload_popup($forum_style = 0) */ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) { - global $user, $db, $auth, $config; + global $user, $db, $auth; // If moderator removing post or user itself removing post, present a confirmation screen - if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))) + if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time']))) { $s_hidden_fields = build_hidden_fields(array( 'p' => $post_id, -- cgit v1.2.1 From 794c5749696c9fa2595ed3a1d7c836a0d984e11c Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 15:29:18 +0000 Subject: remove global and change $user-> to phpbb::$user-> git-svn-id: file:///svn/phpbb/trunk@9334 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 216 +++++++++++++++++++++++++++--------------------------- 1 file changed, 106 insertions(+), 110 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index e2484dfd15..7f1b798f9d 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -21,8 +21,8 @@ include(PHPBB_ROOT_PATH . 'includes/message_parser.' . PHP_EXT); // Start session management -$user->session_begin(); -$auth->acl($user->data); +phpbb::$user->session_begin(); +$auth->acl(phpbb::$user->data); // Grab only parameters needed here @@ -45,7 +45,7 @@ $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var $error = $post_data = array(); $current_time = time(); -if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered']) +if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered) { include(PHPBB_ROOT_PATH . 'includes/captcha/captcha_factory.' . PHP_EXT); $captcha = phpbb_captcha_factory::get_instance(phpbb::$config['captcha_plugin']); @@ -92,7 +92,7 @@ switch ($mode) case 'delete': if (!$post_id) { - $user->setup('posting'); + phpbb::$user->setup('posting'); trigger_error('NO_POST'); } @@ -131,19 +131,19 @@ switch ($mode) if (!$sql) { - $user->setup('posting'); + phpbb::$user->setup('posting'); trigger_error('NO_POST_MODE'); } $result = $db->sql_query($sql); $post_data = $db->sql_fetchrow($result); -$db->sql_freeresult($result); +phpbb::$db->sql_freeresult($result); if (!$post_data) { if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply')) { - $user->setup('posting'); + phpbb::$user->setup('posting'); } trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); } @@ -154,7 +154,7 @@ if ($mode == 'popup') return; } -$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); +phpbb::$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); // Use post_row values in favor of submitted ones... $forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; @@ -171,7 +171,7 @@ if ($post_data['forum_password']) } // Check permissions -if ($user->data['is_bot']) +if (phpbb::$user->is_bot) { redirect(append_sid('index')); } @@ -179,12 +179,12 @@ if ($user->data['is_bot']) // Is the user able to read within this forum? if (!$auth->acl_get('f_read', $forum_id)) { - if ($user->data['user_id'] != ANONYMOUS) + if (phpbb::$user->data['user_id'] != ANONYMOUS) { trigger_error('USER_CANNOT_READ'); } - login_box('', $user->lang['LOGIN_EXPLAIN_POST']); + login_box('', phpbb::$user->lang['LOGIN_EXPLAIN_POST']); } // Permission to do the action asked? @@ -220,14 +220,14 @@ switch ($mode) break; case 'edit': - if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id)) + if (phpbb::$user->is_registered && $auth->acl_gets('f_edit', 'm_edit', $forum_id)) { $is_authed = true; } break; case 'delete': - if ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id)) + if (phpbb::$user->is_registered && $auth->acl_gets('f_delete', 'm_delete', $forum_id)) { $is_authed = true; } @@ -238,12 +238,12 @@ if (!$is_authed) { $check_auth = ($mode == 'quote') ? 'reply' : $mode; - if ($user->data['is_registered']) + if (phpbb::$user->is_registered) { trigger_error('USER_CANNOT_' . strtoupper($check_auth)); } - login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); + login_box('', phpbb::$user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); } // Is the user able to post within this forum? @@ -262,7 +262,7 @@ if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_statu // else it depends on editing times, lock status and if we're the correct user if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) { - if ($user->data['user_id'] != $post_data['poster_id']) + if (phpbb::$user->data['user_id'] != $post_data['poster_id']) { trigger_error('USER_CANNOT_EDIT'); } @@ -302,7 +302,7 @@ if ($mode == 'bump') $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_post_time = $current_time, topic_bumped = 1, - topic_bumper = " . $user->data['user_id'] . " + topic_bumper = " . phpbb::$user->data['user_id'] . " WHERE topic_id = $topic_id"; $db->sql_query($sql); @@ -310,7 +310,7 @@ if ($mode == 'bump') $sql = 'UPDATE ' . USERS_TABLE . " SET user_lastpost_time = $current_time - WHERE user_id = " . $user->data['user_id']; + WHERE user_id = " . phpbb::$user->data['user_id']; $db->sql_query($sql); $db->sql_transaction('commit'); @@ -322,8 +322,8 @@ if ($mode == 'bump') $meta_url = append_sid('viewtopic', "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}"; meta_refresh(3, $meta_url); - $message = $user->lang['TOPIC_BUMPED'] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message = phpbb::$user->lang['TOPIC_BUMPED'] . '

' . sprintf(phpbb::$user->lang['VIEW_MESSAGE'], '', ''); + $message .= '

' . sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } @@ -340,7 +340,7 @@ if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == // Determine some vars if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) { - $post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST']; + $post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : phpbb::$user->lang['GUEST']; } else { @@ -382,7 +382,7 @@ if (isset($post_data['post_text'])) } // Set some default variables -$uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); +$uninit = array('post_attachment' => 0, 'poster_id' => phpbb::$user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); foreach ($uninit as $var_name => $default_value) { @@ -424,20 +424,20 @@ $post_data['enable_urls'] = $post_data['enable_magic_url']; if ($mode != 'edit') { - $post_data['enable_sig'] = (phpbb::$config['allow_sig'] && $user->optionget('attachsig')) ? true: false; - $post_data['enable_smilies'] = (phpbb::$config['allow_smilies'] && $user->optionget('smilies')) ? true : false; - $post_data['enable_bbcode'] = (phpbb::$config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; + $post_data['enable_sig'] = (phpbb::$config['allow_sig'] && phpbb::$user->optionget('attachsig')) ? true: false; + $post_data['enable_smilies'] = (phpbb::$config['allow_smilies'] && phpbb::$user->optionget('smilies')) ? true : false; + $post_data['enable_bbcode'] = (phpbb::$config['allow_bbcode'] && phpbb::$user->optionget('bbcode')) ? true : false; $post_data['enable_urls'] = true; } $post_data['enable_magic_url'] = $post_data['drafts'] = false; // User own some drafts? -if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) +if (phpbb::$user->is_registered && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) { $sql = 'SELECT draft_id FROM ' . DRAFTS_TABLE . ' - WHERE user_id = ' . $user->data['user_id'] . + WHERE user_id = ' . phpbb::$user->data['user_id'] . (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . (($draft_id) ? " AND draft_id <> $draft_id" : ''); @@ -453,12 +453,12 @@ if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == $check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); // Check if user is watching this topic -if ($mode != 'post' && phpbb::$config['allow_topic_notify'] && $user->data['is_registered']) +if ($mode != 'post' && phpbb::$config['allow_topic_notify'] && phpbb::$user->is_registered) { $sql = 'SELECT topic_id FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . $topic_id . ' - AND user_id = ' . $user->data['user_id']; + AND user_id = ' . phpbb::$user->data['user_id']; $result = $db->sql_query($sql); $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); $db->sql_freeresult($result); @@ -479,7 +479,7 @@ $flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && phpbb $quote_status = ($auth->acl_get('f_reply', $forum_id)) ? true : false; // Save Draft -if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) +if ($save && phpbb::$user->is_registered && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) { $subject = utf8_normalize_nfc(request_var('subject', '', true)); $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; @@ -490,7 +490,7 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( if (confirm_box(true)) { $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( - 'user_id' => (int) $user->data['user_id'], + 'user_id' => (int) phpbb::$user->data['user_id'], 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, 'save_time' => (int) $current_time, @@ -503,9 +503,9 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( meta_refresh(3, $meta_info); - $message = $user->lang['DRAFT_SAVED'] . '

'; - $message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' : ''; - $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); + $message = phpbb::$user->lang['DRAFT_SAVED'] . '

'; + $message .= ($mode != 'post') ? sprintf(phpbb::$user->lang['RETURN_TOPIC'], '', '') . '

' : ''; + $message .= sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } @@ -529,24 +529,24 @@ if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ( { if (utf8_clean_string($subject) === '') { - $error[] = $user->lang['EMPTY_SUBJECT']; + $error[] = phpbb::$user->lang['EMPTY_SUBJECT']; } if (utf8_clean_string($message) === '') { - $error[] = $user->lang['TOO_FEW_CHARS']; + $error[] = phpbb::$user->lang['TOO_FEW_CHARS']; } } unset($subject, $message); } // Load requested Draft -if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) +if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && phpbb::$user->is_registered && $auth->acl_get('u_savedrafts')) { $sql = 'SELECT draft_subject, draft_message FROM ' . DRAFTS_TABLE . " WHERE draft_id = $draft_id - AND user_id = " . $user->data['user_id']; + AND user_id = " . phpbb::$user->data['user_id']; $result = $db->sql_query_limit($sql, 1); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -591,9 +591,9 @@ if ($submit || $preview || $refresh) $post_data['enable_bbcode'] = (!$bbcode_status || phpbb_request::is_set_post('disable_bbcode')) ? false : true; $post_data['enable_smilies'] = (!$smilies_status || phpbb_request::is_set_post('disable_smilies')) ? false : true; $post_data['enable_urls'] = phpbb_request::is_set_post('disable_magic_url'); - $post_data['enable_sig'] = (!phpbb::$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && $user->data['is_registered']) ? true : false); + $post_data['enable_sig'] = (!phpbb::$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && phpbb::$user->is_registered) ? true : false); - if (phpbb::$config['allow_topic_notify'] && $user->data['is_registered']) + if (phpbb::$config['allow_topic_notify'] && phpbb::$user->is_registered) { $notify = phpbb_request::is_set_post('notify'); } @@ -618,7 +618,7 @@ if ($submit || $preview || $refresh) // Delete Poll if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) && - ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) + ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) { if ($submit && check_form_key('posting')) { @@ -711,15 +711,15 @@ if ($submit || $preview || $refresh) // Flood check $last_post_time = 0; - if ($user->data['is_registered']) + if (phpbb::$user->is_registered) { - $last_post_time = $user->data['user_lastpost_time']; + $last_post_time = phpbb::$user->data['user_lastpost_time']; } else { $sql = 'SELECT post_time AS last_post_time FROM ' . POSTS_TABLE . " - WHERE poster_ip = '" . $user->ip . "' + WHERE poster_ip = '" . phpbb::$user->ip . "' AND post_time > " . ($current_time - phpbb::$config['flood_interval']); $result = $db->sql_query_limit($sql, 1); if ($row = $db->sql_fetchrow($result)) @@ -731,23 +731,23 @@ if ($submit || $preview || $refresh) if ($last_post_time && ($current_time - $last_post_time) < intval(phpbb::$config['flood_interval'])) { - $error[] = $user->lang['FLOOD_ERROR']; + $error[] = phpbb::$user->lang['FLOOD_ERROR']; } } // Validate username - if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) + if (($post_data['username'] && !phpbb::$user->is_registered) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) { include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false) { - $user->add_lang('ucp'); - $error[] = $user->lang[$result . '_USERNAME']; + phpbb::$user->add_lang('ucp'); + $error[] = phpbb::$user->lang[$result . '_USERNAME']; } } - if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) + if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered && in_array($mode, array('quote', 'post', 'reply'))) { $vc_response = $captcha->validate(); if ($vc_response) @@ -763,13 +763,13 @@ if ($submit || $preview || $refresh) // check form if (($submit || $preview) && !check_form_key('posting')) { - $error[] = $user->lang['FORM_INVALID']; + $error[] = phpbb::$user->lang['FORM_INVALID']; } // Parse subject if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) { - $error[] = $user->lang['EMPTY_SUBJECT']; + $error[] = phpbb::$user->lang['EMPTY_SUBJECT']; } $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; @@ -800,7 +800,7 @@ if ($submit || $preview || $refresh) /* We reset votes, therefore also allow removing options if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size)) { - $message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS']; + $message_parser->warn_msg[] = phpbb::$user->lang['NO_DELETE_POLL_OPTIONS']; }*/ } else @@ -838,7 +838,7 @@ if ($submit || $preview || $refresh) } else { - $error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))]; + $error[] = phpbb::$user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))]; } } } @@ -851,9 +851,9 @@ if ($submit || $preview || $refresh) // DNSBL check if (phpbb::$config['check_dnsbl'] && !$refresh) { - if (($dnsbl = $user->check_dnsbl('post')) !== false) + if (($dnsbl = phpbb::$user->check_dnsbl('post')) !== false) { - $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); + $error[] = sprintf(phpbb::$user->lang['IP_BLACKLISTED'], phpbb::$user->ip, $dnsbl[1]); } } @@ -918,7 +918,7 @@ if ($submit || $preview || $refresh) { // Lock/Unlock Topic $change_topic_status = $post_data['topic_status']; - $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; + $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) { @@ -937,7 +937,7 @@ if ($submit || $preview || $refresh) AND topic_moved_id = 0"; $db->sql_query($sql); - $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; + $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && phpbb::$user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']); } @@ -972,12 +972,12 @@ if ($submit || $preview || $refresh) 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time, 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', 'post_edit_reason' => $post_data['post_edit_reason'], - 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), + 'post_edit_user' => ($mode == 'edit') ? phpbb::$user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), 'forum_parents' => $post_data['forum_parents'], 'forum_name' => $post_data['forum_name'], 'notify' => $notify, 'notify_set' => $post_data['notify_set'], - 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip, + 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : phpbb::$user->ip, 'post_edit_locked' => (int) $post_data['post_edit_locked'], 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, @@ -996,26 +996,26 @@ if ($submit || $preview || $refresh) } $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); - if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) + if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered && in_array($mode, array('quote', 'post', 'reply'))) { $captcha->reset(); } // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. - if (((phpbb::$config['enable_queue_trigger'] && $user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) + if (((phpbb::$config['enable_queue_trigger'] && phpbb::$user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) { meta_refresh(10, $redirect_url); - $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; - $message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']); + $message = ($mode == 'edit') ? phpbb::$user->lang['POST_EDITED_MOD'] : phpbb::$user->lang['POST_STORED_MOD']; + $message .= ((phpbb::$user->is_guest) ? '' : ' '. phpbb::$user->lang['POST_APPROVAL_NOTIFY']); } else { meta_refresh(3, $redirect_url); $message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'; - $message = $user->lang[$message] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); + $message = phpbb::$user->lang[$message] . '

' . sprintf(phpbb::$user->lang['VIEW_MESSAGE'], '', ''); } - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= '

' . sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } } @@ -1028,9 +1028,9 @@ if (!sizeof($error) && $preview) $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); - $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig']; - $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid']; - $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; + $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : phpbb::$user->data['user_sig']; + $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : phpbb::$user->data['user_sig_bbcode_uid']; + $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : phpbb::$user->data['user_sig_bbcode_bitfield']; // Signature if ($post_data['enable_sig'] && phpbb::$config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) @@ -1072,8 +1072,8 @@ if (!sizeof($error) && $preview) 'POLL_QUESTION' => $parse_poll->message, - 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', - 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options'])) + 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf(phpbb::$user->lang['POLL_RUN_TILL'], phpbb::$user->format_date($poll_end)) : '', + 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? phpbb::$user->lang['MAX_OPTION_SELECT'] : sprintf(phpbb::$user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options'])) ); $parse_poll->message = implode("\n", $post_data['poll_options']); @@ -1179,36 +1179,36 @@ if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); } -$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : ((phpbb::$config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); -$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : ((phpbb::$config['allow_smilies']) ? !$user->optionget('smilies') : 1); +$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : ((phpbb::$config['allow_bbcode']) ? !phpbb::$user->optionget('bbcode') : 1); +$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : ((phpbb::$config['allow_smilies']) ? !phpbb::$user->optionget('smilies') : 1); $urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; $sig_checked = $post_data['enable_sig']; $lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); $lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; // If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting -$notify_set = ($mode != 'edit' && phpbb::$config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set']; -$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set); +$notify_set = ($mode != 'edit' && phpbb::$config['allow_topic_notify'] && phpbb::$user->is_registered && !$post_data['notify_set']) ? phpbb::$user->data['user_notify'] : $post_data['notify_set']; +$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? phpbb::$user->data['user_notify'] : $notify_set); // Page title & action URL, include session_id for security purpose -$s_action = append_sid('posting', "mode=$mode&f=$forum_id", true, $user->session_id); +$s_action = append_sid('posting', "mode=$mode&f=$forum_id", true, phpbb::$user->session_id); $s_action .= ($topic_id) ? "&t=$topic_id" : ''; $s_action .= ($post_id) ? "&p=$post_id" : ''; switch ($mode) { case 'post': - $page_title = $user->lang['POST_TOPIC']; + $page_title = phpbb::$user->lang['POST_TOPIC']; break; case 'quote': case 'reply': - $page_title = $user->lang['POST_REPLY']; + $page_title = phpbb::$user->lang['POST_REPLY']; break; case 'delete': case 'edit': - $page_title = $user->lang['EDIT_POST']; + $page_title = phpbb::$user->lang['EDIT_POST']; break; } @@ -1218,7 +1218,7 @@ generate_forum_nav($post_data); // Build Forum Rules generate_forum_rules($post_data); -if (phpbb::$config['enable_post_confirm'] && !$user->data['is_registered'] && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) +if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { $captcha->reset(); @@ -1245,8 +1245,8 @@ add_form_key('posting'); // Start assigning vars for main posting page ... $template->assign_vars(array( 'L_POST_A' => $page_title, - 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => (intval(phpbb::$config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval(phpbb::$config['max_post_chars'])) : '', + 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? phpbb::$user->lang['POST_ICON'] : phpbb::$user->lang['TOPIC_ICON'], + 'L_MESSAGE_BODY_EXPLAIN' => (intval(phpbb::$config['max_post_chars'])) ? sprintf(phpbb::$user->lang['MESSAGE_BODY_EXPLAIN'], intval(phpbb::$config['max_post_chars'])) : '', 'FORUM_NAME' => $post_data['forum_name'], 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', @@ -1255,13 +1255,13 @@ $template->assign_vars(array( 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', 'SUBJECT' => $post_data['post_subject'], 'MESSAGE' => $post_data['post_text'], - 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_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'], - 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], - 'URL_STATUS' => ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], - 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), - 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', + 'BBCODE_STATUS' => ($bbcode_status) ? sprintf(phpbb::$user->lang['BBCODE_IS_ON'], '', '') : sprintf(phpbb::$user->lang['BBCODE_IS_OFF'], '', ''), + 'IMG_STATUS' => ($img_status) ? phpbb::$user->lang['IMAGES_ARE_ON'] : phpbb::$user->lang['IMAGES_ARE_OFF'], + 'FLASH_STATUS' => ($flash_status) ? phpbb::$user->lang['FLASH_IS_ON'] : phpbb::$user->lang['FLASH_IS_OFF'], + 'SMILIES_STATUS' => ($smilies_status) ? phpbb::$user->lang['SMILIES_ARE_ON'] : phpbb::$user->lang['SMILIES_ARE_OFF'], + 'URL_STATUS' => ($bbcode_status && $url_status) ? phpbb::$user->lang['URL_IS_ON'] : phpbb::$user->lang['URL_IS_OFF'], + 'MINI_POST_IMG' => phpbb::$user->img('icon_post_target', 'POST'), + 'POST_DATE' => ($post_data['post_time']) ? phpbb::$user->format_date($post_data['post_time']) : '', 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], 'EDIT_REASON' => $post_data['post_edit_reason'], @@ -1274,26 +1274,26 @@ $template->assign_vars(array( 'S_CLOSE_PROGRESS_WINDOW' => phpbb_request::is_set_post('add_file'), 'S_EDIT_POST' => ($mode == 'edit') ? true : false, 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, - 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, + 'S_DISPLAY_USERNAME' => (!phpbb::$user->is_registered || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, + 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && phpbb::$config['allow_sig'] && $user->data['is_registered']) ? true : false, + 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && phpbb::$config['allow_sig'] && phpbb::$user->is_registered) ? true : false, 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !phpbb::$config['allow_topic_notify'] || !phpbb::$config['email_enable']) ? false : true, + 'S_NOTIFY_ALLOWED' => (!phpbb::$user->is_registered || ($mode == 'edit' && phpbb::$user->data['user_id'] != $post_data['poster_id']) || !phpbb::$config['allow_topic_notify'] || !phpbb::$config['email_enable']) ? false : true, 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', - 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, + 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, - 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $mode != 'edit') ? true : false, - 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false, + 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && phpbb::$user->is_registered && $mode != 'edit') ? true : false, + 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && phpbb::$user->is_registered && $post_data['drafts']) ? true : false, 'S_FORM_ENCTYPE' => $form_enctype, 'S_BBCODE_IMG' => $img_status, @@ -1315,10 +1315,10 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ $template->assign_vars(array( 'S_SHOW_POLL_BOX' => true, 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), + 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - 'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], phpbb::$config['max_poll_options']), + 'L_POLL_OPTIONS_EXPLAIN' => sprintf(phpbb::$user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], phpbb::$config['max_poll_options']), 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', // 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', @@ -1359,18 +1359,16 @@ page_footer(); */ function upload_popup($forum_style = 0) { - global $template, $user; + ($forum_style) ? phpbb::$user->setup('posting', $forum_style) : phpbb::$user->setup('posting'); - ($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting'); - - page_header($user->lang['PROGRESS_BAR']); + page_header(phpbb::$user->lang['PROGRESS_BAR']); $template->set_filenames(array( 'popup' => 'posting_progress_bar.html') ); $template->assign_vars(array( - 'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS'])) + 'PROGRESS_BAR' => phpbb::$user->img('upload_bar', 'UPLOAD_IN_PROGRESS')) ); $template->display('popup'); @@ -1384,10 +1382,8 @@ function upload_popup($forum_style = 0) */ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) { - global $user, $db, $auth; - // If moderator removing post or user itself removing post, present a confirmation screen - if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time']))) + if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$user->is_registered && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time']))) { $s_hidden_fields = build_hidden_fields(array( 'p' => $post_id, @@ -1417,18 +1413,18 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title']); $meta_info = append_sid('viewforum', "f=$forum_id"); - $message = $user->lang['POST_DELETED']; + $message = phpbb::$user->lang['POST_DELETED']; } else { add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject']); $meta_info = append_sid('viewtopic', "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; - $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + $message = phpbb::$user->lang['POST_DELETED'] . '

' . sprintf(phpbb::$user->lang['RETURN_TOPIC'], '', ''); } meta_refresh(3, $meta_info); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= '

' . sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); trigger_error($message); } else @@ -1438,12 +1434,12 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) } // If we are here the user is not able to delete - present the correct error message - if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) + if ($post_data['poster_id'] != phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) { trigger_error('DELETE_OWN_POSTS'); } - if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) + if ($post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) { trigger_error('CANNOT_DELETE_REPLIED'); } -- cgit v1.2.1 From 95b69cfa7f66e721cea3f8a5d62ad1cb2b822cfc Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 15:48:29 +0000 Subject: $auth-> to phpbb::$acl-> git-svn-id: file:///svn/phpbb/trunk@9335 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 104 +++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 7f1b798f9d..97efb7329e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -22,7 +22,7 @@ include(PHPBB_ROOT_PATH . 'includes/message_parser.' . PHP_EXT); // Start session management phpbb::$user->session_begin(); -$auth->acl(phpbb::$user->data); +phpbb::$acl->init(phpbb::$user->data); // Grab only parameters needed here @@ -177,7 +177,7 @@ if (phpbb::$user->is_bot) } // Is the user able to read within this forum? -if (!$auth->acl_get('f_read', $forum_id)) +if (!phpbb::$acl->acl_get('f_read', $forum_id)) { if (phpbb::$user->data['user_id'] != ANONYMOUS) { @@ -193,14 +193,14 @@ $is_authed = false; switch ($mode) { case 'post': - if ($auth->acl_get('f_post', $forum_id)) + if (phpbb::$acl->acl_get('f_post', $forum_id)) { $is_authed = true; } break; case 'bump': - if ($auth->acl_get('f_bump', $forum_id)) + if (phpbb::$acl->acl_get('f_bump', $forum_id)) { $is_authed = true; } @@ -213,21 +213,21 @@ switch ($mode) // no break; case 'reply': - if ($auth->acl_get('f_reply', $forum_id)) + if (phpbb::$acl->acl_get('f_reply', $forum_id)) { $is_authed = true; } break; case 'edit': - if (phpbb::$user->is_registered && $auth->acl_gets('f_edit', 'm_edit', $forum_id)) + if (phpbb::$user->is_registered && phpbb::$acl->acl_gets('f_edit', 'm_edit', $forum_id)) { $is_authed = true; } break; case 'delete': - if (phpbb::$user->is_registered && $auth->acl_gets('f_delete', 'm_delete', $forum_id)) + if (phpbb::$user->is_registered && phpbb::$acl->acl_gets('f_delete', 'm_delete', $forum_id)) { $is_authed = true; } @@ -253,14 +253,14 @@ if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bum } // Forum/Topic locked? -if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id)) +if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !phpbb::$acl->acl_get('m_edit', $forum_id)) { trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); } // Can we edit this post ... if we're a moderator with rights then always yes // else it depends on editing times, lock status and if we're the correct user -if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) +if ($mode == 'edit' && !phpbb::$acl->acl_get('m_edit', $forum_id)) { if (phpbb::$user->data['user_id'] != $post_data['poster_id']) { @@ -433,7 +433,7 @@ if ($mode != 'edit') $post_data['enable_magic_url'] = $post_data['drafts'] = false; // User own some drafts? -if (phpbb::$user->is_registered && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) +if (phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) { $sql = 'SELECT draft_id FROM ' . DRAFTS_TABLE . ' @@ -471,15 +471,15 @@ if ($mode == 'edit' && $post_data['bbcode_uid']) } // HTML, BBCode, Smilies, Images and Flash status -$bbcode_status = (phpbb::$config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; -$smilies_status = ($bbcode_status && phpbb::$config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; -$img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false; +$bbcode_status = (phpbb::$config['allow_bbcode'] && phpbb::$acl->acl_get('f_bbcode', $forum_id)) ? true : false; +$smilies_status = ($bbcode_status && phpbb::$config['allow_smilies'] && phpbb::$acl->acl_get('f_smilies', $forum_id)) ? true : false; +$img_status = ($bbcode_status && phpbb::$acl->acl_get('f_img', $forum_id)) ? true : false; $url_status = (phpbb::$config['allow_post_links']) ? true : false; -$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && phpbb::$config['allow_post_flash']) ? true : false; -$quote_status = ($auth->acl_get('f_reply', $forum_id)) ? true : false; +$flash_status = ($bbcode_status && phpbb::$acl->acl_get('f_flash', $forum_id) && phpbb::$config['allow_post_flash']) ? true : false; +$quote_status = (phpbb::$acl->acl_get('f_reply', $forum_id)) ? true : false; // Save Draft -if ($save && phpbb::$user->is_registered && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) +if ($save && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) { $subject = utf8_normalize_nfc(request_var('subject', '', true)); $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; @@ -541,7 +541,7 @@ if ($save && phpbb::$user->is_registered && $auth->acl_get('u_savedrafts') && ($ } // Load requested Draft -if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && phpbb::$user->is_registered && $auth->acl_get('u_savedrafts')) +if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts')) { $sql = 'SELECT draft_subject, draft_message FROM ' . DRAFTS_TABLE . " @@ -581,7 +581,7 @@ if ($submit || $preview || $refresh) $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); - $post_data['post_edit_reason'] = (!empty($edit_reason) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? $edit_reason : ''; + $post_data['post_edit_reason'] = (!empty($edit_reason) && $mode == 'edit' && phpbb::$acl->acl_get('m_edit', $forum_id)) ? $edit_reason : ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); @@ -591,7 +591,7 @@ if ($submit || $preview || $refresh) $post_data['enable_bbcode'] = (!$bbcode_status || phpbb_request::is_set_post('disable_bbcode')) ? false : true; $post_data['enable_smilies'] = (!$smilies_status || phpbb_request::is_set_post('disable_smilies')) ? false : true; $post_data['enable_urls'] = phpbb_request::is_set_post('disable_magic_url'); - $post_data['enable_sig'] = (!phpbb::$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && phpbb::$user->is_registered) ? true : false); + $post_data['enable_sig'] = (!phpbb::$config['allow_sig'] || !phpbb::$acl->acl_get('f_sigs', $forum_id) || !phpbb::$acl->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && phpbb::$user->is_registered) ? true : false); if (phpbb::$config['allow_topic_notify'] && phpbb::$user->is_registered) { @@ -618,7 +618,7 @@ if ($submit || $preview || $refresh) // Delete Poll if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) && - ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) + ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id)) || phpbb::$acl->acl_get('m_delete', $forum_id))) { if ($submit && check_form_key('posting')) { @@ -654,7 +654,7 @@ if ($submit || $preview || $refresh) $post_data['poll_length'] = request_var('poll_length', 0); $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); $post_data['poll_max_options'] = request_var('poll_max_options', 1); - $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && phpbb_request::is_set_post('poll_vote_change')) ? 1 : 0; + $post_data['poll_vote_change'] = (phpbb::$acl->acl_get('f_votechg', $forum_id) && phpbb_request::is_set_post('poll_vote_change')) ? 1 : 0; } // If replying/quoting and last post id has changed @@ -706,7 +706,7 @@ if ($submit || $preview || $refresh) $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; } - if ($mode != 'edit' && !$preview && !$refresh && phpbb::$config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) + if ($mode != 'edit' && !$preview && !$refresh && phpbb::$config['flood_interval'] && !phpbb::$acl->acl_get('f_ignoreflood', $forum_id)) { // Flood check $last_post_time = 0; @@ -775,8 +775,8 @@ if ($submit || $preview || $refresh) $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; if ($post_data['poll_option_text'] && - ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) + ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || phpbb::$acl->acl_get('m_edit', $forum_id))*/)) + && phpbb::$acl->acl_get('f_poll', $forum_id)) { $poll = array( 'poll_title' => $post_data['poll_title'], @@ -827,7 +827,7 @@ if ($submit || $preview || $refresh) break; } - if (!$auth->acl_get($auth_option, $forum_id)) + if (!phpbb::$acl->acl_get($auth_option, $forum_id)) { // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod. // Another case would be a mod not having sticky permissions for example but edit permissions. @@ -883,7 +883,7 @@ if ($submit || $preview || $refresh) $forum_type = (int) $db->sql_fetchfield('forum_type'); $db->sql_freeresult($result); - if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id)) + if ($forum_type != FORUM_POST || !phpbb::$acl->acl_get('f_post', $to_forum_id)) { $to_forum_id = 0; } @@ -903,7 +903,7 @@ if ($submit || $preview || $refresh) } else { - if (!$auth->acl_get('f_post', $to_forum_id)) + if (!phpbb::$acl->acl_get('f_post', $to_forum_id)) { // This will only be triggered if the user tried to trick the forum. trigger_error('NOT_AUTHORISED'); @@ -918,7 +918,7 @@ if ($submit || $preview || $refresh) { // Lock/Unlock Topic $change_topic_status = $post_data['topic_status']; - $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; + $perm_lock_unlock = (phpbb::$acl->acl_get('m_lock', $forum_id) || (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) { @@ -937,17 +937,17 @@ if ($submit || $preview || $refresh) AND topic_moved_id = 0"; $db->sql_query($sql); - $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && phpbb::$user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; + $user_lock = (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && phpbb::$user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']); } // Lock/Unlock Post Edit - if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) + if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && phpbb::$acl->acl_get('m_edit', $forum_id)) { $post_data['post_edit_locked'] = ITEM_UNLOCKED; } - else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) + else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && phpbb::$acl->acl_get('m_edit', $forum_id)) { $post_data['post_edit_locked'] = ITEM_LOCKED; } @@ -1001,7 +1001,7 @@ if ($submit || $preview || $refresh) $captcha->reset(); } // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. - if (((phpbb::$config['enable_queue_trigger'] && phpbb::$user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !$auth->acl_get('f_noapprove', $data['forum_id'])) && !$auth->acl_get('m_approve', $data['forum_id'])) + if (((phpbb::$config['enable_queue_trigger'] && phpbb::$user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !phpbb::$acl->acl_get('f_noapprove', $data['forum_id'])) && !phpbb::$acl->acl_get('m_approve', $data['forum_id'])) { meta_refresh(10, $redirect_url); $message = ($mode == 'edit') ? phpbb::$user->lang['POST_EDITED_MOD'] : phpbb::$user->lang['POST_STORED_MOD']; @@ -1033,7 +1033,7 @@ if (!sizeof($error) && $preview) $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : phpbb::$user->data['user_sig_bbcode_bitfield']; // Signature - if ($post_data['enable_sig'] && phpbb::$config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) + if ($post_data['enable_sig'] && phpbb::$config['allow_sig'] && $preview_signature && phpbb::$acl->acl_get('f_sigs', $forum_id)) { $parse_sig = new parse_message($preview_signature); $parse_sig->bbcode_uid = $preview_signature_uid; @@ -1052,8 +1052,8 @@ if (!sizeof($error) && $preview) $preview_subject = censor_text($post_data['post_subject']); // Poll Preview - if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) + if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || phpbb::$acl->acl_get('m_edit', $forum_id))*/)) + && phpbb::$acl->acl_get('f_poll', $forum_id)) { $parse_poll = new parse_message($post_data['poll_title']); $parse_poll->bbcode_uid = $message_parser->bbcode_uid; @@ -1174,7 +1174,7 @@ if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_p } $s_topic_icons = false; -if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) +if ($post_data['enable_icons'] && phpbb::$acl->acl_get('f_icons', $forum_id)) { $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); } @@ -1238,7 +1238,7 @@ if ($solved_captcha !== false) $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); } -$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !phpbb::$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; +$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !phpbb::$config['allow_attachments'] || !phpbb::$acl->acl_get('u_attach') || !phpbb::$acl->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; add_form_key('posting'); @@ -1273,27 +1273,27 @@ $template->assign_vars(array( 'S_PRIVMSGS' => false, 'S_CLOSE_PROGRESS_WINDOW' => phpbb_request::is_set_post('add_file'), 'S_EDIT_POST' => ($mode == 'edit') ? true : false, - 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, + 'S_EDIT_REASON' => ($mode == 'edit' && phpbb::$acl->acl_get('m_edit', $forum_id)) ? true : false, 'S_DISPLAY_USERNAME' => (!phpbb::$user->is_registered || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, + 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) || phpbb::$acl->acl_get('m_delete', $forum_id))) ? true : false, 'S_BBCODE_ALLOWED' => $bbcode_status, 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && phpbb::$config['allow_sig'] && phpbb::$user->is_registered) ? true : false, + 'S_SIG_ALLOWED' => (phpbb::$acl->acl_get('f_sigs', $forum_id) && phpbb::$config['allow_sig'] && phpbb::$user->is_registered) ? true : false, 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', 'S_NOTIFY_ALLOWED' => (!phpbb::$user->is_registered || ($mode == 'edit' && phpbb::$user->data['user_id'] != $post_data['poster_id']) || !phpbb::$config['allow_topic_notify'] || !phpbb::$config['email_enable']) ? false : true, 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', - 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, + 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && (phpbb::$acl->acl_get('m_lock', $forum_id) || (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', - 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, + 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && phpbb::$acl->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, - 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && phpbb::$user->is_registered && $mode != 'edit') ? true : false, - 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && phpbb::$user->is_registered && $post_data['drafts']) ? true : false, + 'S_SAVE_ALLOWED' => (phpbb::$acl->acl_get('u_savedrafts') && phpbb::$user->is_registered && $mode != 'edit') ? true : false, + 'S_HAS_DRAFTS' => (phpbb::$acl->acl_get('u_savedrafts') && phpbb::$user->is_registered && $post_data['drafts']) ? true : false, 'S_FORM_ENCTYPE' => $form_enctype, 'S_BBCODE_IMG' => $img_status, @@ -1309,13 +1309,13 @@ $template->assign_vars(array( display_custom_bbcodes(); // Poll entry -if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) +if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || phpbb::$acl->acl_get('m_edit', $forum_id))*/)) + && phpbb::$acl->acl_get('f_poll', $forum_id)) { $template->assign_vars(array( 'S_SHOW_POLL_BOX' => true, - 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), + 'S_POLL_VOTE_CHANGE' => (phpbb::$acl->acl_get('f_votechg', $forum_id)), + 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id)) || phpbb::$acl->acl_get('m_delete', $forum_id))), 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, 'L_POLL_OPTIONS_EXPLAIN' => sprintf(phpbb::$user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], phpbb::$config['max_poll_options']), @@ -1329,7 +1329,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ } // Show attachment box for adding attachments if true -$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && phpbb::$config['allow_attachments'] && $form_enctype); +$allowed = (phpbb::$acl->acl_get('f_attach', $forum_id) && phpbb::$acl->acl_get('u_attach') && phpbb::$config['allow_attachments'] && $form_enctype); // Attachment entry posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); @@ -1383,7 +1383,7 @@ function upload_popup($forum_style = 0) function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) { // If moderator removing post or user itself removing post, present a confirmation screen - if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$user->is_registered && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time']))) + if (phpbb::$acl->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$user->is_registered && phpbb::$acl->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time']))) { $s_hidden_fields = build_hidden_fields(array( 'p' => $post_id, @@ -1434,12 +1434,12 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) } // If we are here the user is not able to delete - present the correct error message - if ($post_data['poster_id'] != phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) + if ($post_data['poster_id'] != phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id)) { trigger_error('DELETE_OWN_POSTS'); } - if ($post_data['poster_id'] == phpbb::$user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) + if ($post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) { trigger_error('CANNOT_DELETE_REPLIED'); } -- cgit v1.2.1 From 84f795e9fbd172924280593d575bf4587c9b40e5 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 18:06:05 +0000 Subject: $db-> to phpbb::$db-> git-svn-id: file:///svn/phpbb/trunk@9336 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 76 +++++++++++++++++++++++++++---------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 97efb7329e..fb63919499 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -135,8 +135,8 @@ if (!$sql) trigger_error('NO_POST_MODE'); } -$result = $db->sql_query($sql); -$post_data = $db->sql_fetchrow($result); +$result = phpbb::$db->sql_query($sql); +$post_data = phpbb::$db->sql_fetchrow($result); phpbb::$db->sql_freeresult($result); if (!$post_data) @@ -291,29 +291,29 @@ if ($mode == 'bump') if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) { - $db->sql_transaction('begin'); + phpbb::$db->sql_transaction('begin'); $sql = 'UPDATE ' . POSTS_TABLE . " SET post_time = $current_time WHERE post_id = {$post_data['topic_last_post_id']} AND topic_id = $topic_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $sql = 'UPDATE ' . TOPICS_TABLE . " SET topic_last_post_time = $current_time, topic_bumped = 1, topic_bumper = " . phpbb::$user->data['user_id'] . " WHERE topic_id = $topic_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); update_post_information('forum', $forum_id); $sql = 'UPDATE ' . USERS_TABLE . " SET user_lastpost_time = $current_time WHERE user_id = " . phpbb::$user->data['user_id']; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); - $db->sql_transaction('commit'); + phpbb::$db->sql_transaction('commit'); markread('post', $forum_id, $topic_id, $current_time); @@ -362,13 +362,13 @@ if ($post_data['poll_start']) FROM ' . POLL_OPTIONS_TABLE . " WHERE topic_id = $topic_id ORDER BY poll_option_id"; - $result = $db->sql_query($sql); + $result = phpbb::$db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + while ($row = phpbb::$db->sql_fetchrow($result)) { $post_data['poll_options'][] = trim($row['poll_option_text']); } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } $orig_poll_options_size = sizeof($post_data['poll_options']); @@ -406,9 +406,9 @@ if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode AND in_message = 0 AND is_orphan = 0 ORDER BY filetime DESC"; - $result = $db->sql_query($sql); - $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $message_parser->attachment_data = array_merge($message_parser->attachment_data, phpbb::$db->sql_fetchrowset($result)); + phpbb::$db->sql_freeresult($result); } if ($post_data['poster_id'] == ANONYMOUS) @@ -441,13 +441,13 @@ if (phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') && ($mod (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . (($draft_id) ? " AND draft_id <> $draft_id" : ''); - $result = $db->sql_query_limit($sql, 1); + $result = phpbb::$db->sql_query_limit($sql, 1); - if ($db->sql_fetchrow($result)) + if (phpbb::$db->sql_fetchrow($result)) { $post_data['drafts'] = true; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } $check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); @@ -459,9 +459,9 @@ if ($mode != 'post' && phpbb::$config['allow_topic_notify'] && phpbb::$user->is_ FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . $topic_id . ' AND user_id = ' . phpbb::$user->data['user_id']; - $result = $db->sql_query($sql); - $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $post_data['notify_set'] = (int) phpbb::$db->sql_fetchfield('topic_id'); + phpbb::$db->sql_freeresult($result); } // Do we want to edit our post ? @@ -489,7 +489,7 @@ if ($save && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') { if (confirm_box(true)) { - $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array( 'user_id' => (int) phpbb::$user->data['user_id'], 'topic_id' => (int) $topic_id, 'forum_id' => (int) $forum_id, @@ -497,7 +497,7 @@ if ($save && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') 'draft_subject' => (string) $subject, 'draft_message' => (string) $message) ); - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $meta_info = ($mode == 'post') ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('viewtopic', "f=$forum_id&t=$topic_id"); @@ -547,9 +547,9 @@ if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && ph FROM ' . DRAFTS_TABLE . " WHERE draft_id = $draft_id AND user_id = " . phpbb::$user->data['user_id']; - $result = $db->sql_query_limit($sql, 1); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query_limit($sql, 1); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); if ($row) { @@ -624,11 +624,11 @@ if ($submit || $preview || $refresh) { $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " WHERE topic_id = $topic_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " WHERE topic_id = $topic_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $topic_sql = array( 'poll_title' => '', @@ -640,9 +640,9 @@ if ($submit || $preview || $refresh) ); $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $topic_sql) . " + SET ' . phpbb::$db->sql_build_array('UPDATE', $topic_sql) . " WHERE topic_id = $topic_id"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); } $post_data['poll_title'] = $post_data['poll_option_text'] = ''; @@ -721,12 +721,12 @@ if ($submit || $preview || $refresh) FROM ' . POSTS_TABLE . " WHERE poster_ip = '" . phpbb::$user->ip . "' AND post_time > " . ($current_time - phpbb::$config['flood_interval']); - $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) + $result = phpbb::$db->sql_query_limit($sql, 1); + if ($row = phpbb::$db->sql_fetchrow($result)) { $last_post_time = $row['last_post_time']; } - $db->sql_freeresult($result); + phpbb::$db->sql_freeresult($result); } if ($last_post_time && ($current_time - $last_post_time) < intval(phpbb::$config['flood_interval'])) @@ -866,9 +866,9 @@ if ($submit || $preview || $refresh) $sql = 'SELECT topic_type, forum_id FROM ' . TOPICS_TABLE . " WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) { @@ -879,9 +879,9 @@ if ($submit || $preview || $refresh) $sql = 'SELECT forum_type FROM ' . FORUMS_TABLE . ' WHERE forum_id = ' . $to_forum_id; - $result = $db->sql_query($sql); - $forum_type = (int) $db->sql_fetchfield('forum_type'); - $db->sql_freeresult($result); + $result = phpbb::$db->sql_query($sql); + $forum_type = (int) phpbb::$db->sql_fetchfield('forum_type'); + phpbb::$db->sql_freeresult($result); if ($forum_type != FORUM_POST || !phpbb::$acl->acl_get('f_post', $to_forum_id)) { @@ -935,7 +935,7 @@ if ($submit || $preview || $refresh) SET topic_status = $change_topic_status WHERE topic_id = $topic_id AND topic_moved_id = 0"; - $db->sql_query($sql); + phpbb::$db->sql_query($sql); $user_lock = (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && phpbb::$user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; -- cgit v1.2.1 From b27add94f8eb36d5e740afadf5306c48873736f9 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 18:56:09 +0000 Subject: $template to phpbb::$template git-svn-id: file:///svn/phpbb/trunk@9337 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index fb63919499..0811a63c15 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -334,7 +334,7 @@ if ($mode == 'bump') // Subject length limiting to 60 characters if first post... if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id'])) { - $template->assign_var('S_NEW_MESSAGE', true); + phpbb::$template->assign_var('S_NEW_MESSAGE', true); } // Determine some vars @@ -556,7 +556,7 @@ if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && ph $post_data['post_subject'] = $row['draft_subject']; $message_parser->message = $row['draft_message']; - $template->assign_var('S_DRAFT_LOADED', true); + phpbb::$template->assign_var('S_DRAFT_LOADED', true); } else { @@ -667,7 +667,7 @@ if ($submit || $preview || $refresh) { if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id'])) { - $template->assign_var('S_POST_REVIEW', true); + phpbb::$template->assign_var('S_POST_REVIEW', true); } $submit = false; @@ -893,10 +893,10 @@ if ($submit || $preview || $refresh) { include_once(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), - 'S_UNGLOBALISE' => true) - ); + 'S_UNGLOBALISE' => true, + )); $submit = false; $refresh = true; @@ -1066,15 +1066,15 @@ if (!sizeof($error) && $preview) $poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time()); } - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_HAS_POLL_OPTIONS' => (sizeof($post_data['poll_options'])), 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, 'POLL_QUESTION' => $parse_poll->message, 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf(phpbb::$user->lang['POLL_RUN_TILL'], phpbb::$user->format_date($poll_end)) : '', - 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? phpbb::$user->lang['MAX_OPTION_SELECT'] : sprintf(phpbb::$user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options'])) - ); + 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? phpbb::$user->lang['MAX_OPTION_SELECT'] : sprintf(phpbb::$user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options']), + )); $parse_poll->message = implode("\n", $post_data['poll_options']); $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); @@ -1083,10 +1083,10 @@ if (!sizeof($error) && $preview) foreach ($preview_poll_options as $key => $option) { - $template->assign_block_vars('poll_option', array( + phpbb::$template->assign_block_vars('poll_option', array( 'POLL_OPTION_CAPTION' => $option, - 'POLL_OPTION_ID' => $key + 1) - ); + 'POLL_OPTION_ID' => $key + 1, + )); } unset($preview_poll_options); } @@ -1094,7 +1094,7 @@ if (!sizeof($error) && $preview) // Attachment Preview if (sizeof($message_parser->attachment_data)) { - $template->assign_var('S_HAS_ATTACHMENTS', true); + phpbb::$template->assign_var('S_HAS_ATTACHMENTS', true); $update_count = array(); $attachment_data = $message_parser->attachment_data; @@ -1103,22 +1103,22 @@ if (!sizeof($error) && $preview) foreach ($attachment_data as $i => $attachment) { - $template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment) - ); + phpbb::$template->assign_block_vars('attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment, + )); } unset($attachment_data); } if (!sizeof($error)) { - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'PREVIEW_SUBJECT' => $preview_subject, 'PREVIEW_MESSAGE' => $preview_message, 'PREVIEW_SIGNATURE' => $preview_signature, - 'S_DISPLAY_PREVIEW' => true) - ); + 'S_DISPLAY_PREVIEW' => true, + )); } } @@ -1222,7 +1222,7 @@ if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered && $so { $captcha->reset(); - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_CONFIRM_CODE' => true, 'CONFIRM' => $captcha->get_template(), )); @@ -1243,7 +1243,7 @@ add_form_key('posting'); // Start assigning vars for main posting page ... -$template->assign_vars(array( +phpbb::$template->assign_vars(array( 'L_POST_A' => $page_title, 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? phpbb::$user->lang['POST_ICON'] : phpbb::$user->lang['TOPIC_ICON'], 'L_MESSAGE_BODY_EXPLAIN' => (intval(phpbb::$config['max_post_chars'])) ? sprintf(phpbb::$user->lang['MESSAGE_BODY_EXPLAIN'], intval(phpbb::$config['max_post_chars'])) : '', @@ -1302,8 +1302,8 @@ $template->assign_vars(array( 'S_BBCODE_QUOTE' => $quote_status, 'S_POST_ACTION' => $s_action, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) -); + 'S_HIDDEN_FIELDS' => $s_hidden_fields, +)); // Build custom bbcodes array display_custom_bbcodes(); @@ -1312,7 +1312,7 @@ display_custom_bbcodes(); if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || phpbb::$acl->acl_get('m_edit', $forum_id))*/)) && phpbb::$acl->acl_get('f_poll', $forum_id)) { - $template->assign_vars(array( + phpbb::$template->assign_vars(array( 'S_SHOW_POLL_BOX' => true, 'S_POLL_VOTE_CHANGE' => (phpbb::$acl->acl_get('f_votechg', $forum_id)), 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id)) || phpbb::$acl->acl_get('m_delete', $forum_id))), @@ -1324,8 +1324,8 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ // 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, - 'POLL_LENGTH' => $post_data['poll_length']) - ); + 'POLL_LENGTH' => $post_data['poll_length'], + )); } // Show attachment box for adding attachments if true @@ -1337,9 +1337,9 @@ posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); // Output page ... page_header($page_title); -$template->set_filenames(array( - 'body' => 'posting_body.html') -); +phpbb::$template->set_filenames(array( + 'body' => 'posting_body.html', +)); make_jumpbox(append_sid('viewforum')); @@ -1348,7 +1348,7 @@ if ($mode == 'reply' || $mode == 'quote') { if (topic_review($topic_id, $forum_id)) { - $template->assign_var('S_DISPLAY_REVIEW', true); + phpbb::$template->assign_var('S_DISPLAY_REVIEW', true); } } @@ -1363,15 +1363,15 @@ function upload_popup($forum_style = 0) page_header(phpbb::$user->lang['PROGRESS_BAR']); - $template->set_filenames(array( - 'popup' => 'posting_progress_bar.html') - ); + phpbb::$template->set_filenames(array( + 'popup' => 'posting_progress_bar.html', + )); - $template->assign_vars(array( - 'PROGRESS_BAR' => phpbb::$user->img('upload_bar', 'UPLOAD_IN_PROGRESS')) - ); + phpbb::$template->assign_vars(array( + 'PROGRESS_BAR' => phpbb::$user->img('upload_bar', 'UPLOAD_IN_PROGRESS'), + )); - $template->display('popup'); + phpbb::$template->display('popup'); garbage_collection(); exit_handler(); -- cgit v1.2.1 From d181f0ef36f4cfbc8726da21e4de864df3a6f3d2 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Feb 2009 19:17:10 +0000 Subject: append_sid wrapper + is_guest git-svn-id: file:///svn/phpbb/trunk@9338 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 0811a63c15..73417d0ee1 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -179,7 +179,7 @@ if (phpbb::$user->is_bot) // Is the user able to read within this forum? if (!phpbb::$acl->acl_get('f_read', $forum_id)) { - if (phpbb::$user->data['user_id'] != ANONYMOUS) + if (!phpbb::$user->is_guest) { trigger_error('USER_CANNOT_READ'); } -- cgit v1.2.1 From 4cbf6bc703bdadf716197b68a89b3438247ff022 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 22 Mar 2009 16:34:26 +0000 Subject: Merge most changes from 3.0.x branch since the 25th december. (Captcha changes for refreshing captcha image not included) git-svn-id: file:///svn/phpbb/trunk@9404 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 73417d0ee1..f5ad0961fd 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -102,7 +102,8 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)"; + OR f.forum_id = $forum_id)" . + (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); break; case 'smilies': @@ -1260,6 +1261,7 @@ phpbb::$template->assign_vars(array( 'FLASH_STATUS' => ($flash_status) ? phpbb::$user->lang['FLASH_IS_ON'] : phpbb::$user->lang['FLASH_IS_OFF'], 'SMILIES_STATUS' => ($smilies_status) ? phpbb::$user->lang['SMILIES_ARE_ON'] : phpbb::$user->lang['SMILIES_ARE_OFF'], 'URL_STATUS' => ($bbcode_status && $url_status) ? phpbb::$user->lang['URL_IS_ON'] : phpbb::$user->lang['URL_IS_OFF'], + 'MAX_FONT_SIZE' => (int) phpbb::$config['max_post_font_size'], 'MINI_POST_IMG' => phpbb::$user->img('icon_post_target', 'POST'), 'POST_DATE' => ($post_data['post_time']) ? phpbb::$user->format_date($post_data['post_time']) : '', 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', -- cgit v1.2.1 From 1042152a55ab2d0764c446949a77f085ab7a77f3 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sat, 18 Apr 2009 15:09:19 +0000 Subject: Merge changes made in revisions #r9405 to #r9467 2009-04-18 git-svn-id: file:///svn/phpbb/trunk@9468 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f5ad0961fd..4c0dcc2481 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -55,7 +55,8 @@ if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered) // Was cancel pressed? If so then redirect to the appropriate page if ($cancel || ($current_time - $lastclick < 2 && $submit)) { - $redirect = ($post_id) ? append_sid('viewtopic', 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid('viewtopic', 't=' . $topic_id) : (($forum_id) ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('index'))); + $f = ($forum_id) ? 'f=' . $forum_id . '&' : ''; + $redirect = ($post_id) ? append_sid('viewtopic', $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid('viewtopic', $f . 't=' . $topic_id) : (($forum_id) ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('index'))); redirect($redirect); } -- cgit v1.2.1 From bf8ac19eaa8d74f9dfd6d597190f5664e7339382 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 18:13:59 +0000 Subject: Move trunk/phpBB to old_trunk/phpBB git-svn-id: file:///svn/phpbb/trunk@10210 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 1453 ----------------------------------------------------- 1 file changed, 1453 deletions(-) delete mode 100644 phpBB/posting.php (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php deleted file mode 100644 index 4c0dcc2481..0000000000 --- a/phpBB/posting.php +++ /dev/null @@ -1,1453 +0,0 @@ -session_begin(); -phpbb::$acl->init(phpbb::$user->data); - - -// Grab only parameters needed here -$post_id = request_var('p', 0); -$topic_id = request_var('t', 0); -$forum_id = request_var('f', 0); -$draft_id = request_var('d', 0); -$lastclick = request_var('lastclick', 0); - -$submit = phpbb_request::is_set_post('post'); -$preview = phpbb_request::is_set_post('preview'); -$save = phpbb_request::is_set_post('save'); -$load = phpbb_request::is_set_post('load'); -$delete = phpbb_request::is_set_post('delete'); -$cancel = (phpbb_request::is_set_post('cancel') && !phpbb_request::is_set_post('save')) ? true : false; - -$refresh = (phpbb_request::is_set_post('add_file') || phpbb_request::is_set_post('delete_file') || phpbb_request::is_set_post('cancel_unglobalise') || $save || $load) ? true : false; -$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); - -$error = $post_data = array(); -$current_time = time(); - -if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered) -{ - include(PHPBB_ROOT_PATH . 'includes/captcha/captcha_factory.' . PHP_EXT); - $captcha = phpbb_captcha_factory::get_instance(phpbb::$config['captcha_plugin']); - $captcha->init(CONFIRM_POST); -} - -// Was cancel pressed? If so then redirect to the appropriate page -if ($cancel || ($current_time - $lastclick < 2 && $submit)) -{ - $f = ($forum_id) ? 'f=' . $forum_id . '&' : ''; - $redirect = ($post_id) ? append_sid('viewtopic', $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid('viewtopic', $f . 't=' . $topic_id) : (($forum_id) ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('index'))); - redirect($redirect); -} - -if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id) -{ - trigger_error('NO_FORUM'); -} - -// We need to know some basic information in all cases before we do anything. -switch ($mode) -{ - case 'post': - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - break; - - case 'bump': - case 'reply': - if (!$topic_id) - { - trigger_error('NO_TOPIC'); - } - - $sql = 'SELECT f.*, t.* - FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f - WHERE t.topic_id = $topic_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)"; - break; - - case 'quote': - case 'edit': - case 'delete': - if (!$post_id) - { - phpbb::$user->setup('posting'); - trigger_error('NO_POST'); - } - - $sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield - FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u - WHERE p.post_id = $post_id - AND t.topic_id = p.topic_id - AND u.user_id = p.poster_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); - break; - - case 'smilies': - $sql = ''; - generate_smilies('window', $forum_id); - break; - - case 'popup': - if ($forum_id) - { - $sql = 'SELECT forum_style - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_id; - } - else - { - upload_popup(); - return; - } - break; - - default: - $sql = ''; - break; -} - -if (!$sql) -{ - phpbb::$user->setup('posting'); - trigger_error('NO_POST_MODE'); -} - -$result = phpbb::$db->sql_query($sql); -$post_data = phpbb::$db->sql_fetchrow($result); -phpbb::$db->sql_freeresult($result); - -if (!$post_data) -{ - if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply')) - { - phpbb::$user->setup('posting'); - } - trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); -} - -if ($mode == 'popup') -{ - upload_popup($post_data['forum_style']); - return; -} - -phpbb::$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); - -// Use post_row values in favor of submitted ones... -$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; -$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id; -$post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id; - -// Need to login to passworded forum first? -if ($post_data['forum_password']) -{ - login_forum_box(array( - 'forum_id' => $forum_id, - 'forum_password' => $post_data['forum_password']) - ); -} - -// Check permissions -if (phpbb::$user->is_bot) -{ - redirect(append_sid('index')); -} - -// Is the user able to read within this forum? -if (!phpbb::$acl->acl_get('f_read', $forum_id)) -{ - if (!phpbb::$user->is_guest) - { - trigger_error('USER_CANNOT_READ'); - } - - login_box('', phpbb::$user->lang['LOGIN_EXPLAIN_POST']); -} - -// Permission to do the action asked? -$is_authed = false; - -switch ($mode) -{ - case 'post': - if (phpbb::$acl->acl_get('f_post', $forum_id)) - { - $is_authed = true; - } - break; - - case 'bump': - if (phpbb::$acl->acl_get('f_bump', $forum_id)) - { - $is_authed = true; - } - break; - - case 'quote': - - $post_data['post_edit_locked'] = 0; - - // no break; - - case 'reply': - if (phpbb::$acl->acl_get('f_reply', $forum_id)) - { - $is_authed = true; - } - break; - - case 'edit': - if (phpbb::$user->is_registered && phpbb::$acl->acl_gets('f_edit', 'm_edit', $forum_id)) - { - $is_authed = true; - } - break; - - case 'delete': - if (phpbb::$user->is_registered && phpbb::$acl->acl_gets('f_delete', 'm_delete', $forum_id)) - { - $is_authed = true; - } - break; -} - -if (!$is_authed) -{ - $check_auth = ($mode == 'quote') ? 'reply' : $mode; - - if (phpbb::$user->is_registered) - { - trigger_error('USER_CANNOT_' . strtoupper($check_auth)); - } - - login_box('', phpbb::$user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); -} - -// Is the user able to post within this forum? -if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply'))) -{ - trigger_error('USER_CANNOT_FORUM_POST'); -} - -// Forum/Topic locked? -if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !phpbb::$acl->acl_get('m_edit', $forum_id)) -{ - trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); -} - -// Can we edit this post ... if we're a moderator with rights then always yes -// else it depends on editing times, lock status and if we're the correct user -if ($mode == 'edit' && !phpbb::$acl->acl_get('m_edit', $forum_id)) -{ - if (phpbb::$user->data['user_id'] != $post_data['poster_id']) - { - trigger_error('USER_CANNOT_EDIT'); - } - - if (!($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) - { - trigger_error('CANNOT_EDIT_TIME'); - } - - if ($post_data['post_edit_locked']) - { - trigger_error('CANNOT_EDIT_POST_LOCKED'); - } -} - -// Handle delete mode... -if ($mode == 'delete') -{ - handle_post_delete($forum_id, $topic_id, $post_id, $post_data); - return; -} - -// Handle bump mode... -if ($mode == 'bump') -{ - if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) - && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) - { - phpbb::$db->sql_transaction('begin'); - - $sql = 'UPDATE ' . POSTS_TABLE . " - SET post_time = $current_time - WHERE post_id = {$post_data['topic_last_post_id']} - AND topic_id = $topic_id"; - phpbb::$db->sql_query($sql); - - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_last_post_time = $current_time, - topic_bumped = 1, - topic_bumper = " . phpbb::$user->data['user_id'] . " - WHERE topic_id = $topic_id"; - phpbb::$db->sql_query($sql); - - update_post_information('forum', $forum_id); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_lastpost_time = $current_time - WHERE user_id = " . phpbb::$user->data['user_id']; - phpbb::$db->sql_query($sql); - - phpbb::$db->sql_transaction('commit'); - - markread('post', $forum_id, $topic_id, $current_time); - - add_log('mod', $forum_id, $topic_id, 'LOG_BUMP_TOPIC', $post_data['topic_title']); - - $meta_url = append_sid('viewtopic', "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}"; - meta_refresh(3, $meta_url); - - $message = phpbb::$user->lang['TOPIC_BUMPED'] . '

' . sprintf(phpbb::$user->lang['VIEW_MESSAGE'], '', ''); - $message .= '

' . sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); - - trigger_error($message); - } - - trigger_error('BUMP_ERROR'); -} - -// Subject length limiting to 60 characters if first post... -if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id'])) -{ - phpbb::$template->assign_var('S_NEW_MESSAGE', true); -} - -// Determine some vars -if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) -{ - $post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : phpbb::$user->lang['GUEST']; -} -else -{ - $post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : ''; -} - -$post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0; -$post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : ''); -$post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0; -$post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0; -$post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0; -$post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id']; -$post_data['poll_options'] = array(); - -// Get Poll Data -if ($post_data['poll_start']) -{ - $sql = 'SELECT poll_option_text - FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id - ORDER BY poll_option_id"; - $result = phpbb::$db->sql_query($sql); - - while ($row = phpbb::$db->sql_fetchrow($result)) - { - $post_data['poll_options'][] = trim($row['poll_option_text']); - } - phpbb::$db->sql_freeresult($result); -} - -$orig_poll_options_size = sizeof($post_data['poll_options']); - -$message_parser = new parse_message(); - -if (isset($post_data['post_text'])) -{ - $message_parser->message = &$post_data['post_text']; - unset($post_data['post_text']); -} - -// Set some default variables -$uninit = array('post_attachment' => 0, 'poster_id' => phpbb::$user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); - -foreach ($uninit as $var_name => $default_value) -{ - if (!isset($post_data[$var_name])) - { - $post_data[$var_name] = $default_value; - } -} -unset($uninit); - -// Always check if the submitted attachment data is valid and belongs to the user. -// Further down (especially in submit_post()) we do not check this again. -$message_parser->get_submitted_attachment_data($post_data['poster_id']); - -if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit') -{ - // Do not change to SELECT * - $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename - FROM ' . ATTACHMENTS_TABLE . " - WHERE post_msg_id = $post_id - AND in_message = 0 - AND is_orphan = 0 - ORDER BY filetime DESC"; - $result = phpbb::$db->sql_query($sql); - $message_parser->attachment_data = array_merge($message_parser->attachment_data, phpbb::$db->sql_fetchrowset($result)); - phpbb::$db->sql_freeresult($result); -} - -if ($post_data['poster_id'] == ANONYMOUS) -{ - $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : ''; -} -else -{ - $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : ''; -} - -$post_data['enable_urls'] = $post_data['enable_magic_url']; - -if ($mode != 'edit') -{ - $post_data['enable_sig'] = (phpbb::$config['allow_sig'] && phpbb::$user->optionget('attachsig')) ? true: false; - $post_data['enable_smilies'] = (phpbb::$config['allow_smilies'] && phpbb::$user->optionget('smilies')) ? true : false; - $post_data['enable_bbcode'] = (phpbb::$config['allow_bbcode'] && phpbb::$user->optionget('bbcode')) ? true : false; - $post_data['enable_urls'] = true; -} - -$post_data['enable_magic_url'] = $post_data['drafts'] = false; - -// User own some drafts? -if (phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) -{ - $sql = 'SELECT draft_id - FROM ' . DRAFTS_TABLE . ' - WHERE user_id = ' . phpbb::$user->data['user_id'] . - (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . - (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . - (($draft_id) ? " AND draft_id <> $draft_id" : ''); - $result = phpbb::$db->sql_query_limit($sql, 1); - - if (phpbb::$db->sql_fetchrow($result)) - { - $post_data['drafts'] = true; - } - phpbb::$db->sql_freeresult($result); -} - -$check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); - -// Check if user is watching this topic -if ($mode != 'post' && phpbb::$config['allow_topic_notify'] && phpbb::$user->is_registered) -{ - $sql = 'SELECT topic_id - FROM ' . TOPICS_WATCH_TABLE . ' - WHERE topic_id = ' . $topic_id . ' - AND user_id = ' . phpbb::$user->data['user_id']; - $result = phpbb::$db->sql_query($sql); - $post_data['notify_set'] = (int) phpbb::$db->sql_fetchfield('topic_id'); - phpbb::$db->sql_freeresult($result); -} - -// Do we want to edit our post ? -if ($mode == 'edit' && $post_data['bbcode_uid']) -{ - $message_parser->bbcode_uid = $post_data['bbcode_uid']; -} - -// HTML, BBCode, Smilies, Images and Flash status -$bbcode_status = (phpbb::$config['allow_bbcode'] && phpbb::$acl->acl_get('f_bbcode', $forum_id)) ? true : false; -$smilies_status = ($bbcode_status && phpbb::$config['allow_smilies'] && phpbb::$acl->acl_get('f_smilies', $forum_id)) ? true : false; -$img_status = ($bbcode_status && phpbb::$acl->acl_get('f_img', $forum_id)) ? true : false; -$url_status = (phpbb::$config['allow_post_links']) ? true : false; -$flash_status = ($bbcode_status && phpbb::$acl->acl_get('f_flash', $forum_id) && phpbb::$config['allow_post_flash']) ? true : false; -$quote_status = (phpbb::$acl->acl_get('f_reply', $forum_id)) ? true : false; - -// Save Draft -if ($save && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) -{ - $subject = utf8_normalize_nfc(request_var('subject', '', true)); - $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; - $message = utf8_normalize_nfc(request_var('message', '', true)); - - if ($subject && $message) - { - if (confirm_box(true)) - { - $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array( - 'user_id' => (int) phpbb::$user->data['user_id'], - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'save_time' => (int) $current_time, - 'draft_subject' => (string) $subject, - 'draft_message' => (string) $message) - ); - phpbb::$db->sql_query($sql); - - $meta_info = ($mode == 'post') ? append_sid('viewforum', 'f=' . $forum_id) : append_sid('viewtopic', "f=$forum_id&t=$topic_id"); - - meta_refresh(3, $meta_info); - - $message = phpbb::$user->lang['DRAFT_SAVED'] . '

'; - $message .= ($mode != 'post') ? sprintf(phpbb::$user->lang['RETURN_TOPIC'], '', '') . '

' : ''; - $message .= sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); - - trigger_error($message); - } - else - { - $s_hidden_fields = build_hidden_fields(array( - 'mode' => $mode, - 'save' => true, - 'f' => $forum_id, - 't' => $topic_id, - 'subject' => $subject, - 'message' => $message, - 'attachment_data' => $message_parser->attachment_data, - ) - ); - - confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields); - } - } - else - { - if (utf8_clean_string($subject) === '') - { - $error[] = phpbb::$user->lang['EMPTY_SUBJECT']; - } - - if (utf8_clean_string($message) === '') - { - $error[] = phpbb::$user->lang['TOO_FEW_CHARS']; - } - } - unset($subject, $message); -} - -// Load requested Draft -if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && phpbb::$user->is_registered && phpbb::$acl->acl_get('u_savedrafts')) -{ - $sql = 'SELECT draft_subject, draft_message - FROM ' . DRAFTS_TABLE . " - WHERE draft_id = $draft_id - AND user_id = " . phpbb::$user->data['user_id']; - $result = phpbb::$db->sql_query_limit($sql, 1); - $row = phpbb::$db->sql_fetchrow($result); - phpbb::$db->sql_freeresult($result); - - if ($row) - { - $post_data['post_subject'] = $row['draft_subject']; - $message_parser->message = $row['draft_message']; - - phpbb::$template->assign_var('S_DRAFT_LOADED', true); - } - else - { - $draft_id = 0; - } -} - -// Load draft overview -if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_data['drafts']) -{ - load_drafts($topic_id, $forum_id); -} - -$solved_captcha = false; - -if ($submit || $preview || $refresh) -{ - $edit_reason = utf8_normalize_nfc(request_var('edit_reason', '', true)); - - $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0); - $post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true)); - $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); - - $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); - $post_data['post_edit_reason'] = (!empty($edit_reason) && $mode == 'edit' && phpbb::$acl->acl_get('m_edit', $forum_id)) ? $edit_reason : ''; - - $post_data['orig_topic_type'] = $post_data['topic_type']; - $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); - $post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); - $post_data['icon_id'] = request_var('icon', 0); - - $post_data['enable_bbcode'] = (!$bbcode_status || phpbb_request::is_set_post('disable_bbcode')) ? false : true; - $post_data['enable_smilies'] = (!$smilies_status || phpbb_request::is_set_post('disable_smilies')) ? false : true; - $post_data['enable_urls'] = phpbb_request::is_set_post('disable_magic_url'); - $post_data['enable_sig'] = (!phpbb::$config['allow_sig'] || !phpbb::$acl->acl_get('f_sigs', $forum_id) || !phpbb::$acl->acl_get('u_sig')) ? false : ((phpbb_request::is_set_post('attach_sig') && phpbb::$user->is_registered) ? true : false); - - if (phpbb::$config['allow_topic_notify'] && phpbb::$user->is_registered) - { - $notify = phpbb_request::is_set_post('notify'); - } - else - { - $notify = false; - } - - $topic_lock = phpbb_request::is_set_post('lock_topic'); - $post_lock = phpbb_request::is_set_post('lock_post'); - $poll_delete = phpbb_request::is_set_post('poll_delete'); - - if ($submit) - { - $status_switch = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); - $status_switch = ($status_switch != $check_value); - } - else - { - $status_switch = 1; - } - - // Delete Poll - if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) && - ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id)) || phpbb::$acl->acl_get('m_delete', $forum_id))) - { - if ($submit && check_form_key('posting')) - { - $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " - WHERE topic_id = $topic_id"; - phpbb::$db->sql_query($sql); - - $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " - WHERE topic_id = $topic_id"; - phpbb::$db->sql_query($sql); - - $topic_sql = array( - 'poll_title' => '', - 'poll_start' => 0, - 'poll_length' => 0, - 'poll_last_vote' => 0, - 'poll_max_options' => 0, - 'poll_vote_change' => 0 - ); - - $sql = 'UPDATE ' . TOPICS_TABLE . ' - SET ' . phpbb::$db->sql_build_array('UPDATE', $topic_sql) . " - WHERE topic_id = $topic_id"; - phpbb::$db->sql_query($sql); - } - - $post_data['poll_title'] = $post_data['poll_option_text'] = ''; - $post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0; - } - else - { - $post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true)); - $post_data['poll_length'] = request_var('poll_length', 0); - $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); - $post_data['poll_max_options'] = request_var('poll_max_options', 1); - $post_data['poll_vote_change'] = (phpbb::$acl->acl_get('f_votechg', $forum_id) && phpbb_request::is_set_post('poll_vote_change')) ? 1 : 0; - } - - // If replying/quoting and last post id has changed - // give user option to continue submit or return to post - // notify and show user the post made between his request and the final submit - if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id']) - { - // Only do so if it is allowed forum-wide - if ($post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) - { - if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id'])) - { - phpbb::$template->assign_var('S_POST_REVIEW', true); - } - - $submit = false; - $refresh = true; - } - } - - // Parse Attachments - before checksum is calculated - $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); - - // Grab md5 'checksum' of new message - $message_md5 = md5($message_parser->message); - - // Check checksum ... don't re-parse message if the same - $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false; - - // Parse message - if ($update_message) - { - if (sizeof($message_parser->warn_msg)) - { - $error[] = implode('
', $message_parser->warn_msg); - $message_parser->warn_msg = array(); - } - - $message_parser->parse($post_data['enable_bbcode'], (phpbb::$config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, phpbb::$config['allow_post_links']); - - // On a refresh we do not care about message parsing errors - if (sizeof($message_parser->warn_msg) && $refresh) - { - $message_parser->warn_msg = array(); - } - } - else - { - $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; - } - - if ($mode != 'edit' && !$preview && !$refresh && phpbb::$config['flood_interval'] && !phpbb::$acl->acl_get('f_ignoreflood', $forum_id)) - { - // Flood check - $last_post_time = 0; - - if (phpbb::$user->is_registered) - { - $last_post_time = phpbb::$user->data['user_lastpost_time']; - } - else - { - $sql = 'SELECT post_time AS last_post_time - FROM ' . POSTS_TABLE . " - WHERE poster_ip = '" . phpbb::$user->ip . "' - AND post_time > " . ($current_time - phpbb::$config['flood_interval']); - $result = phpbb::$db->sql_query_limit($sql, 1); - if ($row = phpbb::$db->sql_fetchrow($result)) - { - $last_post_time = $row['last_post_time']; - } - phpbb::$db->sql_freeresult($result); - } - - if ($last_post_time && ($current_time - $last_post_time) < intval(phpbb::$config['flood_interval'])) - { - $error[] = phpbb::$user->lang['FLOOD_ERROR']; - } - } - - // Validate username - if (($post_data['username'] && !phpbb::$user->is_registered) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) - { - include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT); - - if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false) - { - phpbb::$user->add_lang('ucp'); - $error[] = phpbb::$user->lang[$result . '_USERNAME']; - } - } - - if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered && in_array($mode, array('quote', 'post', 'reply'))) - { - $vc_response = $captcha->validate(); - if ($vc_response) - { - $error[] = $vc_response; - } - else - { - $solved_captcha = true; - } - } - - // check form - if (($submit || $preview) && !check_form_key('posting')) - { - $error[] = phpbb::$user->lang['FORM_INVALID']; - } - - // Parse subject - if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) - { - $error[] = phpbb::$user->lang['EMPTY_SUBJECT']; - } - - $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; - - if ($post_data['poll_option_text'] && - ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || phpbb::$acl->acl_get('m_edit', $forum_id))*/)) - && phpbb::$acl->acl_get('f_poll', $forum_id)) - { - $poll = array( - 'poll_title' => $post_data['poll_title'], - 'poll_length' => $post_data['poll_length'], - 'poll_max_options' => $post_data['poll_max_options'], - 'poll_option_text' => $post_data['poll_option_text'], - 'poll_start' => $post_data['poll_start'], - 'poll_last_vote' => $post_data['poll_last_vote'], - 'poll_vote_change' => $post_data['poll_vote_change'], - 'enable_bbcode' => $post_data['enable_bbcode'], - 'enable_urls' => $post_data['enable_urls'], - 'enable_smilies' => $post_data['enable_smilies'], - 'img_status' => $img_status - ); - - $message_parser->parse_poll($poll); - - $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : ''; - $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; - - /* We reset votes, therefore also allow removing options - if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size)) - { - $message_parser->warn_msg[] = phpbb::$user->lang['NO_DELETE_POLL_OPTIONS']; - }*/ - } - else - { - $poll = array(); - } - - // Check topic type - if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) - { - switch ($post_data['topic_type']) - { - case POST_GLOBAL: - case POST_ANNOUNCE: - $auth_option = 'f_announce'; - break; - - case POST_STICKY: - $auth_option = 'f_sticky'; - break; - - default: - $auth_option = ''; - break; - } - - if (!phpbb::$acl->acl_get($auth_option, $forum_id)) - { - // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod. - // Another case would be a mod not having sticky permissions for example but edit permissions. - if ($mode == 'edit') - { - // To prevent non-authed users messing around with the topic type we reset it to the original one. - $post_data['topic_type'] = $post_data['orig_topic_type']; - } - else - { - $error[] = phpbb::$user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))]; - } - } - } - - if (sizeof($message_parser->warn_msg)) - { - $error[] = implode('
', $message_parser->warn_msg); - } - - // DNSBL check - if (phpbb::$config['check_dnsbl'] && !$refresh) - { - if (($dnsbl = phpbb::$user->check_dnsbl('post')) !== false) - { - $error[] = sprintf(phpbb::$user->lang['IP_BLACKLISTED'], phpbb::$user->ip, $dnsbl[1]); - } - } - - // Store message, sync counters - if (!sizeof($error) && $submit) - { - // Check if we want to de-globalize the topic... and ask for new forum - if ($post_data['topic_type'] != POST_GLOBAL) - { - $sql = 'SELECT topic_type, forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = phpbb::$db->sql_query($sql); - $row = phpbb::$db->sql_fetchrow($result); - phpbb::$db->sql_freeresult($result); - - if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) - { - $to_forum_id = request_var('to_forum_id', 0); - - if ($to_forum_id) - { - $sql = 'SELECT forum_type - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $to_forum_id; - $result = phpbb::$db->sql_query($sql); - $forum_type = (int) phpbb::$db->sql_fetchfield('forum_type'); - phpbb::$db->sql_freeresult($result); - - if ($forum_type != FORUM_POST || !phpbb::$acl->acl_get('f_post', $to_forum_id)) - { - $to_forum_id = 0; - } - } - - if (!$to_forum_id) - { - include_once(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT); - - phpbb::$template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), - 'S_UNGLOBALISE' => true, - )); - - $submit = false; - $refresh = true; - } - else - { - if (!phpbb::$acl->acl_get('f_post', $to_forum_id)) - { - // This will only be triggered if the user tried to trick the forum. - trigger_error('NOT_AUTHORISED'); - } - - $forum_id = $to_forum_id; - } - } - } - - if ($submit) - { - // Lock/Unlock Topic - $change_topic_status = $post_data['topic_status']; - $perm_lock_unlock = (phpbb::$acl->acl_get('m_lock', $forum_id) || (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; - - if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) - { - $change_topic_status = ITEM_UNLOCKED; - } - else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) - { - $change_topic_status = ITEM_LOCKED; - } - - if ($change_topic_status != $post_data['topic_status']) - { - $sql = 'UPDATE ' . TOPICS_TABLE . " - SET topic_status = $change_topic_status - WHERE topic_id = $topic_id - AND topic_moved_id = 0"; - phpbb::$db->sql_query($sql); - - $user_lock = (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && phpbb::$user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; - - add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']); - } - - // Lock/Unlock Post Edit - if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && phpbb::$acl->acl_get('m_edit', $forum_id)) - { - $post_data['post_edit_locked'] = ITEM_UNLOCKED; - } - else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && phpbb::$acl->acl_get('m_edit', $forum_id)) - { - $post_data['post_edit_locked'] = ITEM_LOCKED; - } - - $data = array( - 'topic_title' => (empty($post_data['topic_title'])) ? $post_data['post_subject'] : $post_data['topic_title'], - 'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0, - 'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0, - 'topic_time_limit' => (int) $post_data['topic_time_limit'], - 'topic_attachment' => (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0, - 'post_id' => (int) $post_id, - 'topic_id' => (int) $topic_id, - 'forum_id' => (int) $forum_id, - 'icon_id' => (int) $post_data['icon_id'], - 'poster_id' => (int) $post_data['poster_id'], - 'enable_sig' => (bool) $post_data['enable_sig'], - 'enable_bbcode' => (bool) $post_data['enable_bbcode'], - 'enable_smilies' => (bool) $post_data['enable_smilies'], - 'enable_urls' => (bool) $post_data['enable_urls'], - 'enable_indexing' => (bool) $post_data['enable_indexing'], - 'message_md5' => (string) $message_md5, - 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time, - 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', - 'post_edit_reason' => $post_data['post_edit_reason'], - 'post_edit_user' => ($mode == 'edit') ? phpbb::$user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), - 'forum_parents' => $post_data['forum_parents'], - 'forum_name' => $post_data['forum_name'], - 'notify' => $notify, - 'notify_set' => $post_data['notify_set'], - 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : phpbb::$user->ip, - 'post_edit_locked' => (int) $post_data['post_edit_locked'], - 'bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'bbcode_uid' => $message_parser->bbcode_uid, - 'message' => $message_parser->message, - 'attachment_data' => $message_parser->attachment_data, - 'filename_data' => $message_parser->filename_data, - - 'topic_approved' => (isset($post_data['topic_approved'])) ? $post_data['topic_approved'] : false, - 'post_approved' => (isset($post_data['post_approved'])) ? $post_data['post_approved'] : false, - ); - - if ($mode == 'edit') - { - $data['topic_replies_real'] = (int) $post_data['topic_replies_real']; - $data['topic_replies'] = (int) $post_data['topic_replies']; - } - - $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message); - if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered && in_array($mode, array('quote', 'post', 'reply'))) - { - $captcha->reset(); - } - // Check the permissions for post approval, as well as the queue trigger where users are put on approval with a post count lower than specified. Moderators are not affected. - if (((phpbb::$config['enable_queue_trigger'] && phpbb::$user->data['user_posts'] < phpbb::$config['queue_trigger_posts']) || !phpbb::$acl->acl_get('f_noapprove', $data['forum_id'])) && !phpbb::$acl->acl_get('m_approve', $data['forum_id'])) - { - meta_refresh(10, $redirect_url); - $message = ($mode == 'edit') ? phpbb::$user->lang['POST_EDITED_MOD'] : phpbb::$user->lang['POST_STORED_MOD']; - $message .= ((phpbb::$user->is_guest) ? '' : ' '. phpbb::$user->lang['POST_APPROVAL_NOTIFY']); - } - else - { - meta_refresh(3, $redirect_url); - - $message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'; - $message = phpbb::$user->lang[$message] . '

' . sprintf(phpbb::$user->lang['VIEW_MESSAGE'], '', ''); - } - - $message .= '

' . sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); - trigger_error($message); - } - } -} - -// Preview -if (!sizeof($error) && $preview) -{ - $post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time; - - $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); - - $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : phpbb::$user->data['user_sig']; - $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : phpbb::$user->data['user_sig_bbcode_uid']; - $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : phpbb::$user->data['user_sig_bbcode_bitfield']; - - // Signature - if ($post_data['enable_sig'] && phpbb::$config['allow_sig'] && $preview_signature && phpbb::$acl->acl_get('f_sigs', $forum_id)) - { - $parse_sig = new parse_message($preview_signature); - $parse_sig->bbcode_uid = $preview_signature_uid; - $parse_sig->bbcode_bitfield = $preview_signature_bitfield; - - // Not sure about parameters for bbcode/smilies/urls... in signatures - $parse_sig->format_display(phpbb::$config['allow_sig_bbcode'], true, phpbb::$config['allow_sig_smilies']); - $preview_signature = $parse_sig->message; - unset($parse_sig); - } - else - { - $preview_signature = ''; - } - - $preview_subject = censor_text($post_data['post_subject']); - - // Poll Preview - if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || phpbb::$acl->acl_get('m_edit', $forum_id))*/)) - && phpbb::$acl->acl_get('f_poll', $forum_id)) - { - $parse_poll = new parse_message($post_data['poll_title']); - $parse_poll->bbcode_uid = $message_parser->bbcode_uid; - $parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield; - - $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); - - if ($post_data['poll_length']) - { - $poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time()); - } - - phpbb::$template->assign_vars(array( - 'S_HAS_POLL_OPTIONS' => (sizeof($post_data['poll_options'])), - 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, - - 'POLL_QUESTION' => $parse_poll->message, - - 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf(phpbb::$user->lang['POLL_RUN_TILL'], phpbb::$user->format_date($poll_end)) : '', - 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? phpbb::$user->lang['MAX_OPTION_SELECT'] : sprintf(phpbb::$user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options']), - )); - - $parse_poll->message = implode("\n", $post_data['poll_options']); - $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); - $preview_poll_options = explode('
', $parse_poll->message); - unset($parse_poll); - - foreach ($preview_poll_options as $key => $option) - { - phpbb::$template->assign_block_vars('poll_option', array( - 'POLL_OPTION_CAPTION' => $option, - 'POLL_OPTION_ID' => $key + 1, - )); - } - unset($preview_poll_options); - } - - // Attachment Preview - if (sizeof($message_parser->attachment_data)) - { - phpbb::$template->assign_var('S_HAS_ATTACHMENTS', true); - - $update_count = array(); - $attachment_data = $message_parser->attachment_data; - - parse_attachments($forum_id, $preview_message, $attachment_data, $update_count, true); - - foreach ($attachment_data as $i => $attachment) - { - phpbb::$template->assign_block_vars('attachment', array( - 'DISPLAY_ATTACHMENT' => $attachment, - )); - } - unset($attachment_data); - } - - if (!sizeof($error)) - { - phpbb::$template->assign_vars(array( - 'PREVIEW_SUBJECT' => $preview_subject, - 'PREVIEW_MESSAGE' => $preview_message, - 'PREVIEW_SIGNATURE' => $preview_signature, - - 'S_DISPLAY_PREVIEW' => true, - )); - } -} - -// Decode text for message display -$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; -$message_parser->decode_message($post_data['bbcode_uid']); - -if ($mode == 'quote' && !$submit && !$preview && !$refresh) -{ - $message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; -} - -if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh) -{ - $post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']); -} - -$attachment_data = $message_parser->attachment_data; -$filename_data = $message_parser->filename_data; -$post_data['post_text'] = $message_parser->message; - -if (sizeof($post_data['poll_options']) && $post_data['poll_title']) -{ - $message_parser->message = $post_data['poll_title']; - $message_parser->bbcode_uid = $post_data['bbcode_uid']; - - $message_parser->decode_message(); - $post_data['poll_title'] = $message_parser->message; - - $message_parser->message = implode("\n", $post_data['poll_options']); - $message_parser->decode_message(); - $post_data['poll_options'] = explode("\n", $message_parser->message); -} - -// MAIN POSTING PAGE BEGINS HERE - -// Forum moderators? -$moderators = array(); -get_moderators($moderators, $forum_id); - -// Generate smiley listing -generate_smilies('inline', $forum_id); - -// Generate inline attachment select box -posting_gen_inline_attachments($attachment_data); - -// Do show topic type selection only in first post. -$topic_type_toggle = false; - -if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'])) -{ - $topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']); -} - -$s_topic_icons = false; -if ($post_data['enable_icons'] && phpbb::$acl->acl_get('f_icons', $forum_id)) -{ - $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); -} - -$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : ((phpbb::$config['allow_bbcode']) ? !phpbb::$user->optionget('bbcode') : 1); -$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : ((phpbb::$config['allow_smilies']) ? !phpbb::$user->optionget('smilies') : 1); -$urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; -$sig_checked = $post_data['enable_sig']; -$lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); -$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; - -// If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting -$notify_set = ($mode != 'edit' && phpbb::$config['allow_topic_notify'] && phpbb::$user->is_registered && !$post_data['notify_set']) ? phpbb::$user->data['user_notify'] : $post_data['notify_set']; -$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? phpbb::$user->data['user_notify'] : $notify_set); - -// Page title & action URL, include session_id for security purpose -$s_action = append_sid('posting', "mode=$mode&f=$forum_id", true, phpbb::$user->session_id); -$s_action .= ($topic_id) ? "&t=$topic_id" : ''; -$s_action .= ($post_id) ? "&p=$post_id" : ''; - -switch ($mode) -{ - case 'post': - $page_title = phpbb::$user->lang['POST_TOPIC']; - break; - - case 'quote': - case 'reply': - $page_title = phpbb::$user->lang['POST_REPLY']; - break; - - case 'delete': - case 'edit': - $page_title = phpbb::$user->lang['EDIT_POST']; - break; -} - -// Build Navigation Links -generate_forum_nav($post_data); - -// Build Forum Rules -generate_forum_rules($post_data); - -if (phpbb::$config['enable_post_confirm'] && !phpbb::$user->is_registered && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) -{ - $captcha->reset(); - - phpbb::$template->assign_vars(array( - 'S_CONFIRM_CODE' => true, - 'CONFIRM' => $captcha->get_template(), - )); -} - -$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; -$s_hidden_fields .= ''; -$s_hidden_fields .= ($draft_id || phpbb_request::is_set('draft_loaded')) ? '' : ''; - -// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview -if ($solved_captcha !== false) -{ - $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); -} - -$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !phpbb::$config['allow_attachments'] || !phpbb::$acl->acl_get('u_attach') || !phpbb::$acl->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; -add_form_key('posting'); - - -// Start assigning vars for main posting page ... -phpbb::$template->assign_vars(array( - 'L_POST_A' => $page_title, - 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? phpbb::$user->lang['POST_ICON'] : phpbb::$user->lang['TOPIC_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => (intval(phpbb::$config['max_post_chars'])) ? sprintf(phpbb::$user->lang['MESSAGE_BODY_EXPLAIN'], intval(phpbb::$config['max_post_chars'])) : '', - - 'FORUM_NAME' => $post_data['forum_name'], - 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', - 'TOPIC_TITLE' => censor_text($post_data['topic_title']), - 'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '', - 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', - 'SUBJECT' => $post_data['post_subject'], - 'MESSAGE' => $post_data['post_text'], - 'BBCODE_STATUS' => ($bbcode_status) ? sprintf(phpbb::$user->lang['BBCODE_IS_ON'], '', '') : sprintf(phpbb::$user->lang['BBCODE_IS_OFF'], '', ''), - 'IMG_STATUS' => ($img_status) ? phpbb::$user->lang['IMAGES_ARE_ON'] : phpbb::$user->lang['IMAGES_ARE_OFF'], - 'FLASH_STATUS' => ($flash_status) ? phpbb::$user->lang['FLASH_IS_ON'] : phpbb::$user->lang['FLASH_IS_OFF'], - 'SMILIES_STATUS' => ($smilies_status) ? phpbb::$user->lang['SMILIES_ARE_ON'] : phpbb::$user->lang['SMILIES_ARE_OFF'], - 'URL_STATUS' => ($bbcode_status && $url_status) ? phpbb::$user->lang['URL_IS_ON'] : phpbb::$user->lang['URL_IS_OFF'], - 'MAX_FONT_SIZE' => (int) phpbb::$config['max_post_font_size'], - 'MINI_POST_IMG' => phpbb::$user->img('icon_post_target', 'POST'), - 'POST_DATE' => ($post_data['post_time']) ? phpbb::$user->format_date($post_data['post_time']) : '', - 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', - 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], - 'EDIT_REASON' => $post_data['post_edit_reason'], - 'U_VIEW_FORUM' => append_sid('viewforum', "f=$forum_id"), - 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid('viewtopic', "f=$forum_id&t=$topic_id") : '', - 'U_PROGRESS_BAR' => append_sid('posting', "f=$forum_id&mode=popup"), - 'UA_PROGRESS_BAR' => addslashes(append_sid('posting', "f=$forum_id&mode=popup")), - - 'S_PRIVMSGS' => false, - 'S_CLOSE_PROGRESS_WINDOW' => phpbb_request::is_set_post('add_file'), - 'S_EDIT_POST' => ($mode == 'edit') ? true : false, - 'S_EDIT_REASON' => ($mode == 'edit' && phpbb::$acl->acl_get('m_edit', $forum_id)) ? true : false, - 'S_DISPLAY_USERNAME' => (!phpbb::$user->is_registered || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, - 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, - 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time'])) || phpbb::$acl->acl_get('m_delete', $forum_id))) ? true : false, - 'S_BBCODE_ALLOWED' => $bbcode_status, - 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', - 'S_SMILIES_ALLOWED' => $smilies_status, - 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', - 'S_SIG_ALLOWED' => (phpbb::$acl->acl_get('f_sigs', $forum_id) && phpbb::$config['allow_sig'] && phpbb::$user->is_registered) ? true : false, - 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', - 'S_NOTIFY_ALLOWED' => (!phpbb::$user->is_registered || ($mode == 'edit' && phpbb::$user->data['user_id'] != $post_data['poster_id']) || !phpbb::$config['allow_topic_notify'] || !phpbb::$config['email_enable']) ? false : true, - 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', - 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && (phpbb::$acl->acl_get('m_lock', $forum_id) || (phpbb::$acl->acl_get('f_user_lock', $forum_id) && phpbb::$user->is_registered && !empty($post_data['topic_poster']) && phpbb::$user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, - 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', - 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && phpbb::$acl->acl_get('m_edit', $forum_id)) ? true : false, - 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', - 'S_LINKS_ALLOWED' => $url_status, - 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', - 'S_TYPE_TOGGLE' => $topic_type_toggle, - 'S_SAVE_ALLOWED' => (phpbb::$acl->acl_get('u_savedrafts') && phpbb::$user->is_registered && $mode != 'edit') ? true : false, - 'S_HAS_DRAFTS' => (phpbb::$acl->acl_get('u_savedrafts') && phpbb::$user->is_registered && $post_data['drafts']) ? true : false, - 'S_FORM_ENCTYPE' => $form_enctype, - - 'S_BBCODE_IMG' => $img_status, - 'S_BBCODE_URL' => $url_status, - 'S_BBCODE_FLASH' => $flash_status, - 'S_BBCODE_QUOTE' => $quote_status, - - 'S_POST_ACTION' => $s_action, - 'S_HIDDEN_FIELDS' => $s_hidden_fields, -)); - -// Build custom bbcodes array -display_custom_bbcodes(); - -// Poll entry -if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || phpbb::$acl->acl_get('m_edit', $forum_id))*/)) - && phpbb::$acl->acl_get('f_poll', $forum_id)) -{ - phpbb::$template->assign_vars(array( - 'S_SHOW_POLL_BOX' => true, - 'S_POLL_VOTE_CHANGE' => (phpbb::$acl->acl_get('f_votechg', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id)) || phpbb::$acl->acl_get('m_delete', $forum_id))), - 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - - 'L_POLL_OPTIONS_EXPLAIN' => sprintf(phpbb::$user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], phpbb::$config['max_poll_options']), - - 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', -// 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', - 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', - 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, - 'POLL_LENGTH' => $post_data['poll_length'], - )); -} - -// Show attachment box for adding attachments if true -$allowed = (phpbb::$acl->acl_get('f_attach', $forum_id) && phpbb::$acl->acl_get('u_attach') && phpbb::$config['allow_attachments'] && $form_enctype); - -// Attachment entry -posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); - -// Output page ... -page_header($page_title); - -phpbb::$template->set_filenames(array( - 'body' => 'posting_body.html', -)); - -make_jumpbox(append_sid('viewforum')); - -// Topic review -if ($mode == 'reply' || $mode == 'quote') -{ - if (topic_review($topic_id, $forum_id)) - { - phpbb::$template->assign_var('S_DISPLAY_REVIEW', true); - } -} - -page_footer(); - -/** -* Show upload popup (progress bar) -*/ -function upload_popup($forum_style = 0) -{ - ($forum_style) ? phpbb::$user->setup('posting', $forum_style) : phpbb::$user->setup('posting'); - - page_header(phpbb::$user->lang['PROGRESS_BAR']); - - phpbb::$template->set_filenames(array( - 'popup' => 'posting_progress_bar.html', - )); - - phpbb::$template->assign_vars(array( - 'PROGRESS_BAR' => phpbb::$user->img('upload_bar', 'UPLOAD_IN_PROGRESS'), - )); - - phpbb::$template->display('popup'); - - garbage_collection(); - exit_handler(); -} - -/** -* Do the various checks required for removing posts as well as removing it -*/ -function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) -{ - // If moderator removing post or user itself removing post, present a confirmation screen - if (phpbb::$acl->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$user->is_registered && phpbb::$acl->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - (phpbb::$config['edit_time'] * 60) || !phpbb::$config['edit_time']))) - { - $s_hidden_fields = build_hidden_fields(array( - 'p' => $post_id, - 'f' => $forum_id, - 'mode' => 'delete') - ); - - if (confirm_box(true)) - { - $data = array( - 'topic_first_post_id' => $post_data['topic_first_post_id'], - 'topic_last_post_id' => $post_data['topic_last_post_id'], - 'topic_replies_real' => $post_data['topic_replies_real'], - 'topic_approved' => $post_data['topic_approved'], - 'topic_type' => $post_data['topic_type'], - 'post_approved' => $post_data['post_approved'], - 'post_reported' => $post_data['post_reported'], - 'post_time' => $post_data['post_time'], - 'poster_id' => $post_data['poster_id'], - 'post_postcount' => $post_data['post_postcount'] - ); - - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data); - - if ($next_post_id === false) - { - add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title']); - - $meta_info = append_sid('viewforum', "f=$forum_id"); - $message = phpbb::$user->lang['POST_DELETED']; - } - else - { - add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject']); - - $meta_info = append_sid('viewtopic', "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; - $message = phpbb::$user->lang['POST_DELETED'] . '

' . sprintf(phpbb::$user->lang['RETURN_TOPIC'], '', ''); - } - - meta_refresh(3, $meta_info); - $message .= '

' . sprintf(phpbb::$user->lang['RETURN_FORUM'], '', ''); - trigger_error($message); - } - else - { - confirm_box(false, 'DELETE_POST', $s_hidden_fields); - } - } - - // If we are here the user is not able to delete - present the correct error message - if ($post_data['poster_id'] != phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id)) - { - trigger_error('DELETE_OWN_POSTS'); - } - - if ($post_data['poster_id'] == phpbb::$user->data['user_id'] && phpbb::$acl->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) - { - trigger_error('CANNOT_DELETE_REPLIED'); - } - - trigger_error('USER_CANNOT_DELETE'); -} - -?> \ No newline at end of file -- cgit v1.2.1 From 2e17e448deed073f8614bb555a8ef20c57291c2a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 18:14:59 +0000 Subject: Copy 3.0.x branch to trunk git-svn-id: file:///svn/phpbb/trunk@10211 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 1592 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1592 insertions(+) create mode 100644 phpBB/posting.php (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php new file mode 100644 index 0000000000..1c7cd95b81 --- /dev/null +++ b/phpBB/posting.php @@ -0,0 +1,1592 @@ +session_begin(); +$auth->acl($user->data); + + +// Grab only parameters needed here +$post_id = request_var('p', 0); +$topic_id = request_var('t', 0); +$forum_id = request_var('f', 0); +$draft_id = request_var('d', 0); +$lastclick = request_var('lastclick', 0); + +$submit = (isset($_POST['post'])) ? true : false; +$preview = (isset($_POST['preview'])) ? true : false; +$save = (isset($_POST['save'])) ? true : false; +$load = (isset($_POST['load'])) ? true : false; +$delete = (isset($_POST['delete'])) ? true : false; +$cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; + +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); + +$error = $post_data = array(); +$current_time = time(); + +if ($config['enable_post_confirm'] && !$user->data['is_registered']) +{ + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_POST); +} + +// Was cancel pressed? If so then redirect to the appropriate page +if ($cancel || ($current_time - $lastclick < 2 && $submit)) +{ + $f = ($forum_id) ? 'f=' . $forum_id . '&' : ''; + $redirect = ($post_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 'p=' . $post_id) . '#p' . $post_id : (($topic_id) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", $f . 't=' . $topic_id) : (($forum_id) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}index.$phpEx"))); + redirect($redirect); +} + +if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$forum_id) +{ + trigger_error('NO_FORUM'); +} + +// We need to know some basic information in all cases before we do anything. +switch ($mode) +{ + case 'post': + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + break; + + case 'bump': + case 'reply': + if (!$topic_id) + { + trigger_error('NO_TOPIC'); + } + + // Force forum id + $sql = 'SELECT forum_id + FROM ' . TOPICS_TABLE . ' + WHERE topic_id = ' . $topic_id; + $result = $db->sql_query($sql); + $f_id = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + + $forum_id = (!$f_id) ? $forum_id : $f_id; + + $sql = 'SELECT f.*, t.* + FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f + WHERE t.topic_id = $topic_id + AND (f.forum_id = t.forum_id + OR f.forum_id = $forum_id) + AND t.topic_approved = 1"; + break; + + case 'quote': + case 'edit': + case 'delete': + if (!$post_id) + { + $user->setup('posting'); + trigger_error('NO_POST'); + } + + // Force forum id + $sql = 'SELECT forum_id + FROM ' . POSTS_TABLE . ' + WHERE post_id = ' . $post_id; + $result = $db->sql_query($sql); + $f_id = (int) $db->sql_fetchfield('forum_id'); + $db->sql_freeresult($result); + + $forum_id = (!$f_id) ? $forum_id : $f_id; + + $sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u + WHERE p.post_id = $post_id + AND t.topic_id = p.topic_id + AND u.user_id = p.poster_id + AND (f.forum_id = t.forum_id + OR f.forum_id = $forum_id)" . + (($auth->acl_get('m_approve', $forum_id) && $mode != 'quote') ? '' : 'AND p.post_approved = 1'); + break; + + case 'smilies': + $sql = ''; + generate_smilies('window', $forum_id); + break; + + case 'popup': + if ($forum_id) + { + $sql = 'SELECT forum_style + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $forum_id; + } + else + { + upload_popup(); + return; + } + break; + + default: + $sql = ''; + break; +} + +if (!$sql) +{ + $user->setup('posting'); + trigger_error('NO_POST_MODE'); +} + +$result = $db->sql_query($sql); +$post_data = $db->sql_fetchrow($result); +$db->sql_freeresult($result); + +if (!$post_data) +{ + if (!($mode == 'post' || $mode == 'bump' || $mode == 'reply')) + { + $user->setup('posting'); + } + trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); +} + +if ($mode == 'popup') +{ + upload_popup($post_data['forum_style']); + return; +} + +$user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); + +// Use post_row values in favor of submitted ones... +$forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; +$topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id; +$post_id = (!empty($post_data['post_id'])) ? (int) $post_data['post_id'] : (int) $post_id; + +// Need to login to passworded forum first? +if ($post_data['forum_password']) +{ + login_forum_box(array( + 'forum_id' => $forum_id, + 'forum_password' => $post_data['forum_password']) + ); +} + +// Check permissions +if ($user->data['is_bot']) +{ + redirect(append_sid("{$phpbb_root_path}index.$phpEx")); +} + +// Is the user able to read within this forum? +if (!$auth->acl_get('f_read', $forum_id)) +{ + if ($user->data['user_id'] != ANONYMOUS) + { + trigger_error('USER_CANNOT_READ'); + } + + login_box('', $user->lang['LOGIN_EXPLAIN_POST']); +} + +// Permission to do the action asked? +$is_authed = false; + +switch ($mode) +{ + case 'post': + if ($auth->acl_get('f_post', $forum_id)) + { + $is_authed = true; + } + break; + + case 'bump': + if ($auth->acl_get('f_bump', $forum_id)) + { + $is_authed = true; + } + break; + + case 'quote': + + $post_data['post_edit_locked'] = 0; + + // no break; + + case 'reply': + if ($auth->acl_get('f_reply', $forum_id)) + { + $is_authed = true; + } + break; + + case 'edit': + if ($user->data['is_registered'] && $auth->acl_gets('f_edit', 'm_edit', $forum_id)) + { + $is_authed = true; + } + break; + + case 'delete': + if ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id)) + { + $is_authed = true; + } + break; +} + +if (!$is_authed) +{ + $check_auth = ($mode == 'quote') ? 'reply' : $mode; + + if ($user->data['is_registered']) + { + trigger_error('USER_CANNOT_' . strtoupper($check_auth)); + } + + login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); +} + +// Is the user able to post within this forum? +if ($post_data['forum_type'] != FORUM_POST && in_array($mode, array('post', 'bump', 'quote', 'reply'))) +{ + trigger_error('USER_CANNOT_FORUM_POST'); +} + +// Forum/Topic locked? +if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_status']) && $post_data['topic_status'] == ITEM_LOCKED)) && !$auth->acl_get('m_edit', $forum_id)) +{ + trigger_error(($post_data['forum_status'] == ITEM_LOCKED) ? 'FORUM_LOCKED' : 'TOPIC_LOCKED'); +} + +// Can we edit this post ... if we're a moderator with rights then always yes +// else it depends on editing times, lock status and if we're the correct user +if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) +{ + if ($user->data['user_id'] != $post_data['poster_id']) + { + trigger_error('USER_CANNOT_EDIT'); + } + + if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) + { + trigger_error('CANNOT_EDIT_TIME'); + } + + if ($post_data['post_edit_locked']) + { + trigger_error('CANNOT_EDIT_POST_LOCKED'); + } +} + +// Handle delete mode... +if ($mode == 'delete') +{ + handle_post_delete($forum_id, $topic_id, $post_id, $post_data); + return; +} + +// Handle bump mode... +if ($mode == 'bump') +{ + if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) + && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) + { + $db->sql_transaction('begin'); + + $sql = 'UPDATE ' . POSTS_TABLE . " + SET post_time = $current_time + WHERE post_id = {$post_data['topic_last_post_id']} + AND topic_id = $topic_id"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_last_post_time = $current_time, + topic_bumped = 1, + topic_bumper = " . $user->data['user_id'] . " + WHERE topic_id = $topic_id"; + $db->sql_query($sql); + + update_post_information('forum', $forum_id); + + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_lastpost_time = $current_time + WHERE user_id = " . $user->data['user_id']; + $db->sql_query($sql); + + $db->sql_transaction('commit'); + + markread('post', $forum_id, $topic_id, $current_time); + + add_log('mod', $forum_id, $topic_id, 'LOG_BUMP_TOPIC', $post_data['topic_title']); + + $meta_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}"; + meta_refresh(3, $meta_url); + + $message = $user->lang['TOPIC_BUMPED'] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + + trigger_error($message); + } + + trigger_error('BUMP_ERROR'); +} + +// Subject length limiting to 60 characters if first post... +if ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_data['post_id'])) +{ + $template->assign_var('S_NEW_MESSAGE', true); +} + +// Determine some vars +if (isset($post_data['poster_id']) && $post_data['poster_id'] == ANONYMOUS) +{ + $post_data['quote_username'] = (!empty($post_data['post_username'])) ? $post_data['post_username'] : $user->lang['GUEST']; +} +else +{ + $post_data['quote_username'] = isset($post_data['username']) ? $post_data['username'] : ''; +} + +$post_data['post_edit_locked'] = (isset($post_data['post_edit_locked'])) ? (int) $post_data['post_edit_locked'] : 0; +$post_data['post_subject_md5'] = (isset($post_data['post_subject']) && $mode == 'edit') ? md5($post_data['post_subject']) : ''; +$post_data['post_subject'] = (in_array($mode, array('quote', 'edit'))) ? $post_data['post_subject'] : ((isset($post_data['topic_title'])) ? $post_data['topic_title'] : ''); +$post_data['topic_time_limit'] = (isset($post_data['topic_time_limit'])) ? (($post_data['topic_time_limit']) ? (int) $post_data['topic_time_limit'] / 86400 : (int) $post_data['topic_time_limit']) : 0; +$post_data['poll_length'] = (!empty($post_data['poll_length'])) ? (int) $post_data['poll_length'] / 86400 : 0; +$post_data['poll_start'] = (!empty($post_data['poll_start'])) ? (int) $post_data['poll_start'] : 0; +$post_data['icon_id'] = (!isset($post_data['icon_id']) || in_array($mode, array('quote', 'reply'))) ? 0 : (int) $post_data['icon_id']; +$post_data['poll_options'] = array(); + +// Get Poll Data +if ($post_data['poll_start']) +{ + $sql = 'SELECT poll_option_text + FROM ' . POLL_OPTIONS_TABLE . " + WHERE topic_id = $topic_id + ORDER BY poll_option_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $post_data['poll_options'][] = trim($row['poll_option_text']); + } + $db->sql_freeresult($result); +} + +$orig_poll_options_size = sizeof($post_data['poll_options']); + +$message_parser = new parse_message(); + +if (isset($post_data['post_text'])) +{ + $message_parser->message = &$post_data['post_text']; + unset($post_data['post_text']); +} + +// Set some default variables +$uninit = array('post_attachment' => 0, 'poster_id' => $user->data['user_id'], 'enable_magic_url' => 0, 'topic_status' => 0, 'topic_type' => POST_NORMAL, 'post_subject' => '', 'topic_title' => '', 'post_time' => 0, 'post_edit_reason' => '', 'notify_set' => 0); + +foreach ($uninit as $var_name => $default_value) +{ + if (!isset($post_data[$var_name])) + { + $post_data[$var_name] = $default_value; + } +} +unset($uninit); + +// Always check if the submitted attachment data is valid and belongs to the user. +// Further down (especially in submit_post()) we do not check this again. +$message_parser->get_submitted_attachment_data($post_data['poster_id']); + +if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit') +{ + // Do not change to SELECT * + $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename + FROM ' . ATTACHMENTS_TABLE . " + WHERE post_msg_id = $post_id + AND in_message = 0 + AND is_orphan = 0 + ORDER BY filetime DESC"; + $result = $db->sql_query($sql); + $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); + $db->sql_freeresult($result); +} + +if ($post_data['poster_id'] == ANONYMOUS) +{ + $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['post_username']) : ''; +} +else +{ + $post_data['username'] = ($mode == 'quote' || $mode == 'edit') ? trim($post_data['username']) : ''; +} + +$post_data['enable_urls'] = $post_data['enable_magic_url']; + +if ($mode != 'edit') +{ + $post_data['enable_sig'] = ($config['allow_sig'] && $user->optionget('attachsig')) ? true: false; + $post_data['enable_smilies'] = ($config['allow_smilies'] && $user->optionget('smilies')) ? true : false; + $post_data['enable_bbcode'] = ($config['allow_bbcode'] && $user->optionget('bbcode')) ? true : false; + $post_data['enable_urls'] = true; +} + +$post_data['enable_magic_url'] = $post_data['drafts'] = false; + +// User own some drafts? +if ($user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) +{ + $sql = 'SELECT draft_id + FROM ' . DRAFTS_TABLE . ' + WHERE user_id = ' . $user->data['user_id'] . + (($forum_id) ? ' AND forum_id = ' . (int) $forum_id : '') . + (($topic_id) ? ' AND topic_id = ' . (int) $topic_id : '') . + (($draft_id) ? " AND draft_id <> $draft_id" : ''); + $result = $db->sql_query_limit($sql, 1); + + if ($db->sql_fetchrow($result)) + { + $post_data['drafts'] = true; + } + $db->sql_freeresult($result); +} + +$check_value = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); + +// Check if user is watching this topic +if ($mode != 'post' && $config['allow_topic_notify'] && $user->data['is_registered']) +{ + $sql = 'SELECT topic_id + FROM ' . TOPICS_WATCH_TABLE . ' + WHERE topic_id = ' . $topic_id . ' + AND user_id = ' . $user->data['user_id']; + $result = $db->sql_query($sql); + $post_data['notify_set'] = (int) $db->sql_fetchfield('topic_id'); + $db->sql_freeresult($result); +} + +// Do we want to edit our post ? +if ($mode == 'edit' && $post_data['bbcode_uid']) +{ + $message_parser->bbcode_uid = $post_data['bbcode_uid']; +} + +// HTML, BBCode, Smilies, Images and Flash status +$bbcode_status = ($config['allow_bbcode'] && $auth->acl_get('f_bbcode', $forum_id)) ? true : false; +$smilies_status = ($config['allow_smilies'] && $auth->acl_get('f_smilies', $forum_id)) ? true : false; +$img_status = ($bbcode_status && $auth->acl_get('f_img', $forum_id)) ? true : false; +$url_status = ($config['allow_post_links']) ? true : false; +$flash_status = ($bbcode_status && $auth->acl_get('f_flash', $forum_id) && $config['allow_post_flash']) ? true : false; +$quote_status = true; + +// Save Draft +if ($save && $user->data['is_registered'] && $auth->acl_get('u_savedrafts') && ($mode == 'reply' || $mode == 'post' || $mode == 'quote')) +{ + $subject = utf8_normalize_nfc(request_var('subject', '', true)); + $subject = (!$subject && $mode != 'post') ? $post_data['topic_title'] : $subject; + $message = utf8_normalize_nfc(request_var('message', '', true)); + + if ($subject && $message) + { + if (confirm_box(true)) + { + $sql = 'INSERT INTO ' . DRAFTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'user_id' => (int) $user->data['user_id'], + 'topic_id' => (int) $topic_id, + 'forum_id' => (int) $forum_id, + 'save_time' => (int) $current_time, + 'draft_subject' => (string) $subject, + 'draft_message' => (string) $message) + ); + $db->sql_query($sql); + + $meta_info = ($mode == 'post') ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id) : append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id"); + + meta_refresh(3, $meta_info); + + $message = $user->lang['DRAFT_SAVED'] . '

'; + $message .= ($mode != 'post') ? sprintf($user->lang['RETURN_TOPIC'], '', '') . '

' : ''; + $message .= sprintf($user->lang['RETURN_FORUM'], '', ''); + + trigger_error($message); + } + else + { + $s_hidden_fields = build_hidden_fields(array( + 'mode' => $mode, + 'save' => true, + 'f' => $forum_id, + 't' => $topic_id, + 'subject' => $subject, + 'message' => $message, + 'attachment_data' => $message_parser->attachment_data, + ) + ); + + $hidden_fields = array( + 'icon_id' => 0, + + 'disable_bbcode' => false, + 'disable_smilies' => false, + 'disable_magic_url' => false, + 'attach_sig' => true, + 'lock_topic' => false, + + 'topic_type' => POST_NORMAL, + 'topic_time_limit' => 0, + + 'poll_title' => '', + 'poll_option_text' => '', + 'poll_max_options' => 1, + 'poll_length' => 0, + 'poll_vote_change' => false, + ); + + foreach ($hidden_fields as $name => $default) + { + if (!isset($_POST[$name])) + { + // Don't include it, if its not available + unset($hidden_fields[$name]); + continue; + } + + if (is_bool($default)) + { + // Use the string representation + $hidden_fields[$name] = request_var($name, ''); + } + else + { + $hidden_fields[$name] = request_var($name, $default); + } + } + + $s_hidden_fields .= build_hidden_fields($hidden_fields); + + confirm_box(false, 'SAVE_DRAFT', $s_hidden_fields); + } + } + else + { + if (utf8_clean_string($subject) === '') + { + $error[] = $user->lang['EMPTY_SUBJECT']; + } + + if (utf8_clean_string($message) === '') + { + $error[] = $user->lang['TOO_FEW_CHARS']; + } + } + unset($subject, $message); +} + +// Load requested Draft +if ($draft_id && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $user->data['is_registered'] && $auth->acl_get('u_savedrafts')) +{ + $sql = 'SELECT draft_subject, draft_message + FROM ' . DRAFTS_TABLE . " + WHERE draft_id = $draft_id + AND user_id = " . $user->data['user_id']; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + $post_data['post_subject'] = $row['draft_subject']; + $message_parser->message = $row['draft_message']; + + $template->assign_var('S_DRAFT_LOADED', true); + } + else + { + $draft_id = 0; + } +} + +// Load draft overview +if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_data['drafts']) +{ + load_drafts($topic_id, $forum_id); +} + + +if ($submit || $preview || $refresh) +{ + $post_data['topic_cur_post_id'] = request_var('topic_cur_post_id', 0); + $post_data['post_subject'] = utf8_normalize_nfc(request_var('subject', '', true)); + $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); + + $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); + $post_data['post_edit_reason'] = (!empty($_POST['edit_reason']) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; + + $post_data['orig_topic_type'] = $post_data['topic_type']; + $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); + $post_data['topic_time_limit'] = request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0)); + + if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) + { + $post_data['icon_id'] = request_var('icon', (int) $post_data['icon_id']); + } + + $post_data['enable_bbcode'] = (!$bbcode_status || isset($_POST['disable_bbcode'])) ? false : true; + $post_data['enable_smilies'] = (!$smilies_status || isset($_POST['disable_smilies'])) ? false : true; + $post_data['enable_urls'] = (isset($_POST['disable_magic_url'])) ? 0 : 1; + $post_data['enable_sig'] = (!$config['allow_sig'] || !$auth->acl_get('f_sigs', $forum_id) || !$auth->acl_get('u_sig')) ? false : ((isset($_POST['attach_sig']) && $user->data['is_registered']) ? true : false); + + if ($config['allow_topic_notify'] && $user->data['is_registered']) + { + $notify = (isset($_POST['notify'])) ? true : false; + } + else + { + $notify = false; + } + + $topic_lock = (isset($_POST['lock_topic'])) ? true : false; + $post_lock = (isset($_POST['lock_post'])) ? true : false; + $poll_delete = (isset($_POST['poll_delete'])) ? true : false; + + if ($submit) + { + $status_switch = (($post_data['enable_bbcode']+1) << 8) + (($post_data['enable_smilies']+1) << 4) + (($post_data['enable_urls']+1) << 2) + (($post_data['enable_sig']+1) << 1); + $status_switch = ($status_switch != $check_value); + } + else + { + $status_switch = 1; + } + + // Delete Poll + if ($poll_delete && $mode == 'edit' && sizeof($post_data['poll_options']) && + ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))) + { + if ($submit && check_form_key('posting')) + { + $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . " + WHERE topic_id = $topic_id"; + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . " + WHERE topic_id = $topic_id"; + $db->sql_query($sql); + + $topic_sql = array( + 'poll_title' => '', + 'poll_start' => 0, + 'poll_length' => 0, + 'poll_last_vote' => 0, + 'poll_max_options' => 0, + 'poll_vote_change' => 0 + ); + + $sql = 'UPDATE ' . TOPICS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $topic_sql) . " + WHERE topic_id = $topic_id"; + $db->sql_query($sql); + } + + $post_data['poll_title'] = $post_data['poll_option_text'] = ''; + $post_data['poll_vote_change'] = $post_data['poll_max_options'] = $post_data['poll_length'] = 0; + } + else + { + $post_data['poll_title'] = utf8_normalize_nfc(request_var('poll_title', '', true)); + $post_data['poll_length'] = request_var('poll_length', 0); + $post_data['poll_option_text'] = utf8_normalize_nfc(request_var('poll_option_text', '', true)); + $post_data['poll_max_options'] = request_var('poll_max_options', 1); + $post_data['poll_vote_change'] = ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id) && isset($_POST['poll_vote_change'])) ? 1 : 0; + } + + // If replying/quoting and last post id has changed + // give user option to continue submit or return to post + // notify and show user the post made between his request and the final submit + if (($mode == 'reply' || $mode == 'quote') && $post_data['topic_cur_post_id'] && $post_data['topic_cur_post_id'] != $post_data['topic_last_post_id']) + { + // Only do so if it is allowed forum-wide + if ($post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) + { + if (topic_review($topic_id, $forum_id, 'post_review', $post_data['topic_cur_post_id'])) + { + $template->assign_var('S_POST_REVIEW', true); + } + + $submit = false; + $refresh = true; + } + } + + // Parse Attachments - before checksum is calculated + $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); + + // Grab md5 'checksum' of new message + $message_md5 = md5($message_parser->message); + + // If editing and checksum has changed we know the post was edited while we're editing + // Notify and show user the changed post + if ($mode == 'edit' && $post_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) + { + $edit_post_message_checksum = request_var('edit_post_message_checksum', ''); + $edit_post_subject_checksum = request_var('edit_post_subject_checksum', ''); + + // $post_data['post_checksum'] is the checksum of the post submitted in the meantime + // $message_md5 is the checksum of the post we're about to submit + // $edit_post_message_checksum is the checksum of the post we're editing + // ... + + // We make sure nobody else made exactly the same change + // we're about to submit by also checking $message_md5 != $post_data['post_checksum'] + if (($edit_post_message_checksum !== '' && $edit_post_message_checksum != $post_data['post_checksum'] && $message_md5 != $post_data['post_checksum']) + || ($edit_post_subject_checksum !== '' && $edit_post_subject_checksum != $post_data['post_subject_md5'] && md5($post_data['post_subject']) != $post_data['post_subject_md5'])) + { + if (topic_review($topic_id, $forum_id, 'post_review_edit', $post_id)) + { + $template->assign_vars(array( + 'S_POST_REVIEW' => true, + + 'L_POST_REVIEW' => $user->lang['POST_REVIEW_EDIT'], + 'L_POST_REVIEW_EXPLAIN' => $user->lang['POST_REVIEW_EDIT_EXPLAIN'], + )); + } + + $submit = false; + $refresh = true; + } + } + + // Check checksum ... don't re-parse message if the same + $update_message = ($mode != 'edit' || $message_md5 != $post_data['post_checksum'] || $status_switch || strlen($post_data['bbcode_uid']) < BBCODE_UID_LEN) ? true : false; + + // Also check if subject got updated... + $update_subject = $mode != 'edit' || ($post_data['post_subject_md5'] && $post_data['post_subject_md5'] != md5($post_data['post_subject'])); + + // Parse message + if ($update_message) + { + if (sizeof($message_parser->warn_msg)) + { + $error[] = implode('
', $message_parser->warn_msg); + $message_parser->warn_msg = array(); + } + + $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); + + // On a refresh we do not care about message parsing errors + if (sizeof($message_parser->warn_msg) && $refresh) + { + $message_parser->warn_msg = array(); + } + } + else + { + $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; + } + + if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) + { + // Flood check + $last_post_time = 0; + + if ($user->data['is_registered']) + { + $last_post_time = $user->data['user_lastpost_time']; + } + else + { + $sql = 'SELECT post_time AS last_post_time + FROM ' . POSTS_TABLE . " + WHERE poster_ip = '" . $user->ip . "' + AND post_time > " . ($current_time - $config['flood_interval']); + $result = $db->sql_query_limit($sql, 1); + if ($row = $db->sql_fetchrow($result)) + { + $last_post_time = $row['last_post_time']; + } + $db->sql_freeresult($result); + } + + if ($last_post_time && ($current_time - $last_post_time) < intval($config['flood_interval'])) + { + $error[] = $user->lang['FLOOD_ERROR']; + } + } + + // Validate username + if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + + if (($result = validate_username($post_data['username'], (!empty($post_data['post_username'])) ? $post_data['post_username'] : '')) !== false) + { + $user->add_lang('ucp'); + $error[] = $user->lang[$result . '_USERNAME']; + } + } + + if ($config['enable_post_confirm'] && !$user->data['is_registered'] && in_array($mode, array('quote', 'post', 'reply'))) + { + $captcha_data = array( + 'message' => utf8_normalize_nfc(request_var('message', '', true)), + 'subject' => utf8_normalize_nfc(request_var('subject', '', true)), + 'username' => utf8_normalize_nfc(request_var('username', '', true)), + ); + $vc_response = $captcha->validate($captcha_data); + if ($vc_response) + { + $error[] = $vc_response; + } + } + + // check form + if (($submit || $preview) && !check_form_key('posting')) + { + $error[] = $user->lang['FORM_INVALID']; + } + + // Parse subject + if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) + { + $error[] = $user->lang['EMPTY_SUBJECT']; + } + + $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; + + if ($post_data['poll_option_text'] && + ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) + && $auth->acl_get('f_poll', $forum_id)) + { + $poll = array( + 'poll_title' => $post_data['poll_title'], + 'poll_length' => $post_data['poll_length'], + 'poll_max_options' => $post_data['poll_max_options'], + 'poll_option_text' => $post_data['poll_option_text'], + 'poll_start' => $post_data['poll_start'], + 'poll_last_vote' => $post_data['poll_last_vote'], + 'poll_vote_change' => $post_data['poll_vote_change'], + 'enable_bbcode' => $post_data['enable_bbcode'], + 'enable_urls' => $post_data['enable_urls'], + 'enable_smilies' => $post_data['enable_smilies'], + 'img_status' => $img_status + ); + + $message_parser->parse_poll($poll); + + $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : ''; + $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; + + /* We reset votes, therefore also allow removing options + if ($post_data['poll_last_vote'] && ($poll['poll_options_size'] < $orig_poll_options_size)) + { + $message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS']; + }*/ + } + else + { + $poll = array(); + } + + // Check topic type + if ($post_data['topic_type'] != POST_NORMAL && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) + { + switch ($post_data['topic_type']) + { + case POST_GLOBAL: + case POST_ANNOUNCE: + $auth_option = 'f_announce'; + break; + + case POST_STICKY: + $auth_option = 'f_sticky'; + break; + + default: + $auth_option = ''; + break; + } + + if (!$auth->acl_get($auth_option, $forum_id)) + { + // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod. + // Another case would be a mod not having sticky permissions for example but edit permissions. + if ($mode == 'edit') + { + // To prevent non-authed users messing around with the topic type we reset it to the original one. + $post_data['topic_type'] = $post_data['orig_topic_type']; + } + else + { + $error[] = $user->lang['CANNOT_POST_' . str_replace('F_', '', strtoupper($auth_option))]; + } + } + } + + if (sizeof($message_parser->warn_msg)) + { + $error[] = implode('
', $message_parser->warn_msg); + } + + // DNSBL check + if ($config['check_dnsbl'] && !$refresh) + { + if (($dnsbl = $user->check_dnsbl('post')) !== false) + { + $error[] = sprintf($user->lang['IP_BLACKLISTED'], $user->ip, $dnsbl[1]); + } + } + + // Store message, sync counters + if (!sizeof($error) && $submit) + { + // Check if we want to de-globalize the topic... and ask for new forum + if ($post_data['topic_type'] != POST_GLOBAL) + { + $sql = 'SELECT topic_type, forum_id + FROM ' . TOPICS_TABLE . " + WHERE topic_id = $topic_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) + { + $to_forum_id = request_var('to_forum_id', 0); + + if ($to_forum_id) + { + $sql = 'SELECT forum_type + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $to_forum_id; + $result = $db->sql_query($sql); + $forum_type = (int) $db->sql_fetchfield('forum_type'); + $db->sql_freeresult($result); + + if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id)) + { + $to_forum_id = 0; + } + } + + if (!$to_forum_id) + { + include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); + + $template->assign_vars(array( + 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), + 'S_UNGLOBALISE' => true) + ); + + $submit = false; + $refresh = true; + } + else + { + if (!$auth->acl_get('f_post', $to_forum_id)) + { + // This will only be triggered if the user tried to trick the forum. + trigger_error('NOT_AUTHORISED'); + } + + $forum_id = $to_forum_id; + } + } + } + + if ($submit) + { + // Lock/Unlock Topic + $change_topic_status = $post_data['topic_status']; + $perm_lock_unlock = ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED)) ? true : false; + + if ($post_data['topic_status'] == ITEM_LOCKED && !$topic_lock && $perm_lock_unlock) + { + $change_topic_status = ITEM_UNLOCKED; + } + else if ($post_data['topic_status'] == ITEM_UNLOCKED && $topic_lock && $perm_lock_unlock) + { + $change_topic_status = ITEM_LOCKED; + } + + if ($change_topic_status != $post_data['topic_status']) + { + $sql = 'UPDATE ' . TOPICS_TABLE . " + SET topic_status = $change_topic_status + WHERE topic_id = $topic_id + AND topic_moved_id = 0"; + $db->sql_query($sql); + + $user_lock = ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $post_data['topic_poster']) ? 'USER_' : ''; + + add_log('mod', $forum_id, $topic_id, 'LOG_' . $user_lock . (($change_topic_status == ITEM_LOCKED) ? 'LOCK' : 'UNLOCK'), $post_data['topic_title']); + } + + // Lock/Unlock Post Edit + if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_LOCKED && !$post_lock && $auth->acl_get('m_edit', $forum_id)) + { + $post_data['post_edit_locked'] = ITEM_UNLOCKED; + } + else if ($mode == 'edit' && $post_data['post_edit_locked'] == ITEM_UNLOCKED && $post_lock && $auth->acl_get('m_edit', $forum_id)) + { + $post_data['post_edit_locked'] = ITEM_LOCKED; + } + + $data = array( + 'topic_title' => (empty($post_data['topic_title'])) ? $post_data['post_subject'] : $post_data['topic_title'], + 'topic_first_post_id' => (isset($post_data['topic_first_post_id'])) ? (int) $post_data['topic_first_post_id'] : 0, + 'topic_last_post_id' => (isset($post_data['topic_last_post_id'])) ? (int) $post_data['topic_last_post_id'] : 0, + 'topic_time_limit' => (int) $post_data['topic_time_limit'], + 'topic_attachment' => (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0, + 'post_id' => (int) $post_id, + 'topic_id' => (int) $topic_id, + 'forum_id' => (int) $forum_id, + 'icon_id' => (int) $post_data['icon_id'], + 'poster_id' => (int) $post_data['poster_id'], + 'enable_sig' => (bool) $post_data['enable_sig'], + 'enable_bbcode' => (bool) $post_data['enable_bbcode'], + 'enable_smilies' => (bool) $post_data['enable_smilies'], + 'enable_urls' => (bool) $post_data['enable_urls'], + 'enable_indexing' => (bool) $post_data['enable_indexing'], + 'message_md5' => (string) $message_md5, + 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time, + 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', + 'post_edit_reason' => $post_data['post_edit_reason'], + 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), + 'forum_parents' => $post_data['forum_parents'], + 'forum_name' => $post_data['forum_name'], + 'notify' => $notify, + 'notify_set' => $post_data['notify_set'], + 'poster_ip' => (isset($post_data['poster_ip'])) ? $post_data['poster_ip'] : $user->ip, + 'post_edit_locked' => (int) $post_data['post_edit_locked'], + 'bbcode_bitfield' => $message_parser->bbcode_bitfield, + 'bbcode_uid' => $message_parser->bbcode_uid, + 'message' => $message_parser->message, + 'attachment_data' => $message_parser->attachment_data, + 'filename_data' => $message_parser->filename_data, + + 'topic_approved' => (isset($post_data['topic_approved'])) ? $post_data['topic_approved'] : false, + 'post_approved' => (isset($post_data['post_approved'])) ? $post_data['post_approved'] : false, + ); + + if ($mode == 'edit') + { + $data['topic_replies_real'] = $post_data['topic_replies_real']; + $data['topic_replies'] = $post_data['topic_replies']; + } + + // The last parameter tells submit_post if search indexer has to be run + $redirect_url = submit_post($mode, $post_data['post_subject'], $post_data['username'], $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); + + if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) + { + $captcha->reset(); + } + + // Check the permissions for post approval. Moderators are not affected. + if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) || !empty($post_data['force_approved_state'])) + { + meta_refresh(10, $redirect_url); + $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; + $message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']); + } + else + { + meta_refresh(3, $redirect_url); + + $message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'; + $message = $user->lang[$message] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); + } + + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + trigger_error($message); + } + } +} + +// Preview +if (!sizeof($error) && $preview) +{ + $post_data['post_time'] = ($mode == 'edit') ? $post_data['post_time'] : $current_time; + + $preview_message = $message_parser->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies'], false); + + $preview_signature = ($mode == 'edit') ? $post_data['user_sig'] : $user->data['user_sig']; + $preview_signature_uid = ($mode == 'edit') ? $post_data['user_sig_bbcode_uid'] : $user->data['user_sig_bbcode_uid']; + $preview_signature_bitfield = ($mode == 'edit') ? $post_data['user_sig_bbcode_bitfield'] : $user->data['user_sig_bbcode_bitfield']; + + // Signature + if ($post_data['enable_sig'] && $config['allow_sig'] && $preview_signature && $auth->acl_get('f_sigs', $forum_id)) + { + $parse_sig = new parse_message($preview_signature); + $parse_sig->bbcode_uid = $preview_signature_uid; + $parse_sig->bbcode_bitfield = $preview_signature_bitfield; + + // Not sure about parameters for bbcode/smilies/urls... in signatures + $parse_sig->format_display($config['allow_sig_bbcode'], true, $config['allow_sig_smilies']); + $preview_signature = $parse_sig->message; + unset($parse_sig); + } + else + { + $preview_signature = ''; + } + + $preview_subject = censor_text($post_data['post_subject']); + + // Poll Preview + if (!$poll_delete && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) + && $auth->acl_get('f_poll', $forum_id)) + { + $parse_poll = new parse_message($post_data['poll_title']); + $parse_poll->bbcode_uid = $message_parser->bbcode_uid; + $parse_poll->bbcode_bitfield = $message_parser->bbcode_bitfield; + + $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); + + if ($post_data['poll_length']) + { + $poll_end = ($post_data['poll_length'] * 86400) + (($post_data['poll_start']) ? $post_data['poll_start'] : time()); + } + + $template->assign_vars(array( + 'S_HAS_POLL_OPTIONS' => (sizeof($post_data['poll_options'])), + 'S_IS_MULTI_CHOICE' => ($post_data['poll_max_options'] > 1) ? true : false, + + 'POLL_QUESTION' => $parse_poll->message, + + 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', + 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options'])) + ); + + $parse_poll->message = implode("\n", $post_data['poll_options']); + $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); + $preview_poll_options = explode('
', $parse_poll->message); + unset($parse_poll); + + foreach ($preview_poll_options as $key => $option) + { + $template->assign_block_vars('poll_option', array( + 'POLL_OPTION_CAPTION' => $option, + 'POLL_OPTION_ID' => $key + 1) + ); + } + unset($preview_poll_options); + } + + // Attachment Preview + if (sizeof($message_parser->attachment_data)) + { + $template->assign_var('S_HAS_ATTACHMENTS', true); + + $update_count = array(); + $attachment_data = $message_parser->attachment_data; + + parse_attachments($forum_id, $preview_message, $attachment_data, $update_count, true); + + foreach ($attachment_data as $i => $attachment) + { + $template->assign_block_vars('attachment', array( + 'DISPLAY_ATTACHMENT' => $attachment) + ); + } + unset($attachment_data); + } + + if (!sizeof($error)) + { + $template->assign_vars(array( + 'PREVIEW_SUBJECT' => $preview_subject, + 'PREVIEW_MESSAGE' => $preview_message, + 'PREVIEW_SIGNATURE' => $preview_signature, + + 'S_DISPLAY_PREVIEW' => true) + ); + } +} + +// Decode text for message display +$post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; +$message_parser->decode_message($post_data['bbcode_uid']); + +if ($mode == 'quote' && !$submit && !$preview && !$refresh) +{ + if ($config['allow_bbcode']) + { + $message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; + } + else + { + $offset = 0; + $quote_string = "> "; + $message = censor_text(trim($message_parser->message)); + // see if we are nesting. It's easily tricked but should work for one level of nesting + if (strpos($message, ">") !== false) + { + $offset = 10; + } + $message = utf8_wordwrap($message, 75 + $offset, "\n"); + + $message = $quote_string . $message; + $message = str_replace("\n", "\n" . $quote_string, $message); + $message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . " :\n" . $message . "\n"; + } +} + +if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh) +{ + $post_data['post_subject'] = ((strpos($post_data['post_subject'], 'Re: ') !== 0) ? 'Re: ' : '') . censor_text($post_data['post_subject']); +} + +$attachment_data = $message_parser->attachment_data; +$filename_data = $message_parser->filename_data; +$post_data['post_text'] = $message_parser->message; + +if (sizeof($post_data['poll_options']) && $post_data['poll_title']) +{ + $message_parser->message = $post_data['poll_title']; + $message_parser->bbcode_uid = $post_data['bbcode_uid']; + + $message_parser->decode_message(); + $post_data['poll_title'] = $message_parser->message; + + $message_parser->message = implode("\n", $post_data['poll_options']); + $message_parser->decode_message(); + $post_data['poll_options'] = explode("\n", $message_parser->message); +} + +// MAIN POSTING PAGE BEGINS HERE + +// Forum moderators? +$moderators = array(); +if ($config['load_moderators']) +{ + get_moderators($moderators, $forum_id); +} + +// Generate smiley listing +generate_smilies('inline', $forum_id); + +// Generate inline attachment select box +posting_gen_inline_attachments($attachment_data); + +// Do show topic type selection only in first post. +$topic_type_toggle = false; + +if ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'])) +{ + $topic_type_toggle = posting_gen_topic_types($forum_id, $post_data['topic_type']); +} + +$s_topic_icons = false; +if ($post_data['enable_icons'] && $auth->acl_get('f_icons', $forum_id)) +{ + $s_topic_icons = posting_gen_topic_icons($mode, $post_data['icon_id']); +} + +$bbcode_checked = (isset($post_data['enable_bbcode'])) ? !$post_data['enable_bbcode'] : (($config['allow_bbcode']) ? !$user->optionget('bbcode') : 1); +$smilies_checked = (isset($post_data['enable_smilies'])) ? !$post_data['enable_smilies'] : (($config['allow_smilies']) ? !$user->optionget('smilies') : 1); +$urls_checked = (isset($post_data['enable_urls'])) ? !$post_data['enable_urls'] : 0; +$sig_checked = $post_data['enable_sig']; +$lock_topic_checked = (isset($topic_lock) && $topic_lock) ? $topic_lock : (($post_data['topic_status'] == ITEM_LOCKED) ? 1 : 0); +$lock_post_checked = (isset($post_lock)) ? $post_lock : $post_data['post_edit_locked']; + +// If the user is replying or posting and not already watching this topic but set to always being notified we need to overwrite this setting +$notify_set = ($mode != 'edit' && $config['allow_topic_notify'] && $user->data['is_registered'] && !$post_data['notify_set']) ? $user->data['user_notify'] : $post_data['notify_set']; +$notify_checked = (isset($notify)) ? $notify : (($mode == 'post') ? $user->data['user_notify'] : $notify_set); + +// Page title & action URL, include session_id for security purpose +$s_action = append_sid("{$phpbb_root_path}posting.$phpEx", "mode=$mode&f=$forum_id", true, $user->session_id); +$s_action .= ($topic_id) ? "&t=$topic_id" : ''; +$s_action .= ($post_id) ? "&p=$post_id" : ''; + +switch ($mode) +{ + case 'post': + $page_title = $user->lang['POST_TOPIC']; + break; + + case 'quote': + case 'reply': + $page_title = $user->lang['POST_REPLY']; + break; + + case 'delete': + case 'edit': + $page_title = $user->lang['EDIT_POST']; + break; +} + +// Build Navigation Links +generate_forum_nav($post_data); + +// Build Forum Rules +generate_forum_rules($post_data); + +// Posting uses is_solved for legacy reasons. Plugins have to use is_solved to force themselves to be displayed. +if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === false) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) +{ + + $template->assign_vars(array( + 'S_CONFIRM_CODE' => true, + 'CAPTCHA_TEMPLATE' => $captcha->get_template(), + )); +} + +$s_hidden_fields = ($mode == 'reply' || $mode == 'quote') ? '' : ''; +$s_hidden_fields .= ''; +$s_hidden_fields .= ($draft_id || isset($_REQUEST['draft_loaded'])) ? '' : ''; + +if ($mode == 'edit') +{ + $s_hidden_fields .= build_hidden_fields(array( + 'edit_post_message_checksum' => $post_data['post_checksum'], + 'edit_post_subject_checksum' => $post_data['post_subject_md5'], + )); +} + +// Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview +if (isset($captcha) && $captcha->is_solved() !== false) +{ + $s_hidden_fields .= build_hidden_fields($captcha->get_hidden_fields()); +} + +$form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$config['allow_attachments'] || !$auth->acl_get('u_attach') || !$auth->acl_get('f_attach', $forum_id)) ? '' : ' enctype="multipart/form-data"'; +add_form_key('posting'); + + +// Start assigning vars for main posting page ... +$template->assign_vars(array( + 'L_POST_A' => $page_title, + 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], + 'L_MESSAGE_BODY_EXPLAIN' => (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', + + 'FORUM_NAME' => $post_data['forum_name'], + 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', + 'TOPIC_TITLE' => censor_text($post_data['topic_title']), + 'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '', + 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', + 'SUBJECT' => $post_data['post_subject'], + 'MESSAGE' => $post_data['post_text'], + 'BBCODE_STATUS' => ($bbcode_status) ? sprintf($user->lang['BBCODE_IS_ON'], '', '') : sprintf($user->lang['BBCODE_IS_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'], + 'SMILIES_STATUS' => ($smilies_status) ? $user->lang['SMILIES_ARE_ON'] : $user->lang['SMILIES_ARE_OFF'], + 'URL_STATUS' => ($bbcode_status && $url_status) ? $user->lang['URL_IS_ON'] : $user->lang['URL_IS_OFF'], + 'MAX_FONT_SIZE' => (int) $config['max_post_font_size'], + 'MINI_POST_IMG' => $user->img('icon_post_target', $user->lang['POST']), + 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', + 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', + 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], + 'EDIT_REASON' => $post_data['post_edit_reason'], + 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), + 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', + 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), + 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")), + + 'S_PRIVMSGS' => false, + 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, + 'S_EDIT_POST' => ($mode == 'edit') ? true : false, + 'S_EDIT_REASON' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, + 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, + 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, + 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, + 'S_BBCODE_ALLOWED' => $bbcode_status, + 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', + 'S_SMILIES_ALLOWED' => $smilies_status, + 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', + 'S_SIG_ALLOWED' => ($auth->acl_get('f_sigs', $forum_id) && $config['allow_sig'] && $user->data['is_registered']) ? true : false, + 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', + 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true, + 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', + 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, + 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', + 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, + 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', + 'S_LINKS_ALLOWED' => $url_status, + 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', + 'S_TYPE_TOGGLE' => $topic_type_toggle, + 'S_SAVE_ALLOWED' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $mode != 'edit') ? true : false, + 'S_HAS_DRAFTS' => ($auth->acl_get('u_savedrafts') && $user->data['is_registered'] && $post_data['drafts']) ? true : false, + 'S_FORM_ENCTYPE' => $form_enctype, + + 'S_BBCODE_IMG' => $img_status, + 'S_BBCODE_URL' => $url_status, + 'S_BBCODE_FLASH' => $flash_status, + 'S_BBCODE_QUOTE' => $quote_status, + + 'S_POST_ACTION' => $s_action, + 'S_HIDDEN_FIELDS' => $s_hidden_fields) +); + +// Build custom bbcodes array +display_custom_bbcodes(); + +// Poll entry +if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) + && $auth->acl_get('f_poll', $forum_id)) +{ + $template->assign_vars(array( + 'S_SHOW_POLL_BOX' => true, + 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), + 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), + 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, + + 'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], $config['max_poll_options']), + + 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', + 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', + 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', + 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, + 'POLL_LENGTH' => $post_data['poll_length']) + ); +} + +// Show attachment box for adding attachments if true +$allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); + +// Attachment entry +posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); + +// Output page ... +page_header($page_title, false); + +$template->set_filenames(array( + 'body' => 'posting_body.html') +); + +make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx")); + +// Topic review +if ($mode == 'reply' || $mode == 'quote') +{ + if (topic_review($topic_id, $forum_id)) + { + $template->assign_var('S_DISPLAY_REVIEW', true); + } +} + +page_footer(); + +/** +* Show upload popup (progress bar) +*/ +function upload_popup($forum_style = 0) +{ + global $template, $user; + + ($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting'); + + page_header($user->lang['PROGRESS_BAR'], false); + + $template->set_filenames(array( + 'popup' => 'posting_progress_bar.html') + ); + + $template->assign_vars(array( + 'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS'])) + ); + + $template->display('popup'); + + garbage_collection(); + exit_handler(); +} + +/** +* Do the various checks required for removing posts as well as removing it +*/ +function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) +{ + global $user, $db, $auth, $config; + global $phpbb_root_path, $phpEx; + + // If moderator removing post or user itself removing post, present a confirmation screen + if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) + { + $s_hidden_fields = build_hidden_fields(array( + 'p' => $post_id, + 'f' => $forum_id, + 'mode' => 'delete') + ); + + if (confirm_box(true)) + { + $data = array( + 'topic_first_post_id' => $post_data['topic_first_post_id'], + 'topic_last_post_id' => $post_data['topic_last_post_id'], + 'topic_replies_real' => $post_data['topic_replies_real'], + 'topic_approved' => $post_data['topic_approved'], + 'topic_type' => $post_data['topic_type'], + 'post_approved' => $post_data['post_approved'], + 'post_reported' => $post_data['post_reported'], + 'post_time' => $post_data['post_time'], + 'poster_id' => $post_data['poster_id'], + 'post_postcount' => $post_data['post_postcount'] + ); + + $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data); + $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; + + if ($next_post_id === false) + { + add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title'], $post_username); + + $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); + $message = $user->lang['POST_DELETED']; + } + else + { + add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject'], $post_username); + + $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; + $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + } + + meta_refresh(3, $meta_info); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + trigger_error($message); + } + else + { + confirm_box(false, 'DELETE_POST', $s_hidden_fields); + } + } + + // If we are here the user is not able to delete - present the correct error message + if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) + { + trigger_error('DELETE_OWN_POSTS'); + } + + if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) + { + trigger_error('CANNOT_DELETE_REPLIED'); + } + + trigger_error('USER_CANNOT_DELETE'); +} + +?> \ No newline at end of file -- cgit v1.2.1 From b68de2323d6444b4b3685a98bbcb9500a38e45cb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 16 Dec 2009 15:48:23 +0000 Subject: merge changes from 3.0.x branch git-svn-id: file:///svn/phpbb/trunk@10342 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/posting.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1c7cd95b81..660ca8ef23 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -45,13 +45,6 @@ $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var $error = $post_data = array(); $current_time = time(); -if ($config['enable_post_confirm'] && !$user->data['is_registered']) -{ - include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); - $captcha->init(CONFIRM_POST); -} - // Was cancel pressed? If so then redirect to the appropriate page if ($cancel || ($current_time - $lastclick < 2 && $submit)) { @@ -95,8 +88,8 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id) - AND t.topic_approved = 1"; + OR f.forum_id = $forum_id)" . + (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'); break; case 'quote': @@ -125,7 +118,7 @@ switch ($mode) AND u.user_id = p.poster_id AND (f.forum_id = t.forum_id OR f.forum_id = $forum_id)" . - (($auth->acl_get('m_approve', $forum_id) && $mode != 'quote') ? '' : 'AND p.post_approved = 1'); + (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); break; case 'smilies': @@ -171,6 +164,13 @@ if (!$post_data) trigger_error(($mode == 'post' || $mode == 'bump' || $mode == 'reply') ? 'NO_TOPIC' : 'NO_POST'); } +// Not able to reply to unapproved posts/topics +// TODO: add more descriptive language key +if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && !$post_data['topic_approved']) || ($mode == 'quote' && !$post_data['post_approved']))) +{ + trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); +} + if ($mode == 'popup') { upload_popup($post_data['forum_style']); @@ -179,6 +179,13 @@ if ($mode == 'popup') $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); +if ($config['enable_post_confirm'] && !$user->data['is_registered']) +{ + include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); + $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha->init(CONFIRM_POST); +} + // Use post_row values in favor of submitted ones... $forum_id = (!empty($post_data['forum_id'])) ? (int) $post_data['forum_id'] : (int) $forum_id; $topic_id = (!empty($post_data['topic_id'])) ? (int) $post_data['topic_id'] : (int) $topic_id; -- cgit v1.2.1 From fccd7f0ab5ab559dc89be6af9e582a986af8bb13 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 22 Sep 2010 21:58:20 +0200 Subject: [feature/request-class] Convert any direct access to $_* to use $request PHPBB3-9716 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 853ac18aad..86e953680a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -663,7 +663,7 @@ if ($submit || $preview || $refresh) $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); - $post_data['post_edit_reason'] = (!empty($_POST['edit_reason']) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; + $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, phpbb_request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); -- cgit v1.2.1 From af5b9a96409d788733fcb1ff367e0c7fb0583702 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 9 Nov 2010 08:59:25 +0100 Subject: [ticket/9556] Drop php closing tags, add trailing newline Closing tags converted using Oleg's script. remove-php-end-tags.py -a . Trailing newlines added using the following where $ext is file extension. find . -type f -name "*.$ext" -print | xargs printf "e %s\nw\n" | ed -s; Extensions: php, css, html, js, xml. PHPBB3-9556 --- phpBB/posting.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 73ff836f01..23205dd135 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1624,5 +1624,3 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) trigger_error('USER_CANNOT_DELETE'); } - -?> \ No newline at end of file -- cgit v1.2.1 From 3352141264993982215b714ac7a128854494ac1f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Mar 2010 00:38:56 +0100 Subject: [ticket/9684] Remove code for global announcement in root-files PHPBB3-9684 --- phpBB/posting.php | 60 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 58 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 41559056b9..2fcfd126eb 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -87,8 +87,7 @@ switch ($mode) $sql = 'SELECT f.*, t.* FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)" . + AND f.forum_id = t.forum_id" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'); break; @@ -116,8 +115,7 @@ switch ($mode) WHERE p.post_id = $post_id AND t.topic_id = p.topic_id AND u.user_id = p.poster_id - AND (f.forum_id = t.forum_id - OR f.forum_id = $forum_id)" . + AND f.forum_id = t.forum_id" . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); break; @@ -1005,60 +1003,6 @@ if ($submit || $preview || $refresh) // Store message, sync counters if (!sizeof($error) && $submit) { - // Check if we want to de-globalize the topic... and ask for new forum - if ($post_data['topic_type'] != POST_GLOBAL) - { - $sql = 'SELECT topic_type, forum_id - FROM ' . TOPICS_TABLE . " - WHERE topic_id = $topic_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row && !$row['forum_id'] && $row['topic_type'] == POST_GLOBAL) - { - $to_forum_id = request_var('to_forum_id', 0); - - if ($to_forum_id) - { - $sql = 'SELECT forum_type - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $to_forum_id; - $result = $db->sql_query($sql); - $forum_type = (int) $db->sql_fetchfield('forum_type'); - $db->sql_freeresult($result); - - if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id))) - { - $to_forum_id = 0; - } - } - - if (!$to_forum_id) - { - include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx); - - $template->assign_vars(array( - 'S_FORUM_SELECT' => make_forum_select(false, false, false, true, true, true), - 'S_UNGLOBALISE' => true) - ); - - $submit = false; - $refresh = true; - } - else - { - if (!$auth->acl_get('f_post', $to_forum_id)) - { - // This will only be triggered if the user tried to trick the forum. - trigger_error('NOT_AUTHORISED'); - } - - $forum_id = $to_forum_id; - } - } - } - if ($submit) { // Lock/Unlock Topic -- cgit v1.2.1 From 9265ffbcd5c4cff9c9e4e775d7d8d4877b86fbb8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Mar 2010 23:36:47 +0100 Subject: [ticket/9684] Fix a SQL-Error in the posting.php PHPBB3-9684 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 2fcfd126eb..734e97742c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -88,7 +88,7 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1'); + (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1'); break; case 'quote': @@ -116,7 +116,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1'); + (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1'); break; case 'smilies': -- cgit v1.2.1 From 4bdad7125a34e121f7857c34480d0527c1925384 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 13 Jul 2011 11:32:38 +0200 Subject: [ticket/9608] Remove use of references in captcha and other places References are not really needed in PHP due to copy-on-write. Since PHP5, objects are always passed around as identifiers, which means they are mutable. So it is no longer required to pass these by reference either. PHPBB3-9608 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 0809b5a685..74a8ebecb5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -180,7 +180,7 @@ $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); if ($config['enable_post_confirm'] && !$user->data['is_registered']) { include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha =& phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST); } -- cgit v1.2.1 From 88ae40a4b19360645d5e5a614cc378e7cce4afe3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 14 Sep 2011 00:28:52 +0200 Subject: [ticket/10345] Make use of the plural function in some basic places PHPBB3-10345 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 207ac32a3d..4423737b55 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1154,8 +1154,8 @@ if (!sizeof($error) && $preview) 'POLL_QUESTION' => $parse_poll->message, 'L_POLL_LENGTH' => ($post_data['poll_length']) ? sprintf($user->lang['POLL_RUN_TILL'], $user->format_date($poll_end)) : '', - 'L_MAX_VOTES' => ($post_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $post_data['poll_max_options'])) - ); + 'L_MAX_VOTES' => $user->lang('MAX_OPTIONS_SELECT', (int) $post_data['poll_max_options']), + )); $parse_poll->message = implode("\n", $post_data['poll_options']); $parse_poll->format_display($post_data['enable_bbcode'], $post_data['enable_urls'], $post_data['enable_smilies']); @@ -1430,7 +1430,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - 'L_POLL_OPTIONS_EXPLAIN' => sprintf($user->lang['POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN'], $config['max_poll_options']), + 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', -- cgit v1.2.1 From 179662e949967090724c5e14ea4d4d399886a38a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 Sep 2011 01:33:33 +0200 Subject: [ticket/10345] Use the plural function in some more places. I added two function avatar_explanation_string() and avatar_error_wrong_size() for easier handling of the "pixels"-languages, as they are used quite often. PHPBB3-10345 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 4423737b55..eef186c377 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -322,7 +322,7 @@ if ($mode == 'bump') $meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time); meta_refresh(3, $meta_url); - $message = $user->lang['TOPIC_BUMPED'] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); + $message = $user->lang['TOPIC_BUMPED'] . '

' . $user->lang('VIEW_MESSAGE', '', ''); $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); trigger_error($message); @@ -841,7 +841,7 @@ if ($submit || $preview || $refresh) if (($result = validate_string($post_data['username'], false, $config['min_name_chars'], $config['max_name_chars'])) !== false) { $min_max_amount = ($result == 'TOO_SHORT') ? $config['min_name_chars'] : $config['max_name_chars']; - $error[] = sprintf($user->lang['FIELD_' . $result], $user->lang['USERNAME'], $min_max_amount); + $error[] = $user->lang('FIELD_' . $result, $min_max_amount, $user->lang['USERNAME']); } } @@ -1357,7 +1357,7 @@ add_form_key('posting'); $template->assign_vars(array( 'L_POST_A' => $page_title, 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], - 'L_MESSAGE_BODY_EXPLAIN' => (intval($config['max_post_chars'])) ? sprintf($user->lang['MESSAGE_BODY_EXPLAIN'], intval($config['max_post_chars'])) : '', + 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), 'FORUM_NAME' => $post_data['forum_name'], 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', -- cgit v1.2.1 From 7a04c9048c110f0bd21ea3e9e869e17b408d640e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 31 Dec 2011 13:32:52 +0000 Subject: [ticket/9916] Updating header license and removing Version $Id$ PHPBB3-9916 --- phpBB/posting.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 0ed540679a..56fb7832f2 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -2,9 +2,8 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From a7045e65724481002e232a7d143b7cc2ed6acb3a Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 30 Mar 2012 21:43:00 -0400 Subject: [feature/qrpreview] Preview from Quick Reply PHPBB3-10726 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 56fb7832f2..71ba353e89 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -38,7 +38,7 @@ $load = (isset($_POST['load'])) ? true : false; $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); -- cgit v1.2.1 From 5ccd6915e3e8af30856319d84a48dde074fdbaee Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 31 Mar 2012 15:52:16 -0400 Subject: [feature/qrpreview] Do not error or show preview if no text is entered PHPBB3-10726 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 71ba353e89..7f57f693af 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -38,7 +38,7 @@ $load = (isset($_POST['load'])) ? true : false; $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview) ? true : false; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); @@ -1198,8 +1198,8 @@ if (!sizeof($error) && $preview) 'PREVIEW_MESSAGE' => $preview_message, 'PREVIEW_SIGNATURE' => $preview_signature, - 'S_DISPLAY_PREVIEW' => true) - ); + 'S_DISPLAY_PREVIEW' => !empty($preview_message), + )); } } -- cgit v1.2.1 From d908d932736775b0274564dbc6206babf64ba1be Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 12 Jul 2012 16:02:58 -0400 Subject: [ticket/10444] Do not default to the previous post edit reason. PHPBB3-10444 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 7f57f693af..558520dbaa 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1376,7 +1376,7 @@ $template->assign_vars(array( 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], - 'EDIT_REASON' => $post_data['post_edit_reason'], + 'EDIT_REASON' => $request->variable('edit_reason', ''), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), -- cgit v1.2.1 From 67665f59577092badf7eb0b5585e5ae39c52c8da Mon Sep 17 00:00:00 2001 From: Nathan Date: Sat, 14 Jul 2012 18:12:57 -0500 Subject: [ticket/10990] Use $user->lang['COMMA_SEPARATOR'] when appropriate PHPBB3-10990 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 7f57f693af..a17578e343 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1362,7 +1362,7 @@ $template->assign_vars(array( 'FORUM_NAME' => $post_data['forum_name'], 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', 'TOPIC_TITLE' => censor_text($post_data['topic_title']), - 'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '', + 'MODERATORS' => (sizeof($moderators)) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '', 'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '', 'SUBJECT' => $post_data['post_subject'], 'MESSAGE' => $post_data['post_text'], -- cgit v1.2.1 From 6613884a60cdf399cd8a3a908bc44247c646bb1b Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 20 Aug 2012 11:37:27 -0400 Subject: [feature/add_events] Added core.posting_refresh event PHPBB3-9550 --- phpBB/posting.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index a17578e343..77b3c8c861 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -39,6 +39,19 @@ $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview) ? true : false; + +/** +* This event allows you to alter the $refresh boolean variable. +* +* If $refresh is true the posting form retains previously submitted form data +* +* @event core.posting_refresh +* @var bool refresh Whether or not to retain previously submitted data +* @since 3.1-A1 +*/ +$vars = array('refresh'); +extract($phpbb_dispatcher->trigger_event('core.posting_refresh', compact($vars))); + $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); -- cgit v1.2.1 From a02bfcc83a3c9a107bc2b840d07409a93628bbdc Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Aug 2012 11:50:38 -0400 Subject: [feature/add_events] core.posting_refresh -> core.modify_posting_paramters The event now lets extensions modify the posting paramters, not just refresh PHPBB3-9550 --- phpBB/posting.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 77b3c8c861..33f0bae353 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -39,23 +39,36 @@ $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview) ? true : false; +$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); + +$error = $post_data = array(); +$current_time = time(); /** -* This event allows you to alter the $refresh boolean variable. +* This event allows you to alter the above parameters, such as submit and mode * -* If $refresh is true the posting form retains previously submitted form data +* Note: $refresh must be true to retain previously submitted form data. * -* @event core.posting_refresh +* @event core.modify_posting_parameters +* @var bool submit Whether or not the form has been submitted +* @var bool preview Whether or not the post is being previewed +* @var bool save Whether or not a draft is being saved +* @var bool load Whether or not a draft is being loaded +* @var bool delete Whether or not the post is being deleted +* @var bool cancel Whether or not to cancel the form (returns to +* viewtopic or viewforum depending on if the user +* is posting a new topic or editing a post) * @var bool refresh Whether or not to retain previously submitted data +* @var string mode What action to take if the form has been sumitted +* post|reply|quote|edit|delete|bump|smilies|popup +* @var array error Any error strings; a non-empty array aborts +* form submission. +* NOTE: Should be actual language strings, NOT +* language keys. * @since 3.1-A1 */ -$vars = array('refresh'); -extract($phpbb_dispatcher->trigger_event('core.posting_refresh', compact($vars))); - -$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); - -$error = $post_data = array(); -$current_time = time(); +$vars = array('submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error'); +extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); // Was cancel pressed? If so then redirect to the appropriate page if ($cancel || ($current_time - $lastclick < 2 && $submit)) -- cgit v1.2.1 From 7ee3eb16ac1a4f11003c72b77352ad7fda53050d Mon Sep 17 00:00:00 2001 From: David King Date: Thu, 23 Aug 2012 12:49:09 -0400 Subject: [feature/add_events] Add more parameters to core.modify_posting_parameters PHPBB3-9550 --- phpBB/posting.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 33f0bae353..f37d6128de 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -50,6 +50,11 @@ $current_time = time(); * Note: $refresh must be true to retain previously submitted form data. * * @event core.modify_posting_parameters +* @var int post_id ID of the post +* @var int topic_id ID of the topic +* @var int forum_id ID of the forum +* @var int draft_id ID of the draft +* @var int lastclick Timestamp of when the form was last loaded * @var bool submit Whether or not the form has been submitted * @var bool preview Whether or not the post is being previewed * @var bool save Whether or not a draft is being saved @@ -67,7 +72,7 @@ $current_time = time(); * language keys. * @since 3.1-A1 */ -$vars = array('submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error'); +$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error'); extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); // Was cancel pressed? If so then redirect to the appropriate page -- cgit v1.2.1 From ca62b1ffb0c1f37877fbb59beef7cd38c012b827 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 25 Aug 2012 21:41:04 -0400 Subject: [feature/add_events] Added note in modify_posting_parameters The template assignment methods do not work until $user->setup() has been run. This event is called before it, so extensions requiring template methods must put such calls in a later event. PHPBB3-9550 --- phpBB/posting.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f37d6128de..ff959bb4b7 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -49,6 +49,10 @@ $current_time = time(); * * Note: $refresh must be true to retain previously submitted form data. * +* Note: The template class will not work properly until $user->setup() is +* called, and it has not been called yet. Extensions requiring template +* assignments should use an event that comes later in this file. +* * @event core.modify_posting_parameters * @var int post_id ID of the post * @var int topic_id ID of the topic -- cgit v1.2.1 From 02644c02b9d6bed5e4a8e20323bdafb2ca9749b4 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 26 Aug 2012 15:09:50 -0400 Subject: [feature/add_events] Added core.posting_modify_template_vars Can be used to set template variables and such, as the template assignment methods are not available to the modify_posting_paramters event. PHPBB3-9550 --- phpBB/posting.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index ff959bb4b7..81ef31f96c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1452,6 +1452,14 @@ $template->assign_vars(array( 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); +/** +* This event allows you to modify template variables for the posting screen +* +* @event core.posting_modify_template_vars +* @since 3.1-A1 +*/ +$phpbb_dispatcher->trigger_event('core.posting_modify_template_vars'); + // Build custom bbcodes array display_custom_bbcodes(); -- cgit v1.2.1 From b8c55291ed7ed86565be2bc651bf20eb1a9ed4dd Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Thu, 17 Jun 2010 23:58:18 -0500 Subject: [feature/soft-delete] Lay the groundwork for a soft-delete feature So far, I've added no new functionality. The biggest change here is adjusting the DB column names to "visibility" rather than "approved". Some things here are pretty likely to change, for example the name and location of the topic_visibility class. Happy birthday phpBB :) PHPBB3-9657 --- phpBB/posting.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index a17578e343..273499c1e4 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -86,8 +86,8 @@ switch ($mode) $sql = 'SELECT f.*, t.* FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id - AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND t.topic_approved = 1'); + AND f.forum_id = t.forum_id + AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'quote': @@ -114,8 +114,8 @@ switch ($mode) WHERE p.post_id = $post_id AND t.topic_id = p.topic_id AND u.user_id = p.poster_id - AND f.forum_id = t.forum_id" . - (($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1'); + AND f.forum_id = t.forum_id + AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'smilies': @@ -163,7 +163,7 @@ if (!$post_data) // Not able to reply to unapproved posts/topics // TODO: add more descriptive language key -if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && !$post_data['topic_approved']) || ($mode == 'quote' && !$post_data['post_approved']))) +if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] == ITEM_UNAPPROVED) || ($mode == 'quote' && $post_data['post_visibility'] == ITEM_UNAPPROVED))) { trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); } @@ -1063,8 +1063,8 @@ if ($submit || $preview || $refresh) 'attachment_data' => $message_parser->attachment_data, 'filename_data' => $message_parser->filename_data, - 'topic_approved' => (isset($post_data['topic_approved'])) ? $post_data['topic_approved'] : false, - 'post_approved' => (isset($post_data['post_approved'])) ? $post_data['post_approved'] : false, + 'topic_visibility' => (isset($post_data['topic_visibility'])) ? $post_data['topic_visibility'] : false, + 'post_visibility' => (isset($post_data['post_visibility'])) ? $post_data['post_visibility'] : false, ); if ($mode == 'edit') @@ -1514,9 +1514,9 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], 'topic_replies_real' => $post_data['topic_replies_real'], - 'topic_approved' => $post_data['topic_approved'], + 'topic_visibility' => $post_data['topic_visibility'], 'topic_type' => $post_data['topic_type'], - 'post_approved' => $post_data['post_approved'], + 'post_visibility' => $post_data['post_visibility'], 'post_reported' => $post_data['post_reported'], 'post_time' => $post_data['post_time'], 'poster_id' => $post_data['poster_id'], -- cgit v1.2.1 From c32d76080605f843bb23e9a608c368d4b5dc55d8 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 20 Jun 2010 15:01:26 -0500 Subject: [feature/soft-delete] I told you I was going to rename the class! Rename topic_visibility class to phpbb_visibility. Also a bit of work to the class itself, mostly cleanup and adding the comments that I'd previously written. PHPBB3-9657 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 273499c1e4..30b897c068 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -87,7 +87,7 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id - AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'quote': @@ -115,7 +115,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id - AND " . topic_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'smilies': -- cgit v1.2.1 From fb13ab83e476d2afbc7bb181f7ab90df98f996da Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sun, 27 Jun 2010 14:22:36 -0500 Subject: [feature/soft-delete] Implement the ability to soft-delete and restore posts The soft delete feature seems to work. Tests are pending. A real icon is pending. Add the permissions and the interface to soft-delete posts. Also able to restore posts via the MCP queue PHPBB3-9657 --- phpBB/posting.php | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 30b897c068..221d469b4a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -38,8 +38,20 @@ $load = (isset($_POST['load'])) ? true : false; $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview) ? true : false; -$mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview); +$mode = request_var('mode', ''); + +if ($submit && !$refresh) +{ + if (isset($_POST['soft_delete'])) + { + $mode = 'soft_delete'; + } + else if (isset($_POST['delete'])) + { + $mode = 'delete'; + } +} $error = $post_data = array(); $current_time = time(); @@ -93,6 +105,7 @@ switch ($mode) case 'quote': case 'edit': case 'delete': + case 'soft_delete': if (!$post_id) { $user->setup('posting'); @@ -168,6 +181,13 @@ if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'b trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); } +if ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) +{ + // don't feel that a confirm_box is needed for this + // do not return / trigger_error after this because the post content can also be changed + phpbb_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id)); +} + if ($mode == 'popup') { upload_popup($post_data['forum_style']); @@ -259,6 +279,13 @@ switch ($mode) $is_authed = true; } break; + + case 'soft_delete': + if ($user->data['is_registered'] && $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) + { + $is_authed = true; + } + break; } if (!$is_authed) @@ -306,9 +333,9 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) } // Handle delete mode... -if ($mode == 'delete') +if ($mode == 'delete' || $mode == 'soft_delete') { - handle_post_delete($forum_id, $topic_id, $post_id, $post_data); + handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete')); return; } @@ -1401,6 +1428,10 @@ $template->assign_vars(array( 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', + 'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', + 'S_SOFT_DELETE_ALLOWED' => (phpbb_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_RESTORE_ALLOWED' => (phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_IS_DELETED' => ($post_data['post_visibility'] == POST_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, @@ -1494,19 +1525,21 @@ function upload_popup($forum_style = 0) /** * Do the various checks required for removing posts as well as removing it */ -function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) +function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft) { global $user, $db, $auth, $config; global $phpbb_root_path, $phpEx; + $perm_check = ($is_soft) ? 'softdelete' : 'delete'; + // If moderator removing post or user itself removing post, present a confirmation screen - if ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) + if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) { $s_hidden_fields = build_hidden_fields(array( 'p' => $post_id, 'f' => $forum_id, - 'mode' => 'delete') - ); + 'mode' => ($is_soft) ? 'soft_delete' : 'delete', + )); if (confirm_box(true)) { @@ -1523,7 +1556,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data) 'post_postcount' => $post_data['post_postcount'] ); - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data); + $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft); $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; if ($next_post_id === false) -- cgit v1.2.1 From a80cfafdd91a384ba810a8ee0d43406bba955faa Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Wed, 30 Jun 2010 13:38:49 -0500 Subject: [feature/soft-delete] Rename phpbb_visibility class to phpbb_content_visibility Rename the class to more accurately reflect what it does. PHPBB3-9657 --- phpBB/posting.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 221d469b4a..877ebc6404 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -99,7 +99,7 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id - AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'quote': @@ -128,7 +128,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id - AND " . phpbb_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.'); break; case 'smilies': @@ -181,13 +181,6 @@ if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'b trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); } -if ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) -{ - // don't feel that a confirm_box is needed for this - // do not return / trigger_error after this because the post content can also be changed - phpbb_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id)); -} - if ($mode == 'popup') { upload_popup($post_data['forum_style']); @@ -891,6 +884,13 @@ if ($submit || $preview || $refresh) $error[] = $user->lang['FORM_INVALID']; } + if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) + { + // don't feel that a confirm_box is needed for this + // do not return / trigger_error after this because the post content can also be changed + phpbb_content_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id)); + } + // Parse subject if (!$preview && !$refresh && utf8_clean_string($post_data['post_subject']) === '' && ($mode == 'post' || ($mode == 'edit' && $post_data['topic_first_post_id'] == $post_id))) { @@ -1429,8 +1429,8 @@ $template->assign_vars(array( 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', - 'S_SOFT_DELETE_ALLOWED' => (phpbb_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, - 'S_RESTORE_ALLOWED' => (phpbb_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_SOFT_DELETE_ALLOWED' => (phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_RESTORE_ALLOWED' => (phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, 'S_IS_DELETED' => ($post_data['post_visibility'] == POST_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', -- cgit v1.2.1 From 1ab41f8dc6ec81f2aaf152229d5f0275de796c85 Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Sat, 17 Jul 2010 14:34:36 -0500 Subject: [feature/soft-delete] Fix some small bugs To wit: using non-existing constant POST_DELETED in posting.php; first test post was initially unapproved; soft delete checkbox appeared at post time Links pointing to the wrong place. PHPBB3-9657 --- phpBB/posting.php | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 877ebc6404..095fc06a3f 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -886,9 +886,52 @@ if ($submit || $preview || $refresh) if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) { + // if this is the first post of the topic, restore the whole topic + if ($post_id == $post_data['topic_first_post_id']) + { + // that means we need to gather data for all posts in the topic, not + // just the one being edited + $sql = 'SELECT post_id, poster_id, post_subject, post_postcount + FROM ' . POSTS_TABLE . ' + WHERE topic_id = ' . $post_data['topic_id'] . ' + AND post_visibility = ' . ITEM_DELETED; + $result = $db->sql_query($sql); + + $post_ids = array(); + + while ($row = $db->sql_fetchrow($result)) + { + $post_ids[] = $row['post_id']; + + $posts_data[$row['post_id']] = array( + // all posts are from the same topic and forum + // and are deleted because of the constraints to the query above + 'topic_id' => $post_data['topic_id'], + 'forum_id' => $post_data['forum_id'], + 'topic_replies' => $post_data['topic_replies'], + 'topic_first_post_id' => $post_data['topic_first_post_id'], + 'post_visibility' => ITEM_DELETED, + + 'poster_id' => $row['poster_id'], + 'post_subject' => $row['post_subject'], + 'post_postcount'=> $row['post_postcount'], + ); + } + + // No direct query is needed, just update the array + $post_data['post_visibility'] = $post_data['topic_visibility'] = ITEM_APPROVED; + } + else + { + $post_ids = array($post_id); + $posts_data = array($post_id => $post_data); + + $post_data['post_visibility'] = ITEM_APPROVED; + } + // don't feel that a confirm_box is needed for this // do not return / trigger_error after this because the post content can also be changed - phpbb_content_visibility::unhide_posts_topics('restore', array($post_id => $post_data), array($post_id)); + phpbb_content_visibility::unhide_posts_topics('restore', $posts_data, $post_ids); } // Parse subject @@ -1429,9 +1472,9 @@ $template->assign_vars(array( 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', - 'S_SOFT_DELETE_ALLOWED' => (phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_SOFT_DELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, 'S_RESTORE_ALLOWED' => (phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, - 'S_IS_DELETED' => ($post_data['post_visibility'] == POST_DELETED) ? true : false, + 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, @@ -1547,6 +1590,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], 'topic_replies_real' => $post_data['topic_replies_real'], + 'topic_replies' => $post_data['topic_replies'], 'topic_visibility' => $post_data['topic_visibility'], 'topic_type' => $post_data['topic_type'], 'post_visibility' => $post_data['post_visibility'], -- cgit v1.2.1 From 05f236675528b5af68ba5f0ff140eb8c51ab92b1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 5 Oct 2012 14:42:11 +0200 Subject: [feature/soft-delete] Update docs of can_soft_delete and remove can_restore PHPBB3-9567 --- phpBB/posting.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 095fc06a3f..c09ddb91ff 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -884,8 +884,9 @@ if ($submit || $preview || $refresh) $error[] = $user->lang['FORM_INVALID']; } - if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) + if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && $auth->acl_get('m_approve', $forum_id)) { + //@todo: REMOVE the magic! // if this is the first post of the topic, restore the whole topic if ($post_id == $post_data['topic_first_post_id']) { @@ -1471,10 +1472,10 @@ $template->assign_vars(array( 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', - 'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', - 'S_SOFT_DELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, - 'S_RESTORE_ALLOWED' => (phpbb_content_visibility::can_restore($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, - 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, + 'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', + 'S_SOFT_DELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), + 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, 'S_MAGIC_URL_CHECKED' => ($urls_checked) ? ' checked="checked"' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, -- cgit v1.2.1 From e447a0fa0797440688335bc0dc18c8a73b5586ec Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 8 Oct 2012 23:09:12 +0200 Subject: [feature/soft-delete] Fix restoring a post via editing PHPBB3-9567 --- phpBB/posting.php | 58 ++++++++++--------------------------------------------- 1 file changed, 10 insertions(+), 48 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index c09ddb91ff..f4a6df3200 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -274,7 +274,7 @@ switch ($mode) break; case 'soft_delete': - if ($user->data['is_registered'] && $auth->acl_gets('f_softdelete', 'm_softdelete', $forum_id)) + if ($user->data['is_registered'] && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) { $is_authed = true; } @@ -886,53 +886,15 @@ if ($submit || $preview || $refresh) if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && $auth->acl_get('m_approve', $forum_id)) { - //@todo: REMOVE the magic! - // if this is the first post of the topic, restore the whole topic - if ($post_id == $post_data['topic_first_post_id']) - { - // that means we need to gather data for all posts in the topic, not - // just the one being edited - $sql = 'SELECT post_id, poster_id, post_subject, post_postcount - FROM ' . POSTS_TABLE . ' - WHERE topic_id = ' . $post_data['topic_id'] . ' - AND post_visibility = ' . ITEM_DELETED; - $result = $db->sql_query($sql); - - $post_ids = array(); - - while ($row = $db->sql_fetchrow($result)) - { - $post_ids[] = $row['post_id']; - - $posts_data[$row['post_id']] = array( - // all posts are from the same topic and forum - // and are deleted because of the constraints to the query above - 'topic_id' => $post_data['topic_id'], - 'forum_id' => $post_data['forum_id'], - 'topic_replies' => $post_data['topic_replies'], - 'topic_first_post_id' => $post_data['topic_first_post_id'], - 'post_visibility' => ITEM_DELETED, - - 'poster_id' => $row['poster_id'], - 'post_subject' => $row['post_subject'], - 'post_postcount'=> $row['post_postcount'], - ); - } + $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_replies']); + $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_replies']); + $updated_post_data = phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); - // No direct query is needed, just update the array - $post_data['post_visibility'] = $post_data['topic_visibility'] = ITEM_APPROVED; - } - else + if (!empty($updated_post_data)) { - $post_ids = array($post_id); - $posts_data = array($post_id => $post_data); - - $post_data['post_visibility'] = ITEM_APPROVED; + // Update the post_data, so we don't need to refetch it. + $post_data = array_merge($post_data, $updated_post_data); } - - // don't feel that a confirm_box is needed for this - // do not return / trigger_error after this because the post content can also be changed - phpbb_content_visibility::unhide_posts_topics('restore', $posts_data, $post_ids); } // Parse subject @@ -1591,17 +1553,17 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], 'topic_replies_real' => $post_data['topic_replies_real'], - 'topic_replies' => $post_data['topic_replies'], + 'topic_replies' => $post_data['topic_replies'], 'topic_visibility' => $post_data['topic_visibility'], 'topic_type' => $post_data['topic_type'], 'post_visibility' => $post_data['post_visibility'], 'post_reported' => $post_data['post_reported'], 'post_time' => $post_data['post_time'], 'poster_id' => $post_data['poster_id'], - 'post_postcount' => $post_data['post_postcount'] + 'post_postcount' => $post_data['post_postcount'], ); - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft); + $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft);//@todo: $reason); $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; if ($next_post_id === false) -- cgit v1.2.1 From 70fa983fa804c2a826a51af1c31ffc663cde48b3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 9 Oct 2012 17:38:08 +0200 Subject: [feature/soft-delete] Do not allow users to reply to soft deleted topics We should discuss this in an RFC again, but for now, we just fix the old state. So moderators can only reply, when the topic is approved. Also fixes a bug in the visibility check. We need to check the posts visibility rather then the visibility of the topic. Because when the post is visible, the topic is as well, but not the other way round. PHPBB3-9567 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f4a6df3200..9f0b0d2eb9 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -128,7 +128,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id - AND " . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); break; case 'smilies': @@ -176,7 +176,7 @@ if (!$post_data) // Not able to reply to unapproved posts/topics // TODO: add more descriptive language key -if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] == ITEM_UNAPPROVED) || ($mode == 'quote' && $post_data['post_visibility'] == ITEM_UNAPPROVED))) +if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'bump') && $post_data['topic_visibility'] != ITEM_APPROVED) || ($mode == 'quote' && $post_data['post_visibility'] != ITEM_APPROVED))) { trigger_error(($mode == 'reply' || $mode == 'bump') ? 'TOPIC_UNAPPROVED' : 'POST_UNAPPROVED'); } -- cgit v1.2.1 From 5925a17894cecb9fdf2d5c58dcdeb533fb80e8f7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Oct 2012 14:55:10 +0200 Subject: [feature/soft-delete] Fix some more uses of topic_replies_real PHPBB3-9567 --- phpBB/posting.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 9f0b0d2eb9..c7e96dd6c0 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -886,8 +886,8 @@ if ($submit || $preview || $refresh) if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && $auth->acl_get('m_approve', $forum_id)) { - $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_replies']); - $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_replies']); + $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_posts']); + $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_posts']); $updated_post_data = phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); if (!empty($updated_post_data)) @@ -1102,8 +1102,9 @@ if ($submit || $preview || $refresh) if ($mode == 'edit') { - $data['topic_replies_real'] = $post_data['topic_replies_real']; - $data['topic_replies'] = $post_data['topic_replies']; + $data['topic_posts'] = $post_data['topic_posts']; + $data['topic_posts_unapproved'] = $post_data['topic_posts_unapproved']; + $data['topic_posts_softdeleted'] = $post_data['topic_posts_softdeleted']; } // The last parameter tells submit_post if search indexer has to be run @@ -1552,8 +1553,9 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $data = array( 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], - 'topic_replies_real' => $post_data['topic_replies_real'], - 'topic_replies' => $post_data['topic_replies'], + 'topic_posts' => $post_data['topic_posts']; + 'topic_posts_unapproved' => $post_data['topic_posts_unapproved']; + 'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted']; 'topic_visibility' => $post_data['topic_visibility'], 'topic_type' => $post_data['topic_type'], 'post_visibility' => $post_data['post_visibility'], -- cgit v1.2.1 From f21fd469bca3e5c3504a773a96d1a8fab6c374a7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 24 Oct 2012 19:52:16 +0200 Subject: [feature/soft-delete] Handle soft deleting via Delete Icon PHPBB3-9567 --- phpBB/posting.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index c7e96dd6c0..f82ae049dc 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -41,16 +41,10 @@ $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview); $mode = request_var('mode', ''); -if ($submit && !$refresh) +// If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here. +if ($mode == 'delete' && (($auth->acl_get('m_softdelete', $forum_id) && $request->is_set_post('soft_delete')) || !$auth->acl_get('m_delete', $forum_id))) { - if (isset($_POST['soft_delete'])) - { - $mode = 'soft_delete'; - } - else if (isset($_POST['delete'])) - { - $mode = 'delete'; - } + $mode = 'soft_delete'; } $error = $post_data = array(); @@ -328,7 +322,8 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) // Handle delete mode... if ($mode == 'delete' || $mode == 'soft_delete') { - handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete')); + $soft_delete_reason = ($mode == 'soft_delete' && $auth->acl_get('m_softdelete', $forum_id)) ? utf8_normalize_nfc(request_var('delete_reason', '', true)) : ''; + handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason); return; } @@ -1532,7 +1527,7 @@ function upload_popup($forum_style = 0) /** * Do the various checks required for removing posts as well as removing it */ -function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft) +function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $soft_delete_reason = '') { global $user, $db, $auth, $config; global $phpbb_root_path, $phpEx; @@ -1553,9 +1548,9 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $data = array( 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], - 'topic_posts' => $post_data['topic_posts']; - 'topic_posts_unapproved' => $post_data['topic_posts_unapproved']; - 'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted']; + 'topic_posts' => $post_data['topic_posts'], + 'topic_posts_unapproved' => $post_data['topic_posts_unapproved'], + 'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'], 'topic_visibility' => $post_data['topic_visibility'], 'topic_type' => $post_data['topic_type'], 'post_visibility' => $post_data['post_visibility'], @@ -1565,7 +1560,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof 'post_postcount' => $post_data['post_postcount'], ); - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft);//@todo: $reason); + $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $soft_delete_reason); $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; if ($next_post_id === false) @@ -1589,7 +1584,15 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof } else { - confirm_box(false, 'DELETE_POST', $s_hidden_fields); + global $template; + + $template->assign_vars(array( + 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id) || $auth->acl_get('f_delete', $forum_id), + 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id) || $auth->acl_get('f_softdelete', $forum_id), + 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), + )); + + confirm_box(false, 'DELETE_POST', $s_hidden_fields, 'posting_delete_post_body.html'); } } -- cgit v1.2.1 From 4a8d38aab13099fdb4fb7e2a7b72cff1c05fda9c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 27 Oct 2012 17:12:34 +0200 Subject: [feature/soft-delete] Allow soft deleting/restoring topics via quickmoderation PHPBB3-9567 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f82ae049dc..d1c48b38b0 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1565,14 +1565,14 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof if ($next_post_id === false) { - add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_TOPIC', $post_data['topic_title'], $post_username); + add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username); $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); $message = $user->lang['POST_DELETED']; } else { - add_log('mod', $forum_id, $topic_id, 'LOG_DELETE_POST', $post_data['post_subject'], $post_username); + add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username); $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); -- cgit v1.2.1 From 8d05dad63471ffbc58feecd1f44cfa5703f0d5f1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 31 Oct 2012 17:29:55 +0100 Subject: [feature/soft-delete] Display message when the posts are already soft deleted PHPBB3-9567 --- phpBB/posting.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index d1c48b38b0..e0ab56f7b7 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1587,6 +1587,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof global $template; $template->assign_vars(array( + 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id) || $auth->acl_get('f_delete', $forum_id), 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id) || $auth->acl_get('f_softdelete', $forum_id), 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), -- cgit v1.2.1 From bed82bf2bd13ca04cc1572d454eee5ef3a9053a6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 1 Nov 2012 22:23:35 +0100 Subject: [feature/soft-delete] Invert the logic on confirm box Permanent delete is now the checkbox rather then softdelete. PHPBB3-9567 --- phpBB/posting.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index e0ab56f7b7..b0157376cf 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1593,7 +1593,9 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), )); - confirm_box(false, 'DELETE_POST', $s_hidden_fields, 'posting_delete_post_body.html'); + $l_confirm = 'DELETE_POST' . (($post_data['post_visibility'] == ITEM_DELETED) ? '_PERMANENTLY' : ''); + + confirm_box(false, $l_confirm, $s_hidden_fields, 'confirm_delete_body.html'); } } -- cgit v1.2.1 From 63e3baf0eb37d1d8f6f0b5b46df56a673eafa6fe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 2 Nov 2012 12:40:10 +0100 Subject: [feature/soft-delete] Correctly manage softdeleting via posting.php PHPBB3-9567 --- phpBB/posting.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index b0157376cf..96907ee790 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -35,14 +35,14 @@ $submit = (isset($_POST['post'])) ? true : false; $preview = (isset($_POST['preview'])) ? true : false; $save = (isset($_POST['save'])) ? true : false; $load = (isset($_POST['load'])) ? true : false; -$delete = (isset($_POST['delete'])) ? true : false; +$confirm = (isset($_POST['confirm'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview); $mode = request_var('mode', ''); // If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here. -if ($mode == 'delete' && (($auth->acl_get('m_softdelete', $forum_id) && $request->is_set_post('soft_delete')) || !$auth->acl_get('m_delete', $forum_id))) +if ($mode == 'delete' && (($confirm && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id))) { $mode = 'soft_delete'; } @@ -1537,11 +1537,11 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof // If moderator removing post or user itself removing post, present a confirmation screen if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) { - $s_hidden_fields = build_hidden_fields(array( + $s_hidden_fields = array( 'p' => $post_id, 'f' => $forum_id, 'mode' => ($is_soft) ? 'soft_delete' : 'delete', - )); + ); if (confirm_box(true)) { @@ -1593,9 +1593,18 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), )); - $l_confirm = 'DELETE_POST' . (($post_data['post_visibility'] == ITEM_DELETED) ? '_PERMANENTLY' : ''); + $l_confirm = 'DELETE_POST'; + if ($post_data['post_visibility'] == ITEM_DELETED) + { + $l_confirm .= '_PERMANENTLY'; + $s_hidden_fields['delete_permanent'] = '1'; + } + else if (!$auth->acl_get('m_softdelete', $forum_id) && !$auth->acl_get('f_softdelete', $forum_id)) + { + $s_hidden_fields['delete_permanent'] = '1'; + } - confirm_box(false, $l_confirm, $s_hidden_fields, 'confirm_delete_body.html'); + confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); } } -- cgit v1.2.1 From dfcfccf537658b83401b78afc851239f4842a4e5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 3 Nov 2012 22:53:54 +0100 Subject: [feature/soft-delete] Fix deleting via post editing PHPBB3-9567 --- phpBB/posting.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 96907ee790..4c92d85a20 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -322,6 +322,12 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) // Handle delete mode... if ($mode == 'delete' || $mode == 'soft_delete') { + if ($mode == 'soft_delete' && $post_data['post_visibility'] == ITEM_DELETED) + { + $user->setup('posting'); + trigger_error('NO_POST'); + } + $soft_delete_reason = ($mode == 'soft_delete' && $auth->acl_get('m_softdelete', $forum_id)) ? utf8_normalize_nfc(request_var('delete_reason', '', true)) : ''; handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason); return; @@ -1110,6 +1116,14 @@ if ($submit || $preview || $refresh) $captcha->reset(); } + // Handle delete mode... + if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent')) + { + $soft_delete_reason = (!$request->is_set_post('delete_permanent') && $auth->acl_get('m_softdelete', $forum_id)) ? utf8_normalize_nfc(request_var('delete_reason', '', true)) : ''; + handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $soft_delete_reason); + return; + } + // Check the permissions for post approval. Moderators are not affected. if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state'])) { @@ -1430,8 +1444,9 @@ $template->assign_vars(array( 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', - 'S_SOFT_DELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', - 'S_SOFT_DELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', + 'S_DELETE_REASON' => ($mode == 'edit' && $auth->acl_get('m_softdelete', $forum_id)) ? true : false, + 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, @@ -1584,10 +1599,11 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof } else { - global $template; + global $template, $request; $template->assign_vars(array( 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, + 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id) || $auth->acl_get('f_delete', $forum_id), 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id) || $auth->acl_get('f_softdelete', $forum_id), 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), -- cgit v1.2.1 From 885e19e58a54dc5f06161dd56d7e1a2df34df95d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 4 Nov 2012 01:17:22 +0100 Subject: [feature/soft-delete] Provide the options for permanent delete via AJAX AJAX confirm_box should be able to call the template file given. The confirm message is HTML so far, but generating the HTML in the php code is not, what we want. PHPBB3-9567 --- phpBB/posting.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 4c92d85a20..16dfad3b91 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1604,8 +1604,8 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $template->assign_vars(array( 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', - 'S_ALLOWED_DELETE' => $auth->acl_get('m_delete', $forum_id) || $auth->acl_get('f_delete', $forum_id), - 'S_ALLOWED_SOFTDELETE' => $auth->acl_get('m_softdelete', $forum_id) || $auth->acl_get('f_softdelete', $forum_id), + 'S_ALLOWED_DELETE' => $auth->acl_gets('m_delete', 'f_delete', $forum_id), + 'S_ALLOWED_SOFTDELETE' => $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id), 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), )); @@ -1620,7 +1620,24 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $s_hidden_fields['delete_permanent'] = '1'; } - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); + // @todo: This needs fixing! AJAX confirm_box should be able to call template files! + if ($request->is_ajax()) + { + $l_confirm = (!isset($user->lang[$l_confirm . '_CONFIRM'])) ? $l_confirm : $user->lang[$l_confirm . '_CONFIRM']; + if ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)) + { + $l_confirm .= '
' . $user->lang['DELETE_PERMANENTLY'] . ': '; + } + if ($auth->acl_get('m_softdelete', $forum_id)) + { + $l_confirm .= '
' . $user->lang['DELETE_REASON'] . ': '; + } + confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields)); + } + else + { + confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); + } } } -- cgit v1.2.1 From fc110a7332a756891d5f8276d26f88a6e4113350 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 12:09:46 +0100 Subject: [feature/soft-delete] Remove the current work around on ajax confirm problem PHPBB3-9567 --- phpBB/posting.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 16dfad3b91..62c55d9ff4 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1599,7 +1599,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof } else { - global $template, $request; + global $user, $template, $request; $template->assign_vars(array( 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, @@ -1621,23 +1621,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof } // @todo: This needs fixing! AJAX confirm_box should be able to call template files! - if ($request->is_ajax()) - { - $l_confirm = (!isset($user->lang[$l_confirm . '_CONFIRM'])) ? $l_confirm : $user->lang[$l_confirm . '_CONFIRM']; - if ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)) - { - $l_confirm .= '
' . $user->lang['DELETE_PERMANENTLY'] . ': '; - } - if ($auth->acl_get('m_softdelete', $forum_id)) - { - $l_confirm .= '
' . $user->lang['DELETE_REASON'] . ': '; - } - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields)); - } - else - { - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } + confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); } } -- cgit v1.2.1 From 8512543cf490e06e3b3ca95d0ae9be3ee8fb850d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 12:32:27 +0100 Subject: [feature/soft-delete] Use request object instead of direct access PHPBB3-9567 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 62c55d9ff4..0b22fa54c2 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -35,7 +35,7 @@ $submit = (isset($_POST['post'])) ? true : false; $preview = (isset($_POST['preview'])) ? true : false; $save = (isset($_POST['save'])) ? true : false; $load = (isset($_POST['load'])) ? true : false; -$confirm = (isset($_POST['confirm'])) ? true : false; +$confirm = $request->is_set_post('confirm'); $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview); @@ -328,7 +328,7 @@ if ($mode == 'delete' || $mode == 'soft_delete') trigger_error('NO_POST'); } - $soft_delete_reason = ($mode == 'soft_delete' && $auth->acl_get('m_softdelete', $forum_id)) ? utf8_normalize_nfc(request_var('delete_reason', '', true)) : ''; + $soft_delete_reason = ($mode == 'soft_delete' && $auth->acl_get('m_softdelete', $forum_id)) ? $request->variable('delete_reason', '', true) : ''; handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason); return; } @@ -1119,7 +1119,7 @@ if ($submit || $preview || $refresh) // Handle delete mode... if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent')) { - $soft_delete_reason = (!$request->is_set_post('delete_permanent') && $auth->acl_get('m_softdelete', $forum_id)) ? utf8_normalize_nfc(request_var('delete_reason', '', true)) : ''; + $soft_delete_reason = (!$request->is_set_post('delete_permanent') && $auth->acl_get('m_softdelete', $forum_id)) ? $request->variable('delete_reason', '', true) : ''; handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $soft_delete_reason); return; } -- cgit v1.2.1 From 9c2a58eff4c2bd164ee3bdb2ec66729d4562963d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 13:37:53 +0100 Subject: [feature/soft-delete] Append _approved to *_posts and *_topics column names PHPBB3-9567 --- phpBB/posting.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 0b22fa54c2..52ef424ace 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -887,8 +887,8 @@ if ($submit || $preview || $refresh) if ($submit && $mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED && !isset($_POST['soft_delete']) && $auth->acl_get('m_approve', $forum_id)) { - $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_posts']); - $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_posts']); + $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_posts_approved']); + $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_posts_approved']); $updated_post_data = phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); if (!empty($updated_post_data)) @@ -1103,7 +1103,7 @@ if ($submit || $preview || $refresh) if ($mode == 'edit') { - $data['topic_posts'] = $post_data['topic_posts']; + $data['topic_posts_approved'] = $post_data['topic_posts_approved']; $data['topic_posts_unapproved'] = $post_data['topic_posts_unapproved']; $data['topic_posts_softdeleted'] = $post_data['topic_posts_softdeleted']; } @@ -1563,7 +1563,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $data = array( 'topic_first_post_id' => $post_data['topic_first_post_id'], 'topic_last_post_id' => $post_data['topic_last_post_id'], - 'topic_posts' => $post_data['topic_posts'], + 'topic_posts_approved' => $post_data['topic_posts_approved'], 'topic_posts_unapproved' => $post_data['topic_posts_unapproved'], 'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'], 'topic_visibility' => $post_data['topic_visibility'], -- cgit v1.2.1 From eb5a6cb006a3b65daca604996a154484bb318221 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 10 Mar 2013 22:07:38 +0100 Subject: [ticket/9657] Display reason field, when the user has both delete permissions PHPBB3-9657 --- phpBB/posting.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index dd6c3556fc..40ffc0d98d 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -363,7 +363,8 @@ if ($mode == 'delete' || $mode == 'soft_delete') trigger_error('NO_POST'); } - $soft_delete_reason = ($mode == 'soft_delete' && $auth->acl_get('m_softdelete', $forum_id)) ? $request->variable('delete_reason', '', true) : ''; + $allow_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); + $soft_delete_reason = ($mode == 'soft_delete' && $allow_reason) ? $request->variable('delete_reason', '', true) : ''; handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason); return; } @@ -1154,7 +1155,8 @@ if ($submit || $preview || $refresh) // Handle delete mode... if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent')) { - $soft_delete_reason = (!$request->is_set_post('delete_permanent') && $auth->acl_get('m_softdelete', $forum_id)) ? $request->variable('delete_reason', '', true) : ''; + $allow_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); + $soft_delete_reason = (!$request->is_set_post('delete_permanent') && $allow_reason) ? $request->variable('delete_reason', '', true) : ''; handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $soft_delete_reason); return; } @@ -1645,12 +1647,14 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof { global $user, $template, $request; + $display_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); + $template->assign_vars(array( 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', 'S_ALLOWED_DELETE' => $auth->acl_gets('m_delete', 'f_delete', $forum_id), 'S_ALLOWED_SOFTDELETE' => $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id), - 'S_DELETE_REASON' => $auth->acl_get('m_softdelete', $forum_id), + 'S_DELETE_REASON' => $display_reason, )); $l_confirm = 'DELETE_POST'; -- cgit v1.2.1 From d6d7acef0416287bf70c0582ae874bbca6caf2eb Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 10 Mar 2013 23:48:53 +0100 Subject: [ticket/9657] Remove already fixed todo PHPBB3-9657 --- phpBB/posting.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 40ffc0d98d..51cdc04abb 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1668,7 +1668,6 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $s_hidden_fields['delete_permanent'] = '1'; } - // @todo: This needs fixing! AJAX confirm_box should be able to call template files! confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); } } -- cgit v1.2.1 From 74f4fd724e64eba4092b48cd114b2a1ee9e399b3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 12 Mar 2013 12:39:00 +0100 Subject: [ticket/9657] Correctly determine the users permissions when deleting posts PHPBB3-9657 --- phpBB/posting.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 51cdc04abb..dbc569d844 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -296,7 +296,7 @@ switch ($mode) break; case 'delete': - if ($user->data['is_registered'] && $auth->acl_gets('f_delete', 'm_delete', $forum_id)) + if ($user->data['is_registered'] && ($auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)))) { $is_authed = true; } @@ -307,6 +307,11 @@ switch ($mode) { $is_authed = true; } + else + { + // Display the same error message for softdelete we use for delete + $mode = 'delete'; + } break; } @@ -1647,13 +1652,15 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof { global $user, $template, $request; - $display_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); + $can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id)); + $can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id)); + $display_reason = $auth->acl_get('m_softdelete', $forum_id) || ($can_delete && $can_softdelete); $template->assign_vars(array( 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', - 'S_ALLOWED_DELETE' => $auth->acl_gets('m_delete', 'f_delete', $forum_id), - 'S_ALLOWED_SOFTDELETE' => $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id), + 'S_ALLOWED_DELETE' => $can_delete, + 'S_ALLOWED_SOFTDELETE' => $can_softdelete, 'S_DELETE_REASON' => $display_reason, )); @@ -1663,7 +1670,7 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $l_confirm .= '_PERMANENTLY'; $s_hidden_fields['delete_permanent'] = '1'; } - else if (!$auth->acl_get('m_softdelete', $forum_id) && !$auth->acl_get('f_softdelete', $forum_id)) + else if (!$can_softdelete) { $s_hidden_fields['delete_permanent'] = '1'; } -- cgit v1.2.1 From 9aed758c1397c31b979f4aca51249c73d21bd6f5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 11 Jul 2013 14:24:07 +0200 Subject: [ticket/9657] Use the service instead of the static class PHPBB3-9657 --- phpBB/posting.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index d5bb536753..ac459197b3 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -98,6 +98,8 @@ if (in_array($mode, array('post', 'reply', 'quote', 'edit', 'delete')) && !$foru trigger_error('NO_FORUM'); } +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); + // We need to know some basic information in all cases before we do anything. switch ($mode) { @@ -128,7 +130,7 @@ switch ($mode) FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f WHERE t.topic_id = $topic_id AND f.forum_id = t.forum_id - AND " . phpbb_content_visibility::get_visibility_sql('topic', $forum_id, 't.'); + AND " . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.'); break; case 'quote': @@ -157,7 +159,7 @@ switch ($mode) AND t.topic_id = p.topic_id AND u.user_id = p.poster_id AND f.forum_id = t.forum_id - AND " . phpbb_content_visibility::get_visibility_sql('post', $forum_id, 'p.'); + AND " . $phpbb_content_visibility->get_visibility_sql('post', $forum_id, 'p.'); break; case 'smilies': @@ -304,7 +306,7 @@ switch ($mode) break; case 'soft_delete': - if ($user->data['is_registered'] && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) + if ($user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) { $is_authed = true; } @@ -931,7 +933,7 @@ if ($submit || $preview || $refresh) { $is_first_post = ($post_id == $post_data['topic_first_post_id'] || !$post_data['topic_posts_approved']); $is_last_post = ($post_id == $post_data['topic_last_post_id'] || !$post_data['topic_posts_approved']); - $updated_post_data = phpbb_content_visibility::set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); + $updated_post_data = $phpbb_content_visibility->set_post_visibility(ITEM_APPROVED, $post_id, $post_data['topic_id'], $post_data['forum_id'], $user->data['user_id'], time(), '', $is_first_post, $is_last_post); if (!empty($updated_post_data)) { @@ -1490,7 +1492,7 @@ $template->assign_vars(array( 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', 'S_DELETE_REASON' => ($mode == 'edit' && $auth->acl_get('m_softdelete', $forum_id)) ? true : false, - 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && phpbb_content_visibility::can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, + 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, 'S_LINKS_ALLOWED' => $url_status, -- cgit v1.2.1 From da2752e4004b296ae5acdd08b7c0a758d8f61e9d Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 14 Jul 2013 13:30:52 -0400 Subject: [ticket/11700] Modify all code to use the new interface names PHPBB3-11700 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index ac459197b3..f9d5295320 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -697,7 +697,7 @@ if ($submit || $preview || $refresh) $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); - $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, phpbb_request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; + $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, phpbb_request_request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f9d5295320..942821a233 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -697,7 +697,7 @@ if ($submit || $preview || $refresh) $message_parser->message = utf8_normalize_nfc(request_var('message', '', true)); $post_data['username'] = utf8_normalize_nfc(request_var('username', $post_data['username'], true)); - $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, phpbb_request_request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; + $post_data['post_edit_reason'] = ($request->variable('edit_reason', false, false, \phpbb\request\request_interface::POST) && $mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? utf8_normalize_nfc(request_var('edit_reason', '', true)) : ''; $post_data['orig_topic_type'] = $post_data['topic_type']; $post_data['topic_type'] = request_var('topic_type', (($mode != 'post') ? (int) $post_data['topic_type'] : POST_NORMAL)); -- cgit v1.2.1 From 2050a39da793b9ed219beed868ec86ebade423f6 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 11 Oct 2013 17:40:16 +0200 Subject: [feature/plupload/integration] Integration of Plupload This commit is a highly-refactored and up-to-date version of Fyorl's work which was part of his Google Summer of Code 2012 project "Attachment Improvements". PHPBB3-10929 --- phpBB/posting.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1609382551..396b320eac 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -452,6 +452,8 @@ if ($mode == 'edit') $orig_poll_options_size = sizeof($post_data['poll_options']); $message_parser = new parse_message(); +$plupload = $phpbb_container->get('plupload'); +$message_parser->set_plupload($plupload); if (isset($post_data['post_text'])) { @@ -1551,6 +1553,11 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ // Show attachment box for adding attachments if true $allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); +if ($allowed) +{ + $plupload->configure($cache, $template, $s_action, $forum_id); +} + // Attachment entry posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); -- cgit v1.2.1 From 3c9a8a3788f4dda1ef16430f16d6392a9e6f8dad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Oct 2013 16:32:40 +0200 Subject: [ticket/11924] Fix some minor issues with the php event docs PHPBB3-11924 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 396b320eac..e29b74af65 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1525,7 +1525,7 @@ $template->assign_vars(array( * @event core.posting_modify_template_vars * @since 3.1-A1 */ -$phpbb_dispatcher->trigger_event('core.posting_modify_template_vars'); +$phpbb_dispatcher->dispatch('core.posting_modify_template_vars'); // Build custom bbcodes array display_custom_bbcodes(); -- cgit v1.2.1 From ef1f99183796f8e246f96bca54ca439bf8ea1750 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 30 Oct 2013 13:37:29 +0100 Subject: [task/code-sniffer] Replace spaces with tabs. PHPBB3-11980 --- phpBB/posting.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index e29b74af65..5db36007c2 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -381,7 +381,7 @@ if ($mode == 'delete' || $mode == 'soft_delete') if ($mode == 'bump') { if ($bump_time = bump_topic_allowed($forum_id, $post_data['topic_bumped'], $post_data['topic_last_post_time'], $post_data['topic_poster'], $post_data['topic_last_poster_id']) - && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) + && check_link_hash(request_var('hash', ''), "topic_{$post_data['topic_id']}")) { $meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time); meta_refresh(3, $meta_url); @@ -817,8 +817,13 @@ if ($submit || $preview || $refresh) // We make sure nobody else made exactly the same change // we're about to submit by also checking $message_md5 != $post_data['post_checksum'] - if (($edit_post_message_checksum !== '' && $edit_post_message_checksum != $post_data['post_checksum'] && $message_md5 != $post_data['post_checksum']) - || ($edit_post_subject_checksum !== '' && $edit_post_subject_checksum != $post_data['post_subject_md5'] && md5($post_data['post_subject']) != $post_data['post_subject_md5'])) + if ($edit_post_message_checksum !== '' && + $edit_post_message_checksum != $post_data['post_checksum'] && + $message_md5 != $post_data['post_checksum'] + || + $edit_post_subject_checksum !== '' && + $edit_post_subject_checksum != $post_data['post_subject_md5'] && + md5($post_data['post_subject']) != $post_data['post_subject_md5']) { if (topic_review($topic_id, $forum_id, 'post_review_edit', $post_id)) { -- cgit v1.2.1 From 0faafce4ce254ff282de801901372f67ca4f4415 Mon Sep 17 00:00:00 2001 From: callumacrae Date: Fri, 12 Jul 2013 21:52:10 -0400 Subject: [ticket/11672] Removed unnecessary text from alerts. Messages like "Return to forum last visited" are entirely unnecessary when using AJAX to delete a post, so this commit removes them. PHPBB3-11672 --- phpBB/posting.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 5db36007c2..6e9cc1aa94 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -386,8 +386,12 @@ if ($mode == 'bump') $meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time); meta_refresh(3, $meta_url); - $message = $user->lang['TOPIC_BUMPED'] . '

' . $user->lang('VIEW_MESSAGE', '', ''); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message = $user->lang['TOPIC_BUMPED']; + if (!$request->is_ajax()) + { + $message .= '

' . $user->lang('VIEW_MESSAGE', '', ''); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + } trigger_error($message); } @@ -1616,7 +1620,7 @@ function upload_popup($forum_style = 0) */ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $soft_delete_reason = '') { - global $user, $db, $auth, $config; + global $user, $db, $auth, $config, $request; global $phpbb_root_path, $phpEx; $perm_check = ($is_soft) ? 'softdelete' : 'delete'; @@ -1662,11 +1666,18 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username); $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; - $message = $user->lang['POST_DELETED'] . '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + $message = $user->lang['POST_DELETED']; + if (!$request->is_ajax()) + { + $message .= '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + } } meta_refresh(3, $meta_info); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + if (!$request->is_ajax()) + { + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + } trigger_error($message); } else -- cgit v1.2.1 From c6473da412d1a572ed80ec10d826239ad5ce5098 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 17 Oct 2013 20:14:14 -0700 Subject: [ticket/11672] Replace sprintf() usage with $user->lang(). PHPBB3-11672 --- phpBB/posting.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 6e9cc1aa94..0d2cff40bc 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -385,12 +385,12 @@ if ($mode == 'bump') { $meta_url = phpbb_bump_topic($forum_id, $topic_id, $post_data, $current_time); meta_refresh(3, $meta_url); - $message = $user->lang['TOPIC_BUMPED']; + if (!$request->is_ajax()) { $message .= '

' . $user->lang('VIEW_MESSAGE', '', ''); - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= '

' . $user->lang('RETURN_FORUM', '', ''); } trigger_error($message); @@ -1667,16 +1667,17 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; $message = $user->lang['POST_DELETED']; + if (!$request->is_ajax()) { - $message .= '

' . sprintf($user->lang['RETURN_TOPIC'], '', ''); + $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); } } meta_refresh(3, $meta_info); if (!$request->is_ajax()) { - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + $message .= '

' . $user->lang('RETURN_FORUM', '', ''); } trigger_error($message); } -- cgit v1.2.1 From 0a418739a36bdd41932d3ca18c4edcfa6cf44a01 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Thu, 19 Dec 2013 17:28:16 -0800 Subject: [ticket/12078] Check for f_delete when a user attempts to permanently delete PHPBB3-12078 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 0d2cff40bc..7a58aa9c72 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -42,7 +42,7 @@ $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($ $mode = request_var('mode', ''); // If the user is not allowed to delete the post, we try to soft delete it, so we overwrite the mode here. -if ($mode == 'delete' && (($confirm && !$request->is_set_post('delete_permanent')) || !$auth->acl_get('m_delete', $forum_id))) +if ($mode == 'delete' && (($confirm && !$request->is_set_post('delete_permanent')) || !$auth->acl_gets('f_delete', 'm_delete', $forum_id))) { $mode = 'soft_delete'; } -- cgit v1.2.1 From be52a823f871682a7740ca3c8207ac7f88f181f5 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sun, 10 Nov 2013 18:27:13 -0800 Subject: [ticket/11915] Provide the attachment file size to the template. PHPBB3-11915 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 0d2cff40bc..192fc69f47 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -484,7 +484,7 @@ $message_parser->get_submitted_attachment_data($post_data['poster_id']); if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode == 'edit') { // Do not change to SELECT * - $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename + $sql = 'SELECT attach_id, is_orphan, attach_comment, real_filename, filesize FROM ' . ATTACHMENTS_TABLE . " WHERE post_msg_id = $post_id AND in_message = 0 -- cgit v1.2.1 From 0ea110292b31bff28cced69dc066cc62ed09d208 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sun, 10 Nov 2013 18:29:49 -0800 Subject: [ticket/11915] Provide some additional info about limits to the uploader. PHPBB3-11915 --- phpBB/posting.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 192fc69f47..1711b91093 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1464,6 +1464,7 @@ $template->assign_vars(array( 'L_POST_A' => $page_title, 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), + 'L_TOO_MANY_ATTACHMENTS' => $user->lang('TOO_MANY_ATTACHMENTS', (int) $config['max_attachments']), 'FORUM_NAME' => $post_data['forum_name'], 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', @@ -1487,6 +1488,8 @@ $template->assign_vars(array( 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")), + 'ATTACH_ORDER' => ($config['display_order']) ? 'asc' : 'desc', + 'MAX_ATTACHMENTS' => ($auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) ? 0 : (int) $config['max_attachments'], 'S_PRIVMSGS' => false, 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, -- cgit v1.2.1 From 2719a18f7fc6ee3112c3ebc73d50e7c4d2f9d57f Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sun, 10 Nov 2013 18:31:58 -0800 Subject: [ticket/11915] Make it possible to display trigger_error() messages to user. PHPBB3-11915 --- phpBB/posting.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1711b91093..6066511d1c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -255,8 +255,18 @@ if (!$auth->acl_get('f_read', $forum_id)) { trigger_error('USER_CANNOT_READ'); } + $message = $user->lang['LOGIN_EXPLAIN_POST']; - login_box('', $user->lang['LOGIN_EXPLAIN_POST']); + if ($request->is_ajax()) + { + $json = new phpbb\json_response(); + $json->send(array( + 'title' => $user->lang['INFORMATION'], + 'message' => $message, + )); + } + + login_box('', $message); } // Permission to do the action asked? @@ -326,8 +336,18 @@ if (!$is_authed) { trigger_error('USER_CANNOT_' . strtoupper($check_auth)); } + $message = $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]; + + if ($request->is_ajax()) + { + $json = new phpbb\json_response(); + $json->send(array( + 'title' => $user->lang['INFORMATION'], + 'message' => $message, + )); + } - login_box('', $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]); + login_box('', $message); } // Is the user able to post within this forum? -- cgit v1.2.1 From ebc2d1dd1bd2a102ee8c8f1b134068e7a1f75c00 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 18 Dec 2013 19:23:14 -0800 Subject: [ticket/11915] Pass the data to the template instead of scraping HTML for it. PHPBB3-11915 --- phpBB/posting.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 6066511d1c..902f1b2175 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1548,8 +1548,9 @@ $template->assign_vars(array( 'S_BBCODE_QUOTE' => $quote_status, 'S_POST_ACTION' => $s_action, - 'S_HIDDEN_FIELDS' => $s_hidden_fields) -); + 'S_HIDDEN_FIELDS' => $s_hidden_fields, + 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), +)); /** * This event allows you to modify template variables for the posting screen -- cgit v1.2.1 From e2835d66cd630798458993e27e8ff2ea5eb6bfe8 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 16 Mar 2014 17:54:58 +0100 Subject: [ticket/10590] Remove confirmation page after posting PHPBB3-10590 --- phpBB/posting.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 442e1d9782..aee9ba50af 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1213,17 +1213,11 @@ if ($submit || $preview || $refresh) meta_refresh(10, $redirect_url); $message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD']; $message .= (($user->data['user_id'] == ANONYMOUS) ? '' : ' '. $user->lang['POST_APPROVAL_NOTIFY']); + $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); + trigger_error($message); } - else - { - meta_refresh(3, $redirect_url); - $message = ($mode == 'edit') ? 'POST_EDITED' : 'POST_STORED'; - $message = $user->lang[$message] . '

' . sprintf($user->lang['VIEW_MESSAGE'], '', ''); - } - - $message .= '

' . sprintf($user->lang['RETURN_FORUM'], '', ''); - trigger_error($message); + redirect($redirect_url); } } } -- cgit v1.2.1 From 18bed2ea476849fce3774783d728a763ab3e7138 Mon Sep 17 00:00:00 2001 From: geetakshi Date: Wed, 19 Mar 2014 19:55:55 +0530 Subject: [ticket/11360] Change second parameter in page_header function PHPBB3-11360 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 442e1d9782..ebb0af3adf 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1595,7 +1595,7 @@ if ($allowed) posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); // Output page ... -page_header($page_title, false); +page_header($page_title); $template->set_filenames(array( 'body' => 'posting_body.html') @@ -1623,7 +1623,7 @@ function upload_popup($forum_style = 0) ($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting'); - page_header($user->lang['PROGRESS_BAR'], false); + page_header($user->lang['PROGRESS_BAR']); $template->set_filenames(array( 'popup' => 'posting_progress_bar.html') -- cgit v1.2.1 From 66dad8d2fbc5820de0b31c4f9953ce5ce218cae9 Mon Sep 17 00:00:00 2001 From: PayBas Date: Sun, 6 Apr 2014 17:41:09 +0200 Subject: [ticket/12364] Add template identifier var to all missing pages PHPBB3-12364 --- phpBB/posting.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index ef90c229da..6b48470552 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1544,6 +1544,7 @@ $template->assign_vars(array( 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), + 'S_IN_POSTING' => true, )); /** -- cgit v1.2.1 From a8ec1905e18fda73c440373d696bf9d3b0e06b60 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Wed, 9 Apr 2014 11:35:19 -0700 Subject: [ticket/12356] Assign vars preventing Plupload from loading in PM editor. PHPBB3-12356 --- phpBB/posting.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 6b48470552..f592402fc6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1478,7 +1478,6 @@ $template->assign_vars(array( 'L_POST_A' => $page_title, 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), - 'L_TOO_MANY_ATTACHMENTS' => $user->lang('TOO_MANY_ATTACHMENTS', (int) $config['max_attachments']), 'FORUM_NAME' => $post_data['forum_name'], 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', @@ -1502,8 +1501,6 @@ $template->assign_vars(array( 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), 'UA_PROGRESS_BAR' => addslashes(append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup")), - 'ATTACH_ORDER' => ($config['display_order']) ? 'asc' : 'desc', - 'MAX_ATTACHMENTS' => ($auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) ? 0 : (int) $config['max_attachments'], 'S_PRIVMSGS' => false, 'S_CLOSE_PROGRESS_WINDOW' => (isset($_POST['add_file'])) ? true : false, @@ -1583,7 +1580,8 @@ $allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') if ($allowed) { - $plupload->configure($cache, $template, $s_action, $forum_id); + $max_files = ($auth->acl_get('a_') || $auth->acl_get('m_', $forum_id)) ? 0 : (int) $config['max_attachments']; + $plupload->configure($cache, $template, $s_action, $forum_id, $max_files); } // Attachment entry -- cgit v1.2.1 From 11c4d14a9bf2fec0fbf9226cd1d7cb3a1468ac26 Mon Sep 17 00:00:00 2001 From: n-aleha Date: Mon, 14 Apr 2014 08:37:47 +0300 Subject: [ticket/12391] Assign variables to core.posting_modify_template_vars Assign variables to event "core.posting_modify_template_vars". Also, fix a couple of typos. PHPBB3-12391 --- phpBB/posting.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f592402fc6..ed1268e84b 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -52,7 +52,7 @@ $current_time = time(); /** * This event allows you to alter the above parameters, such as submit and mode -* +* * Note: $refresh must be true to retain previously submitted form data. * * Note: The template class will not work properly until $user->setup() is @@ -74,7 +74,7 @@ $current_time = time(); * viewtopic or viewforum depending on if the user * is posting a new topic or editing a post) * @var bool refresh Whether or not to retain previously submitted data -* @var string mode What action to take if the form has been sumitted +* @var string mode What action to take if the form has been submitted * post|reply|quote|edit|delete|bump|smilies|popup * @var array error Any error strings; a non-empty array aborts * form submission. @@ -1548,9 +1548,21 @@ $template->assign_vars(array( * This event allows you to modify template variables for the posting screen * * @event core.posting_modify_template_vars +* @var array post_data Array with post data +* @var array moderators Array with forum moderators +* @var string mode What action to take if the form is submitted +* post|reply|quote|edit|delete|bump|smilies|popup +* @var string page_title Title of the mode page +* @var bool s_topic_icons Whether or not to show the topic icons +* @var string form_enctype If attachments are allowed for this form the value of +* this is "multipart/form-data" else it is the empty string +* @var string s_action The URL to submit the POST data to +* @var string s_hidden_fields The concatenated input tags of the form's hidden fields * @since 3.1-A1 +* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields */ -$phpbb_dispatcher->dispatch('core.posting_modify_template_vars'); +$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype', 's_action', 's_hidden_fields'); +extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); // Build custom bbcodes array display_custom_bbcodes(); -- cgit v1.2.1 From b2bfcda19c20ca695f8228ef49de9295c191a316 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2014 14:40:50 +0200 Subject: [ticket/12407] Allow changing of post_data, etc. at end of posting.php The current event core.posting_modify_template_vars is just ran using dispatch but it doesn't pass any data from posting.php to the listener. Because of that, it's not possible to know anything from posting.php and therefore limits the use cases of this event. This will change it to allow similar actions as with the event core.modify_posting_parameters. PHPBB3-12407 --- phpBB/posting.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f592402fc6..b6a388dc64 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1473,8 +1473,8 @@ $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_up add_form_key('posting'); -// Start assigning vars for main posting page ... -$template->assign_vars(array( +// Build array of variables for main posting page +$page_data = array( 'L_POST_A' => $page_title, 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), @@ -1542,15 +1542,42 @@ $template->assign_vars(array( 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_ATTACH_DATA' => json_encode($message_parser->attachment_data), 'S_IN_POSTING' => true, -)); +); /** * This event allows you to modify template variables for the posting screen * * @event core.posting_modify_template_vars +* @var int post_id ID of the post +* @var int topic_id ID of the topic +* @var int forum_id ID of the forum +* @var bool submit Whether or not the form has been submitted +* @var bool preview Whether or not the post is being previewed +* @var bool save Whether or not a draft is being saved +* @var bool load Whether or not a draft is being loaded +* @var bool delete Whether or not the post is being deleted +* @var bool cancel Whether or not to cancel the form (returns to +* viewtopic or viewforum depending on if the user +* is posting a new topic or editing a post) +* @var bool refresh Whether or not to retain previously submitted data +* @var string mode What action to take if the form has been sumitted +* post|reply|quote|edit|delete|bump|smilies|popup +* @var array error Any error strings; a non-empty array aborts +* form submission. +* NOTE: Should be actual language strings, NOT +* language keys. +* @var array s_hidden_fields Hidden fields of posting form +* @var array post_data Post data of the post to create, edit, etc. +* @var array page_data Posting page data that should be passed to the +* posting page via $template->assign_vars() * @since 3.1-A1 +* @changed 3.1.0-b3 Introduced variables passed to listener */ -$phpbb_dispatcher->dispatch('core.posting_modify_template_vars'); +$vars = array('post_id', 'topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error', 's_hidden_fields', 'post_data', 'page_data'); +extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); + +// Start assigning vars for main posting page ... +$template->assign_vars($page_data); // Build custom bbcodes array display_custom_bbcodes(); -- cgit v1.2.1 From 61f4802b5a40c0d30de8398a058a24baf2cab182 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2014 16:00:12 +0200 Subject: [ticket/12407] Add message_parser as passed variable to event PHPBB3-12407 --- phpBB/posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index b6a388dc64..7a90a473a7 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1570,10 +1570,11 @@ $page_data = array( * @var array post_data Post data of the post to create, edit, etc. * @var array page_data Posting page data that should be passed to the * posting page via $template->assign_vars() +* @var object message_parser The message parser object * @since 3.1-A1 * @changed 3.1.0-b3 Introduced variables passed to listener */ -$vars = array('post_id', 'topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error', 's_hidden_fields', 'post_data', 'page_data'); +$vars = array('post_id', 'topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error', 's_hidden_fields', 'post_data', 'page_data', 'message_parser'); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); // Start assigning vars for main posting page ... -- cgit v1.2.1 From a3dbfb749ec71e67f20f65c7f8acdd2f61612561 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Apr 2014 11:10:29 +0200 Subject: [ticket/12407] Assign template variables again after merging develop-ascraeus PHPBB3-12407 --- phpBB/posting.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 7f374338ff..3262a3353b 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1588,6 +1588,9 @@ $vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', $vars += array('topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser'); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); +// Start assigning vars for main posting page ... +$template->assign_vars($page_data); + // Build custom bbcodes array display_custom_bbcodes(); -- cgit v1.2.1 From bfd66ef2fdc1721ded267b6a0af3883f827840c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Apr 2014 12:38:55 +0200 Subject: [ticket/12407] Merge @change in doc block of event PHPBB3-12407 --- phpBB/posting.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 3262a3353b..cac0aa30c0 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1579,10 +1579,9 @@ $page_data = array( * @var object message_parser The message parser object * @since 3.1-A1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, -* s_topic_icons, form_enctype, s_action, s_hidden_fields -* @change 3.1.0-b3 Added vars post_id, topic_id, forum_id, submit, preview, -* save, load, delete, cancel, refresh, error, page_data, -* message_parser +* s_topic_icons, form_enctype, s_action, s_hidden_fields, +* post_id, topic_id, forum_id, submit, preview, save, load, +* delete, cancel, refresh, error, page_data, message_parser */ $vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype', 's_action', 's_hidden_fields', 'post_id'); $vars += array('topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser'); -- cgit v1.2.1 From c2dace762ec295c7a2d67758006b1fff56f1f573 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 15:13:13 +0200 Subject: [ticket/12273] Fix long $vars lines for existing events PHPBB3-12273 --- phpBB/posting.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index ed1268e84b..3d48a67e60 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -82,7 +82,9 @@ $current_time = time(); * language keys. * @since 3.1-A1 */ -$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error'); +$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick'); +$vars = array_merge($vars, array('submit', 'preview', 'save', 'load', 'delete')); +$vars = array_merge($vars, array('cancel', 'refresh', 'mode', 'error')); extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); // Was cancel pressed? If so then redirect to the appropriate page @@ -1561,7 +1563,8 @@ $template->assign_vars(array( * @since 3.1-A1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields */ -$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype', 's_action', 's_hidden_fields'); +$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons'); +$vars = array_merge($vars, array('form_enctype', 's_action', 's_hidden_fields')); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); // Build custom bbcodes array -- cgit v1.2.1 From 87899b0e140400e23341ea1286d50e330132be90 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 11:46:44 +0200 Subject: [ticket/12273] Update existing events PHPBB3-12273 --- phpBB/posting.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 3d48a67e60..11f0898440 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -82,9 +82,22 @@ $current_time = time(); * language keys. * @since 3.1-A1 */ -$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick'); -$vars = array_merge($vars, array('submit', 'preview', 'save', 'load', 'delete')); -$vars = array_merge($vars, array('cancel', 'refresh', 'mode', 'error')); +$vars = array( + 'post_id', + 'topic_id', + 'forum_id', + 'draft_id', + 'lastclick', + 'submit', + 'preview', + 'save', + 'load', + 'delete', + 'cancel', + 'refresh', + 'mode', + 'error', +); extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars))); // Was cancel pressed? If so then redirect to the appropriate page @@ -1563,8 +1576,16 @@ $template->assign_vars(array( * @since 3.1-A1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields */ -$vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons'); -$vars = array_merge($vars, array('form_enctype', 's_action', 's_hidden_fields')); +$vars = array( + 'post_data', + 'moderators', + 'mode', + 'page_title', + 's_topic_icons', + 'form_enctype', + 's_action', + 's_hidden_fields', +); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); // Build custom bbcodes array -- cgit v1.2.1 From b32895308d13d5d9b0cd954fd8ce871a1fa073da Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 12:15:44 +0200 Subject: [ticket/12273] Update since version to 3.1.0-a* style PHPBB3-12273 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 11f0898440..cfd6524e62 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -80,7 +80,7 @@ $current_time = time(); * form submission. * NOTE: Should be actual language strings, NOT * language keys. -* @since 3.1-A1 +* @since 3.1.0-a1 */ $vars = array( 'post_id', @@ -1573,7 +1573,7 @@ $template->assign_vars(array( * this is "multipart/form-data" else it is the empty string * @var string s_action The URL to submit the POST data to * @var string s_hidden_fields The concatenated input tags of the form's hidden fields -* @since 3.1-A1 +* @since 3.1.0-a1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields */ $vars = array( -- cgit v1.2.1 From 0ef920eb427203e27cb56c19d2a6894ba79786c4 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sat, 26 Apr 2014 15:01:30 +0200 Subject: [ticket/12025] Post Preview no longer shows warnings https://tracker.phpbb.com/browse/PHPBB3-12025 PHPBB3-12025 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index ed1268e84b..975f4bd079 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -882,7 +882,7 @@ if ($submit || $preview || $refresh) $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); // On a refresh we do not care about message parsing errors - if (sizeof($message_parser->warn_msg) && $refresh) + if (sizeof($message_parser->warn_msg) && $refresh && !$preview) { $message_parser->warn_msg = array(); } -- cgit v1.2.1 From 8facf2b8d9980ef92ad519ebf004e1bdc1c4d287 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sun, 27 Apr 2014 23:11:10 +0200 Subject: [ticket/12025] Don't show any error on preview if the message is empty PHPBB3-12025 --- phpBB/posting.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 975f4bd079..47b366fce0 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -879,7 +879,10 @@ if ($submit || $preview || $refresh) $message_parser->warn_msg = array(); } - $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); + if ($preview && empty($message_parser->message)) + { + $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); + } // On a refresh we do not care about message parsing errors if (sizeof($message_parser->warn_msg) && $refresh && !$preview) -- cgit v1.2.1 From 7af9f41e4f2a179065ce42dfb0755ecf3459add7 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Mon, 28 Apr 2014 21:18:01 +0200 Subject: [ticket/12025] Fixing the condition.... PHPBB3-12025 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 47b366fce0..9a3df73701 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -879,7 +879,7 @@ if ($submit || $preview || $refresh) $message_parser->warn_msg = array(); } - if ($preview && empty($message_parser->message)) + if (! ($preview && empty($message_parser->message))) { $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); } -- cgit v1.2.1 From 1c336c355965fbe47717744e0d5fb04125d12247 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sat, 26 Apr 2014 12:47:24 +0200 Subject: [ticket/11942] Adding the reason to hard deleted topic/post PHPBB3-11942 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index cfd6524e62..46ccf40e5c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1709,14 +1709,14 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof if ($next_post_id === false) { - add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username); + add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username, $soft_delete_reason); $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); $message = $user->lang['POST_DELETED']; } else { - add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username); + add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username, $soft_delete_reason); $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; $message = $user->lang['POST_DELETED']; -- cgit v1.2.1 From 00610677152f073c4cded21a24f5ce92bbb39b8c Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 5 May 2014 18:23:55 +0200 Subject: [ticket/12025] Apply DeMorgan PHPBB3-12025 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 9a3df73701..89056f0f11 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -879,7 +879,7 @@ if ($submit || $preview || $refresh) $message_parser->warn_msg = array(); } - if (! ($preview && empty($message_parser->message))) + if (!$preview || !empty($message_parser->message)) { $message_parser->parse($post_data['enable_bbcode'], ($config['allow_post_links']) ? $post_data['enable_urls'] : false, $post_data['enable_smilies'], $img_status, $flash_status, $quote_status, $config['allow_post_links']); } -- cgit v1.2.1 From 0bc5e951987ff77b2f1611981fcdb33efcc55ad6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 11 May 2014 09:40:26 +0200 Subject: [ticket/12407] Fix incorrect @since line in event PHPBB3-12407 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index bdb4d21924..345b5b094e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1596,7 +1596,7 @@ $page_data = array( * @var array page_data Posting page data that should be passed to the * posting page via $template->assign_vars() * @var object message_parser The message parser object -* @since 3.1-A1 +* @since 3.1.0-a1 * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, * s_topic_icons, form_enctype, s_action, s_hidden_fields, * post_id, topic_id, forum_id, submit, preview, save, load, -- cgit v1.2.1 From e7923336fb146c90d14ee0ccb3c164017bd3aef6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 11 May 2014 10:10:26 +0200 Subject: [ticket/12407] Remove merge marker from posting.php PHPBB3-12407 --- phpBB/posting.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 345b5b094e..d48157dcd6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1572,7 +1572,6 @@ $page_data = array( * post|reply|quote|edit|delete|bump|smilies|popup * @var string page_title Title of the mode page * @var bool s_topic_icons Whether or not to show the topic icons -<<<<<<< HEAD * @var string form_enctype If attachments are allowed for this form * "multipart/form-data" or empty string * @var string s_action The URL to submit the POST data to -- cgit v1.2.1 From 237619792dd2d7b6c9e057307139e6bb52283df3 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 11 May 2014 19:28:26 +0200 Subject: [ticket/11942] Always display delete reason PHPBB3-11942 --- phpBB/posting.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 46ccf40e5c..cc39f70b48 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1740,14 +1740,12 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof $can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id)); $can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id)); - $display_reason = $auth->acl_get('m_softdelete', $forum_id) || ($can_delete && $can_softdelete); $template->assign_vars(array( 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', 'S_ALLOWED_DELETE' => $can_delete, 'S_ALLOWED_SOFTDELETE' => $can_softdelete, - 'S_DELETE_REASON' => $display_reason, )); $l_confirm = 'DELETE_POST'; -- cgit v1.2.1 From 12e0e358d1b04af41c34039dbc23b54f260883fd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 11 May 2014 19:35:42 +0200 Subject: [ticket/11942] Apply the modifications to subsilver PHPBB3-11942 --- phpBB/posting.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index cc39f70b48..2d25aedae8 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1537,7 +1537,6 @@ $template->assign_vars(array( 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', 'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '', - 'S_DELETE_REASON' => ($mode == 'edit' && $auth->acl_get('m_softdelete', $forum_id)) ? true : false, 'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false, 'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id), 'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false, -- cgit v1.2.1 From b430979f604c89bd4ee8e48c6a637ed52dcc5609 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 11 May 2014 20:04:00 +0200 Subject: [ticket/12518] Add event to overwrite the cannot edit condition in posting.php PHPBB3-12518 --- phpBB/posting.php | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index d48157dcd6..6e1bde42f8 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -381,19 +381,46 @@ if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_statu // else it depends on editing times, lock status and if we're the correct user if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) { - if ($user->data['user_id'] != $post_data['poster_id']) - { - trigger_error('USER_CANNOT_EDIT'); - } - - if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) - { - trigger_error('CANNOT_EDIT_TIME'); - } + $force_edit_allowed = false; + + $s_cannot_edit = $user->data['user_id'] != $post_data['poster_id']; + $s_cannot_edit_time = !($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']); + $s_cannot_edit_locked = $post_data['post_edit_locked']; + + /** + * This event allows you to modify the conditions for the "cannot edit post" checks + * + * @event core.posting_modify_cannot_edit_conditions + * @var array post_data Array with post data + * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored) + * @var bool s_cannot_edit User can not edit the post because it's not his + * @var bool s_cannot_edit_locked User can not edit the post because it's locked + * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed + * @since 3.1.0-b4 + */ + $vars = array( + 'post_data', + 'force_edit_allowed', + 's_cannot_edit', + 's_cannot_edit_locked', + 's_cannot_edit_time', + ); + extract($phpbb_dispatcher->trigger_event('core.posting_modify_cannot_edit_conditions', compact($vars))); - if ($post_data['post_edit_locked']) + if (!$force_edit_allowed) { - trigger_error('CANNOT_EDIT_POST_LOCKED'); + if ($s_cannot_edit) + { + trigger_error('USER_CANNOT_EDIT'); + } + else if ($s_cannot_edit_time) + { + trigger_error('CANNOT_EDIT_TIME'); + } + else if ($s_cannot_edit_locked) + { + trigger_error('CANNOT_EDIT_POST_LOCKED'); + } } } -- cgit v1.2.1 From 8d20f095aaa9e00f10a67022f0f0e84bf0a2b802 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 11 May 2014 22:49:10 +0200 Subject: [ticket/12518] Apply De Morgan to make the conditions easier to read PHPBB3-12518 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 6e1bde42f8..441de9f28c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -384,7 +384,7 @@ if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id)) $force_edit_allowed = false; $s_cannot_edit = $user->data['user_id'] != $post_data['poster_id']; - $s_cannot_edit_time = !($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']); + $s_cannot_edit_time = $config['edit_time'] && $post_data['post_time'] <= time() - ($config['edit_time'] * 60); $s_cannot_edit_locked = $post_data['post_edit_locked']; /** -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/posting.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 441de9f28c..d3015c6eb6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1 From 95b9c938922a95c5755c66714989e42c03d7ee60 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 31 May 2014 10:12:24 -0700 Subject: [ticket/12640] Preserve the active tab when previewing in posting page. PHPBB3-12640 --- phpBB/posting.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 2516067aae..60bb595da6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1546,6 +1546,7 @@ $page_data = array( 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], 'EDIT_REASON' => $request->variable('edit_reason', ''), + 'SHOW_PANEL' => $request->variable('show_panel', ''), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', 'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&mode=popup"), -- cgit v1.2.1 From b8151b1299c02506ffa0d665461d85e32cd4cd10 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 9 Jun 2014 18:56:13 +0200 Subject: [ticket/11711] Improve checks for unsupported characters and check subject PHPBB3-11711 --- phpBB/posting.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 60bb595da6..fc407caf69 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1028,6 +1028,14 @@ if ($submit || $preview || $refresh) $error[] = $user->lang['EMPTY_SUBJECT']; } + // Check for out-of-bounds characters that are currently + // not supported by utf8_bin + if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches)) + { + $character_list = implode('
', $matches[0]); + $error[] = $user->lang('UNSUPPORTED_CHARACTERS_SUBJECT', $character_list); + } + $post_data['poll_last_vote'] = (isset($post_data['poll_last_vote'])) ? $post_data['poll_last_vote'] : 0; if ($post_data['poll_option_text'] && -- cgit v1.2.1 From 5ee7f20f4ee110c2ae0b122e9efbd4fabf669581 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 10 Jun 2014 15:51:25 +0200 Subject: [ticket/11711] Improve coding and comments of character check PHPBB3-11711 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index fc407caf69..17eac71bd3 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1029,7 +1029,7 @@ if ($submit || $preview || $refresh) } // Check for out-of-bounds characters that are currently - // not supported by utf8_bin + // not supported by utf8_bin in MySQL if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $post_data['post_subject'], $matches)) { $character_list = implode('
', $matches[0]); -- cgit v1.2.1 From 73c69cc6536b189ca29494ca6e550e0432f419b3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 18 Jun 2014 15:12:32 +0200 Subject: [ticket/12612] Move functions from posting.php to functions_posting.php PHPBB3-12612 --- phpBB/posting.php | 134 ------------------------------------------------------ 1 file changed, 134 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 60bb595da6..44e5851319 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1714,137 +1714,3 @@ if ($mode == 'reply' || $mode == 'quote') } page_footer(); - -/** -* Show upload popup (progress bar) -*/ -function upload_popup($forum_style = 0) -{ - global $template, $user; - - ($forum_style) ? $user->setup('posting', $forum_style) : $user->setup('posting'); - - page_header($user->lang['PROGRESS_BAR']); - - $template->set_filenames(array( - 'popup' => 'posting_progress_bar.html') - ); - - $template->assign_vars(array( - 'PROGRESS_BAR' => $user->img('upload_bar', $user->lang['UPLOAD_IN_PROGRESS'])) - ); - - $template->display('popup'); - - garbage_collection(); - exit_handler(); -} - -/** -* Do the various checks required for removing posts as well as removing it -*/ -function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $soft_delete_reason = '') -{ - global $user, $db, $auth, $config, $request; - global $phpbb_root_path, $phpEx; - - $perm_check = ($is_soft) ? 'softdelete' : 'delete'; - - // If moderator removing post or user itself removing post, present a confirmation screen - if ($auth->acl_get("m_$perm_check", $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get("f_$perm_check", $forum_id) && $post_id == $post_data['topic_last_post_id'] && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']))) - { - $s_hidden_fields = array( - 'p' => $post_id, - 'f' => $forum_id, - 'mode' => ($is_soft) ? 'soft_delete' : 'delete', - ); - - if (confirm_box(true)) - { - $data = array( - 'topic_first_post_id' => $post_data['topic_first_post_id'], - 'topic_last_post_id' => $post_data['topic_last_post_id'], - 'topic_posts_approved' => $post_data['topic_posts_approved'], - 'topic_posts_unapproved' => $post_data['topic_posts_unapproved'], - 'topic_posts_softdeleted' => $post_data['topic_posts_softdeleted'], - 'topic_visibility' => $post_data['topic_visibility'], - 'topic_type' => $post_data['topic_type'], - 'post_visibility' => $post_data['post_visibility'], - 'post_reported' => $post_data['post_reported'], - 'post_time' => $post_data['post_time'], - 'poster_id' => $post_data['poster_id'], - 'post_postcount' => $post_data['post_postcount'], - ); - - $next_post_id = delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $soft_delete_reason); - $post_username = ($post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username'])) ? $post_data['post_username'] : $post_data['username']; - - if ($next_post_id === false) - { - add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username, $soft_delete_reason); - - $meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"); - $message = $user->lang['POST_DELETED']; - } - else - { - add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username, $soft_delete_reason); - - $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&p=$next_post_id") . "#p$next_post_id"; - $message = $user->lang['POST_DELETED']; - - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_TOPIC', '', ''); - } - } - - meta_refresh(3, $meta_info); - if (!$request->is_ajax()) - { - $message .= '

' . $user->lang('RETURN_FORUM', '', ''); - } - trigger_error($message); - } - else - { - global $user, $template, $request; - - $can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id)); - $can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id)); - - $template->assign_vars(array( - 'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED, - 'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '', - 'S_ALLOWED_DELETE' => $can_delete, - 'S_ALLOWED_SOFTDELETE' => $can_softdelete, - )); - - $l_confirm = 'DELETE_POST'; - if ($post_data['post_visibility'] == ITEM_DELETED) - { - $l_confirm .= '_PERMANENTLY'; - $s_hidden_fields['delete_permanent'] = '1'; - } - else if (!$can_softdelete) - { - $s_hidden_fields['delete_permanent'] = '1'; - } - - confirm_box(false, $l_confirm, build_hidden_fields($s_hidden_fields), 'confirm_delete_body.html'); - } - } - - // If we are here the user is not able to delete - present the correct error message - if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) - { - trigger_error('DELETE_OWN_POSTS'); - } - - if ($post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && $post_id != $post_data['topic_last_post_id']) - { - trigger_error('CANNOT_DELETE_REPLIED'); - } - - trigger_error('USER_CANNOT_DELETE'); -} -- cgit v1.2.1 From 94a81fa01d0106f6deba6cbb9000f4c8bbbf607a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 9 Jan 2014 23:53:19 +0100 Subject: [ticket/11148] Pass mimetype guesser to upload_attachment() function PHPBB3-11148 --- phpBB/posting.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1b8fa6debf..0e912330e0 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -523,7 +523,9 @@ $orig_poll_options_size = sizeof($post_data['poll_options']); $message_parser = new parse_message(); $plupload = $phpbb_container->get('plupload'); +$mimetype_guesser = $phpbb_container->get('mimetype.guesser'); $message_parser->set_plupload($plupload); +$message_parser->set_mimetype_guesser($mimetype_guesser); if (isset($post_data['post_text'])) { -- cgit v1.2.1 From 5403b487885dd7593a43c198f8baacc194ff1a3a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 23 Jun 2014 22:48:08 +0200 Subject: [ticket/12612] Prefix handle_post_delete() with phpbb and remove unused global PHPBB3-12612 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1b8fa6debf..dedd393858 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -439,7 +439,7 @@ if ($mode == 'delete' || $mode == 'soft_delete') $allow_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); $soft_delete_reason = ($mode == 'soft_delete' && $allow_reason) ? $request->variable('delete_reason', '', true) : ''; - handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason); + phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason); return; } @@ -1259,7 +1259,7 @@ if ($submit || $preview || $refresh) { $allow_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); $soft_delete_reason = (!$request->is_set_post('delete_permanent') && $allow_reason) ? $request->variable('delete_reason', '', true) : ''; - handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $soft_delete_reason); + phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $soft_delete_reason); return; } -- cgit v1.2.1 From e4437e19e8be79c32945fbb4e79df84e60e73690 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 23 Jun 2014 22:49:00 +0200 Subject: [ticket/12612] Prefix upload_popup() with phpbb_ PHPBB3-12612 --- phpBB/posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index dedd393858..70df052099 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -195,7 +195,7 @@ switch ($mode) } else { - upload_popup(); + phpbb_upload_popup(); return; } break; @@ -233,7 +233,7 @@ if ($auth->acl_get('m_approve', $forum_id) && ((($mode == 'reply' || $mode == 'b if ($mode == 'popup') { - upload_popup($post_data['forum_style']); + phpbb_upload_popup($post_data['forum_style']); return; } -- cgit v1.2.1 From 160ff7b912243dc14d871b820213ddcd20dd06f4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 8 Aug 2014 18:02:03 +0200 Subject: [ticket/11854] Move captcha stuff to phpbb/ and use DI for plugins PHPBB3-11854 --- phpBB/posting.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 6638caa94b..6d6297741b 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -241,8 +241,7 @@ $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); if ($config['enable_post_confirm'] && !$user->data['is_registered']) { - include($phpbb_root_path . 'includes/captcha/captcha_factory.' . $phpEx); - $captcha = phpbb_captcha_factory::get_instance($config['captcha_plugin']); + $captcha = $phpbb_container->get('captchas.factory')->get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST); } -- cgit v1.2.1 From b91abf1a0bd751da640219596a94019f70086c0b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 9 Aug 2014 15:57:01 +0200 Subject: [ticket/11854] Rename captchas.factory service to captcha.factory PHPBB3-11854 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 6d6297741b..4c3d012ca5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -241,7 +241,7 @@ $user->setup(array('posting', 'mcp', 'viewtopic'), $post_data['forum_style']); if ($config['enable_post_confirm'] && !$user->data['is_registered']) { - $captcha = $phpbb_container->get('captchas.factory')->get_instance($config['captcha_plugin']); + $captcha = $phpbb_container->get('captcha.factory')->get_instance($config['captcha_plugin']); $captcha->init(CONFIRM_POST); } -- cgit v1.2.1 From bf7041eeb9682dc7a47a6837af700f9f56ec0d27 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sun, 14 Sep 2014 10:38:56 -0700 Subject: [ticket/13019] Always accept a reason for deleting a post/topic. PHPBB3-13019 --- phpBB/posting.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 4c3d012ca5..18572a3a6c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -436,9 +436,8 @@ if ($mode == 'delete' || $mode == 'soft_delete') trigger_error('NO_POST'); } - $allow_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); - $soft_delete_reason = ($mode == 'soft_delete' && $allow_reason) ? $request->variable('delete_reason', '', true) : ''; - phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $soft_delete_reason); + $delete_reason = $request->variable('delete_reason', '', true); + phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $delete_reason); return; } @@ -1258,9 +1257,8 @@ if ($submit || $preview || $refresh) // Handle delete mode... if ($request->is_set_post('delete') || $request->is_set_post('delete_permanent')) { - $allow_reason = $auth->acl_get('m_softdelete', $forum_id) || ($auth->acl_gets('m_delete', 'f_delete', $forum_id) && $auth->acl_gets('m_softdelete', 'f_softdelete', $forum_id)); - $soft_delete_reason = (!$request->is_set_post('delete_permanent') && $allow_reason) ? $request->variable('delete_reason', '', true) : ''; - phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $soft_delete_reason); + $delete_reason = $request->variable('delete_reason', '', true); + phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, !$request->is_set_post('delete_permanent'), $delete_reason); return; } -- cgit v1.2.1 From cb49a0c4cca2464a10fdf461bb43b5d81c3e7b31 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 1 Oct 2014 00:13:37 +0200 Subject: [ticket/13123] Add events to allow modifying post data PHPBB3-13123 --- phpBB/posting.php | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 18572a3a6c..764a16d386 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1155,6 +1155,34 @@ if ($submit || $preview || $refresh) } } + /** + * This event allows you to define errors before the post action is performed + * + * @event core.posting_modify_submission_errors + * @var array post_data Array with post data + * @var string mode What action to take if the form is submitted + * post|reply|quote|edit|delete|bump|smilies|popup + * @var string page_title Title of the mode page + * @var int post_id ID of the post + * @var int topic_id ID of the topic + * @var int forum_id ID of the forum + * @var bool submit Whether or not the form has been submitted + * @var array error Any error strings; a non-empty array aborts form submission. + * NOTE: Should be actual language strings, NOT language keys. + * @since 3.1.0-RC5 + */ + $vars = array( + 'post_data', + 'mode', + 'page_title', + 'post_id', + 'topic_id', + 'forum_id', + 'submit', + 'error', + ); + extract($phpbb_dispatcher->trigger_event('core.posting_modify_submission_errors', compact($vars))); + // Store message, sync counters if (!sizeof($error) && $submit) { @@ -1246,9 +1274,87 @@ if ($submit || $preview || $refresh) // post's poster, not the poster of the current post). See: PHPBB3-11769 for more information. $post_author_name = ((!$user->data['is_registered'] || $mode == 'edit') && $post_data['username'] !== '') ? $post_data['username'] : ''; + /** + * This event allows you to define errors before the post action is performed + * + * @event core.posting_modify_submit_post_before + * @var array post_data Array with post data + * @var array poll Array with poll data + * @var array data Array with post data going to be stored in the database + * @var string mode What action to take if the form is submitted + * post|reply|quote|edit|delete + * @var string page_title Title of the mode page + * @var int post_id ID of the post + * @var int topic_id ID of the topic + * @var int forum_id ID of the forum + * @var string post_author_name Author name for guest posts + * @var bool update_message Boolean if the post message was changed + * @var bool update_subject Boolean if the post subject was changed + * @var bool submit Whether or not the form has been submitted + * @var array error Any error strings; a non-empty array aborts form submission. + * NOTE: Should be actual language strings, NOT language keys. + * @since 3.1.0-RC5 + */ + $vars = array( + 'post_data', + 'poll', + 'data', + 'mode', + 'page_title', + 'post_id', + 'topic_id', + 'forum_id', + 'post_author_name', + 'update_message', + 'update_subject', + 'submit', + 'error', + ); + extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_before', compact($vars))); + // The last parameter tells submit_post if search indexer has to be run $redirect_url = submit_post($mode, $post_data['post_subject'], $post_author_name, $post_data['topic_type'], $poll, $data, $update_message, ($update_message || $update_subject) ? true : false); + /** + * This event allows you to define errors after the post action is performed + * + * @event core.posting_modify_submit_post_after + * @var array post_data Array with post data + * @var array poll Array with poll data + * @var array data Array with post data going to be stored in the database + * @var string mode What action to take if the form is submitted + * post|reply|quote|edit|delete + * @var string page_title Title of the mode page + * @var int post_id ID of the post + * @var int topic_id ID of the topic + * @var int forum_id ID of the forum + * @var string post_author_name Author name for guest posts + * @var bool update_message Boolean if the post message was changed + * @var bool update_subject Boolean if the post subject was changed + * @var string redirect_url URL the user is going to be redirected to + * @var bool submit Whether or not the form has been submitted + * @var array error Any error strings; a non-empty array aborts form submission. + * NOTE: Should be actual language strings, NOT language keys. + * @since 3.1.0-RC5 + */ + $vars = array( + 'post_data', + 'poll', + 'data', + 'mode', + 'page_title', + 'post_id', + 'topic_id', + 'forum_id', + 'post_author_name', + 'update_message', + 'update_subject', + 'redirect_url', + 'submit', + 'error', + ); + extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_after', compact($vars))); + if ($config['enable_post_confirm'] && !$user->data['is_registered'] && (isset($captcha) && $captcha->is_solved() === true) && ($mode == 'post' || $mode == 'reply' || $mode == 'quote')) { $captcha->reset(); -- cgit v1.2.1 From 2d0917c56e3a29dde5707b382ad0c6725f416996 Mon Sep 17 00:00:00 2001 From: omniError Date: Mon, 10 Nov 2014 17:23:23 -0600 Subject: [ticket/13323] empty auth option in posting.php https://tracker.phpbb.com/browse/PHPBB3-13323 PHPBB3-13323 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 764a16d386..762439007d 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1125,7 +1125,7 @@ if ($submit || $preview || $refresh) break; } - if (!$auth->acl_get($auth_option, $forum_id)) + if ($auth_option != '' && !$auth->acl_get($auth_option, $forum_id)) { // There is a special case where a user edits his post whereby the topic type got changed by an admin/mod. // Another case would be a mod not having sticky permissions for example but edit permissions. -- cgit v1.2.1 From bb75cd40f5e93f87affd68ee31ea186e240133e4 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 19 Oct 2014 02:34:38 +0800 Subject: [ticket/13182] Add posting.php core event to allow modifying the message text posting.php core event to allow modifying the message before parsing would be needed for some extensions, like for adding topic title to the topic URL etc. Also removed 'delete' var from core.posting_modify_template_vars and core.modify_posting_parameters as it does not exist. PHPBB3-13182 --- phpBB/posting.php | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 764a16d386..4c32276d17 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -73,7 +73,6 @@ $current_time = time(); * @var bool preview Whether or not the post is being previewed * @var bool save Whether or not a draft is being saved * @var bool load Whether or not a draft is being loaded -* @var bool delete Whether or not the post is being deleted * @var bool cancel Whether or not to cancel the form (returns to * viewtopic or viewforum depending on if the user * is posting a new topic or editing a post) @@ -85,6 +84,7 @@ $current_time = time(); * NOTE: Should be actual language strings, NOT * language keys. * @since 3.1.0-a1 +* @change 3.1.2-RC1 Removed 'delete' var as it does not exist */ $vars = array( 'post_id', @@ -96,7 +96,6 @@ $vars = array( 'preview', 'save', 'load', - 'delete', 'cancel', 'refresh', 'mode', @@ -870,6 +869,43 @@ if ($submit || $preview || $refresh) // Parse Attachments - before checksum is calculated $message_parser->parse_attachments('fileupload', $mode, $forum_id, $submit, $preview, $refresh); + /** + * This event allows you to modify message text before parsing + * + * @event core.posting_modify_message_text + * @var array post_data Array with post data + * @var string mode What action to take if the form is submitted + * post|reply|quote|edit|delete|bump|smilies|popup + * @var int post_id ID of the post + * @var int topic_id ID of the topic + * @var int forum_id ID of the forum + * @var bool submit Whether or not the form has been submitted + * @var bool preview Whether or not the post is being previewed + * @var bool save Whether or not a draft is being saved + * @var bool load Whether or not a draft is being loaded + * @var bool cancel Whether or not to cancel the form (returns to + * viewtopic or viewforum depending on if the user + * is posting a new topic or editing a post) + * @var bool refresh Whether or not to retain previously submitted data + * @var object message_parser The message parser object + * @since 3.1.2-RC1 + */ + $vars = array( + 'post_data', + 'mode', + 'post_id', + 'topic_id', + 'forum_id', + 'submit', + 'preview', + 'save', + 'load', + 'cancel', + 'refresh', + 'message_parser', + ); + extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars))); + // Grab md5 'checksum' of new message $message_md5 = md5($message_parser->message); @@ -1727,7 +1763,6 @@ $page_data = array( * @var bool preview Whether or not the post is being previewed * @var bool save Whether or not a draft is being saved * @var bool load Whether or not a draft is being loaded -* @var bool delete Whether or not the post is being deleted * @var bool cancel Whether or not to cancel the form (returns to * viewtopic or viewforum depending on if the user * is posting a new topic or editing a post) @@ -1744,6 +1779,7 @@ $page_data = array( * s_topic_icons, form_enctype, s_action, s_hidden_fields, * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser +* @change 3.1.2-RC1 Removed 'delete' var as it does not exist */ $vars = array( 'post_data', @@ -1761,7 +1797,6 @@ $vars = array( 'preview', 'save', 'load', - 'delete', 'cancel', 'refresh', 'error', -- cgit v1.2.1 From 96a734b012cdff268f699b7468af117a013e7967 Mon Sep 17 00:00:00 2001 From: brunoais Date: Wed, 3 Dec 2014 17:34:35 +0000 Subject: [ticket/13158] Allow adding extra auth checks when the user is posting PHPBB3-13158 --- phpBB/posting.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index dda7455845..10c3b696e6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -344,6 +344,48 @@ switch ($mode) } break; } +/** +* This event allows you to do extra auth checks and verify if the user +* has the required permissions +* +* Extensions should only change the error and is_authed variables. +* +* @event core.modify_posting_auth +* @var int post_id ID of the post +* @var int topic_id ID of the topic +* @var int forum_id ID of the forum +* @var int draft_id ID of the draft +* @var int lastclick Timestamp of when the form was last loaded +* @var bool submit Whether or not the form has been submitted +* @var bool preview Whether or not the post is being previewed +* @var bool save Whether or not a draft is being saved +* @var bool load Whether or not a draft is being loaded +* @var bool refresh Whether or not to retain previously submitted data +* @var string mode What action to take if the form has been submitted +* post|reply|quote|edit|delete|bump|smilies|popup +* @var array error Any error strings; a non-empty array aborts +* form submission. +* NOTE: Should be actual language strings, NOT +* language keys. +* @var bool is_authed Does the user have the required permissions? +* @since 3.1.3-RC1 +*/ +$vars = array( + 'post_id', + 'topic_id', + 'forum_id', + 'draft_id', + 'lastclick', + 'submit', + 'preview', + 'save', + 'load', + 'refresh', + 'mode', + 'error', + 'is_authed', +); +extract($phpbb_dispatcher->trigger_event('core.modify_posting_auth', compact($vars))); if (!$is_authed) { -- cgit v1.2.1 From f075fb78f694048a4115b145e59c110a5acffcdb Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 11 Jan 2015 19:29:33 +0100 Subject: [ticket/13490] Allow multibyte characters in edit reason PHPBB3-13490 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 10c3b696e6..ac412c0c73 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1736,7 +1736,7 @@ $page_data = array( 'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '', 'ERROR' => (sizeof($error)) ? implode('
', $error) : '', 'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'], - 'EDIT_REASON' => $request->variable('edit_reason', ''), + 'EDIT_REASON' => $request->variable('edit_reason', '', true), 'SHOW_PANEL' => $request->variable('show_panel', ''), 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"), 'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id") : '', -- cgit v1.2.1 From 53169b1303d3b9be66c6b67ab031060c41a1280f Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Sun, 11 Jan 2015 20:42:42 +0100 Subject: [ticket/13469] Fall back to soft_delete if no permissions for delete PHPBB3-13469 --- phpBB/posting.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 10c3b696e6..695a71140a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -330,14 +330,17 @@ switch ($mode) { $is_authed = true; } - break; + + // no break; case 'soft_delete': - if ($user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) + if (!$is_authed && $user->data['is_registered'] && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $post_data['post_edit_locked'])) { + // Fall back to soft_delete if we have no permissions to delete posts but to soft delete them $is_authed = true; + $mode = 'soft_delete'; } - else + else if (!$is_authed) { // Display the same error message for softdelete we use for delete $mode = 'delete'; -- cgit v1.2.1 From 77c2b2a51dfd429b7bac10d84017e4b2da321e30 Mon Sep 17 00:00:00 2001 From: Richard McGirr Date: Thu, 9 Apr 2015 06:20:04 -0400 Subject: [ticket/13598] Allow topic lock on topic creation PHPBB3-13598 --- phpBB/posting.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index ac412c0c73..118f33def0 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -621,6 +621,11 @@ if ($mode != 'edit') $post_data['enable_urls'] = true; } +if ($mode == 'post') +{ + $post_data['topic_status'] = ($request->is_set_post('lock_topic') && $auth->acl_gets('m_lock', 'f_user_lock', $forum_id)) ? ITEM_LOCKED : ITEM_UNLOCKED; +} + $post_data['enable_magic_url'] = $post_data['drafts'] = false; // User own some drafts? @@ -1334,6 +1339,7 @@ if ($submit || $preview || $refresh) 'message' => $message_parser->message, 'attachment_data' => $message_parser->attachment_data, 'filename_data' => $message_parser->filename_data, + 'topic_status' => $post_data['topic_status'], 'topic_visibility' => (isset($post_data['topic_visibility'])) ? $post_data['topic_visibility'] : false, 'post_visibility' => (isset($post_data['post_visibility'])) ? $post_data['post_visibility'] : false, @@ -1758,7 +1764,7 @@ $page_data = array( 'S_SIGNATURE_CHECKED' => ($sig_checked) ? ' checked="checked"' : '', 'S_NOTIFY_ALLOWED' => (!$user->data['is_registered'] || ($mode == 'edit' && $user->data['user_id'] != $post_data['poster_id']) || !$config['allow_topic_notify'] || !$config['email_enable']) ? false : true, 'S_NOTIFY_CHECKED' => ($notify_checked) ? ' checked="checked"' : '', - 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, + 'S_LOCK_TOPIC_ALLOWED' => (($mode == 'edit' || $mode == 'reply' || $mode == 'quote' || $mode == 'post') && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && !empty($post_data['topic_poster']) && $user->data['user_id'] == $post_data['topic_poster'] && $post_data['topic_status'] == ITEM_UNLOCKED))) ? true : false, 'S_LOCK_TOPIC_CHECKED' => ($lock_topic_checked) ? ' checked="checked"' : '', 'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false, 'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '', -- cgit v1.2.1 From 34602037dcbd357985baa8416dc748f3dd570ec3 Mon Sep 17 00:00:00 2001 From: javiexin Date: Wed, 29 Apr 2015 20:15:20 +0200 Subject: [ticket/13795] Modify core event in posting to include poll data Modified the core.posting_modify_template_vars event in posting.php to extend the content of the page_data array to include poll data. That required moving the event and merging the new set of template vars. PHPBB3-13795 --- phpBB/posting.php | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index ac412c0c73..20cb14b4b5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1784,6 +1784,30 @@ $page_data = array( 'S_IN_POSTING' => true, ); +// Build custom bbcodes array +display_custom_bbcodes(); + +// Poll entry +if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) + && $auth->acl_get('f_poll', $forum_id)) +{ + $page_data = array_merge($page_data, array( + 'S_SHOW_POLL_BOX' => true, + 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), + 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), + 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, + + 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), + + 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', + 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', + 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', + 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, + 'POLL_LENGTH' => $post_data['poll_length'], + ) + ); +} + /** * This event allows you to modify template variables for the posting screen * @@ -1822,6 +1846,7 @@ $page_data = array( * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser * @change 3.1.2-RC1 Removed 'delete' var as it does not exist +* @change 3.1.4-RC1 Added poll variables to the page_data array */ $vars = array( 'post_data', @@ -1850,29 +1875,6 @@ extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', co // Start assigning vars for main posting page ... $template->assign_vars($page_data); -// Build custom bbcodes array -display_custom_bbcodes(); - -// Poll entry -if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) -{ - $template->assign_vars(array( - 'S_SHOW_POLL_BOX' => true, - 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), - 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - - 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), - - 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', - 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', - 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', - 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, - 'POLL_LENGTH' => $post_data['poll_length']) - ); -} - // Show attachment box for adding attachments if true $allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); -- cgit v1.2.1 From 6e0d12094abed711e4c50d0d9d62de9d425673fd Mon Sep 17 00:00:00 2001 From: javiexin Date: Mon, 4 May 2015 20:34:54 +0200 Subject: [ticket/13795] Modify core event in posting to include poll data Modified the core.posting_modify_template_vars event in posting.php to extend the content of the page_data array to include poll data. That required moving the event and merging the new set of template vars. Also include the poll variable in the parameter list for event core.posting_modify_submission_errors, as it was missing, and any modification here on post_data for poll related data is silently ignored. PHPBB3-13795 --- phpBB/posting.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 20cb14b4b5..1ee4e0c22a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1238,6 +1238,7 @@ if ($submit || $preview || $refresh) * * @event core.posting_modify_submission_errors * @var array post_data Array with post data + * @var array poll Array with poll data from post (must be used instead of the post_data equivalent) * @var string mode What action to take if the form is submitted * post|reply|quote|edit|delete|bump|smilies|popup * @var string page_title Title of the mode page @@ -1251,6 +1252,7 @@ if ($submit || $preview || $refresh) */ $vars = array( 'post_data', + 'poll', 'mode', 'page_title', 'post_id', -- cgit v1.2.1 From e80bb565ce3cecbb30880e626afd614a83292616 Mon Sep 17 00:00:00 2001 From: javiexin Date: Thu, 28 May 2015 14:39:22 +0200 Subject: [ticket/13795] Modify core event in posting to include poll data Modified the core.posting_modify_template_vars event in posting.php to extend the content of the page_data array to include poll data. That required moving the event and merging the new set of template vars. Also include the poll variable in the parameter list for event core.posting_modify_submission_errors, as it was missing, and any modification here on post_data for poll related data is silently ignored. Added correct @change tags to both events. PHPBB3-13795 --- phpBB/posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 1ee4e0c22a..2d44e0b6e7 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1249,6 +1249,7 @@ if ($submit || $preview || $refresh) * @var array error Any error strings; a non-empty array aborts form submission. * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 + * @change 3.1.5-RC1 Added poll array to the event */ $vars = array( 'post_data', @@ -1848,7 +1849,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser * @change 3.1.2-RC1 Removed 'delete' var as it does not exist -* @change 3.1.4-RC1 Added poll variables to the page_data array +* @change 3.1.5-RC1 Added poll variables to the page_data array */ $vars = array( 'post_data', -- cgit v1.2.1 From 2c6369c5d90134b761ffd1da86401deff571f636 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Mon, 8 Jun 2015 16:43:10 +0200 Subject: [ticket/13833] Prevent flooding if type=submit doesn't exist PHPBB3-13833 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 964b0f1f8b..13de8d5fd2 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -32,7 +32,6 @@ $forum_id = request_var('f', 0); $draft_id = request_var('d', 0); $lastclick = request_var('lastclick', 0); -$submit = (isset($_POST['post'])) ? true : false; $preview = (isset($_POST['preview'])) ? true : false; $save = (isset($_POST['save'])) ? true : false; $load = (isset($_POST['load'])) ? true : false; @@ -40,6 +39,7 @@ $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; $refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$submit = isset($_POST['post']) && !$refresh && !$preview; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); -- cgit v1.2.1 From 817db2f13526842e04aeabe4fcd6d809dce2d0a2 Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Sat, 30 May 2015 01:02:12 +0200 Subject: [ticket/13880] Automatically remove quotes that are nested too deep PHPBB3-13880 --- phpBB/posting.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 651f674ef9..d994811a91 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1579,11 +1579,21 @@ if (!sizeof($error) && $preview) } } +// Remove quotes that would become nested too deep before decoding the text +$generate_quote = ($mode == 'quote' && !$submit && !$preview && !$refresh); +if ($generate_quote && $config['max_quote_depth'] > 0) +{ + $tmp_bbcode_uid = $message_parser->bbcode_uid; + $message_parser->bbcode_uid = $post_data['bbcode_uid']; + $message_parser->remove_nested_quotes($config['max_quote_depth'] - 1); + $message_parser->bbcode_uid = $tmp_bbcode_uid; +} + // Decode text for message display $post_data['bbcode_uid'] = ($mode == 'quote' && !$preview && !$refresh && !sizeof($error)) ? $post_data['bbcode_uid'] : $message_parser->bbcode_uid; $message_parser->decode_message($post_data['bbcode_uid']); -if ($mode == 'quote' && !$submit && !$preview && !$refresh) +if ($generate_quote) { if ($config['allow_bbcode']) { -- cgit v1.2.1 From 6f189636363d7ab2e373932d392ec4818b10c84a Mon Sep 17 00:00:00 2001 From: Marco Kubuntu Date: Sat, 27 Jun 2015 12:38:31 +0200 Subject: [ticket/13971] Add draft_id var to event core.posting_modify_template_vars Added draft_id to the core.posting_modify_template_vars event in posting.php, to provide the ability to use the 'checked' draft_id in extensions, in addition to the 'raw' draft_id provided in earlier events in posting.php PHPBB3-13971 --- phpBB/posting.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 651f674ef9..4b7ae341c3 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1841,6 +1841,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ * @var int post_id ID of the post * @var int topic_id ID of the topic * @var int forum_id ID of the forum +* @var int draft_id ID of the draft * @var bool submit Whether or not the form has been submitted * @var bool preview Whether or not the post is being previewed * @var bool save Whether or not a draft is being saved @@ -1863,6 +1864,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ * delete, cancel, refresh, error, page_data, message_parser * @change 3.1.2-RC1 Removed 'delete' var as it does not exist * @change 3.1.5-RC1 Added poll variables to the page_data array +* @change 3.1.6-RC1 Added 'draft_id' var */ $vars = array( 'post_data', @@ -1876,6 +1878,7 @@ $vars = array( 'post_id', 'topic_id', 'forum_id', + 'draft_id', 'submit', 'preview', 'save', -- cgit v1.2.1 From 18a08e1af17ff3622312324f5ddca66b79b30e98 Mon Sep 17 00:00:00 2001 From: RMcGirr83 Date: Wed, 1 Jul 2015 11:23:56 -0400 Subject: [ticket/13579] This commit corrects the regression. PHPBB3-13759 --- phpBB/posting.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f0446cf2db..4fe5ac1da2 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1322,7 +1322,6 @@ if ($submit || $preview || $refresh) 'enable_urls' => (bool) $post_data['enable_urls'], 'enable_indexing' => (bool) $post_data['enable_indexing'], 'message_md5' => (string) $message_md5, - 'post_time' => (isset($post_data['post_time'])) ? (int) $post_data['post_time'] : $current_time, 'post_checksum' => (isset($post_data['post_checksum'])) ? (string) $post_data['post_checksum'] : '', 'post_edit_reason' => $post_data['post_edit_reason'], 'post_edit_user' => ($mode == 'edit') ? $user->data['user_id'] : ((isset($post_data['post_edit_user'])) ? (int) $post_data['post_edit_user'] : 0), -- cgit v1.2.1 From 8b981f9ccd12fe4fa91fa242014c525cd1fcb6ec Mon Sep 17 00:00:00 2001 From: Richard McGirr Date: Sun, 19 Jul 2015 06:25:59 -0400 Subject: [ticket/13815] Event parameters in posting have no effect PHPBB3-13815 --- phpBB/posting.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index bd36dc5db7..2bd3a1a1d2 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1379,10 +1379,9 @@ if ($submit || $preview || $refresh) * @var string post_author_name Author name for guest posts * @var bool update_message Boolean if the post message was changed * @var bool update_subject Boolean if the post subject was changed - * @var bool submit Whether or not the form has been submitted - * @var array error Any error strings; a non-empty array aborts form submission. * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 + * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event */ $vars = array( 'post_data', @@ -1396,8 +1395,6 @@ if ($submit || $preview || $refresh) 'post_author_name', 'update_message', 'update_subject', - 'submit', - 'error', ); extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_before', compact($vars))); @@ -1421,10 +1418,9 @@ if ($submit || $preview || $refresh) * @var bool update_message Boolean if the post message was changed * @var bool update_subject Boolean if the post subject was changed * @var string redirect_url URL the user is going to be redirected to - * @var bool submit Whether or not the form has been submitted - * @var array error Any error strings; a non-empty array aborts form submission. * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 + * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event */ $vars = array( 'post_data', @@ -1439,8 +1435,6 @@ if ($submit || $preview || $refresh) 'update_message', 'update_subject', 'redirect_url', - 'submit', - 'error', ); extract($phpbb_dispatcher->trigger_event('core.posting_modify_submit_post_after', compact($vars))); -- cgit v1.2.1 From a49a3091f9de5c8f872b976e22d243db1d0fb1ad Mon Sep 17 00:00:00 2001 From: Richard McGirr Date: Wed, 14 Oct 2015 05:59:01 -0400 Subject: [ticket/13851] Fix ignore flood limit check PHPBB3-13851 --- phpBB/posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 2bd3a1a1d2..5fcd427b2b 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1027,7 +1027,8 @@ if ($submit || $preview || $refresh) $message_parser->bbcode_bitfield = $post_data['bbcode_bitfield']; } - if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$auth->acl_get('f_ignoreflood', $forum_id)) + $ignore_flood = $auth->acl_get('u_ignoreflood') ? true : $auth->acl_get('f_ignoreflood', $forum_id); + if ($mode != 'edit' && !$preview && !$refresh && $config['flood_interval'] && !$ignore_flood) { // Flood check $last_post_time = 0; -- cgit v1.2.1 From 15157eed61e3aa50910ce557ee4e0a0f329dcc36 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 14 Jan 2016 23:15:36 +0100 Subject: [ticket/14411] Permanently delete post if delete_permanent is set PHPBB3-14411 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 5fcd427b2b..a7df1a018e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -481,7 +481,7 @@ if ($mode == 'delete' || $mode == 'soft_delete') } $delete_reason = $request->variable('delete_reason', '', true); - phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete'), $delete_reason); + phpbb_handle_post_delete($forum_id, $topic_id, $post_id, $post_data, ($mode == 'soft_delete' && !$request->is_set_post('delete_permanent')), $delete_reason); return; } -- cgit v1.2.1 From 3d7d0c40b8e7f1897fc4a323d4edee6db2a7f452 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 6 Mar 2016 11:22:05 +0100 Subject: [ticket/14437] Make sure attachments array is properly ordered before processing PHPBB3-14437 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index a7df1a018e..263809e998 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -599,7 +599,7 @@ if ($post_data['post_attachment'] && !$submit && !$refresh && !$preview && $mode WHERE post_msg_id = $post_id AND in_message = 0 AND is_orphan = 0 - ORDER BY filetime DESC"; + ORDER BY attach_id DESC"; $result = $db->sql_query($sql); $message_parser->attachment_data = array_merge($message_parser->attachment_data, $db->sql_fetchrowset($result)); $db->sql_freeresult($result); -- cgit v1.2.1 From 0ca32c41b5f82f333d8deaf0f51f677d2a5e2388 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 27 Mar 2016 19:09:06 +0700 Subject: [ticket/14559] Remove attachment BBCode tags from the quoted message PHPBB3-14559 --- phpBB/posting.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 263809e998..653740ae1c 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1589,6 +1589,9 @@ $message_parser->decode_message($post_data['bbcode_uid']); if ($generate_quote) { + // Remove attachment bbcode tags from the quoted message to avoid mixing with the new post attachments if any + $message_parser->message = preg_replace('#\[attachment=([0-9]+)\](.*?)\[\/attachment\]#uis', '\\2', $message_parser->message); + if ($config['allow_bbcode']) { $message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n"; -- cgit v1.2.1 From c016e09ca4d7ebe9488619f899c766a9969d28d1 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Thu, 11 Aug 2016 14:54:36 +0200 Subject: [ticket/12925] Pluralize permanent delete checkbox label PHPBB3-12925 --- phpBB/posting.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 653740ae1c..f1e8452305 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1741,6 +1741,7 @@ $page_data = array( 'L_POST_A' => $page_title, 'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'], 'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']), + 'L_DELETE_POST_PERMANENTLY' => $user->lang('DELETE_POST_PERMANENTLY', 1), 'FORUM_NAME' => $post_data['forum_name'], 'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '', -- cgit v1.2.1 From 64178b40b80c2991197a73cd0b7f6cf6cbd5bf9c Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Fri, 2 Sep 2016 11:41:43 +0200 Subject: [ticket/14747] Add post_data to core.modify_posting_auth PHPBB3-14747 --- phpBB/posting.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index f1e8452305..db580d926b 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -371,7 +371,9 @@ switch ($mode) * NOTE: Should be actual language strings, NOT * language keys. * @var bool is_authed Does the user have the required permissions? +* @var array post_data All post data from database * @since 3.1.3-RC1 +* @changed 3.1.10-RC1 Added post_data */ $vars = array( 'post_id', @@ -387,6 +389,7 @@ $vars = array( 'mode', 'error', 'is_authed', + 'post_data', ); extract($phpbb_dispatcher->trigger_event('core.modify_posting_auth', compact($vars))); -- cgit v1.2.1 From c2836725f9692e907d77edce7c609142661af6c1 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Sun, 20 Nov 2016 17:58:59 +0100 Subject: [ticket/13429] Replace @changed with @change in event docblocks PHPBB3-13429 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index db580d926b..6f8225c198 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -373,7 +373,7 @@ switch ($mode) * @var bool is_authed Does the user have the required permissions? * @var array post_data All post data from database * @since 3.1.3-RC1 -* @changed 3.1.10-RC1 Added post_data +* @change 3.1.10-RC1 Added post_data */ $vars = array( 'post_id', @@ -1385,7 +1385,7 @@ if ($submit || $preview || $refresh) * @var bool update_subject Boolean if the post subject was changed * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 - * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event + * @change 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event */ $vars = array( 'post_data', @@ -1424,7 +1424,7 @@ if ($submit || $preview || $refresh) * @var string redirect_url URL the user is going to be redirected to * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 - * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event + * @change 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event */ $vars = array( 'post_data', -- cgit v1.2.1 From fbcbd79d79c5510d3943e0e1068801a8ea62146d Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Wed, 21 Dec 2016 14:41:53 +0100 Subject: [ticket/14929] Add error to core.posting_modify_message_text PHPBB3-14929 --- phpBB/posting.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index db580d926b..90e52b3de8 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -941,7 +941,9 @@ if ($submit || $preview || $refresh) * is posting a new topic or editing a post) * @var bool refresh Whether or not to retain previously submitted data * @var object message_parser The message parser object + * @var array error Array of errors * @since 3.1.2-RC1 + * @changed 3.1.11-RC1 Added error */ $vars = array( 'post_data', @@ -956,6 +958,7 @@ if ($submit || $preview || $refresh) 'cancel', 'refresh', 'message_parser', + 'error', ); extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars))); -- cgit v1.2.1 From 779758f2195f87868da3694b5ffd00adee1be0b3 Mon Sep 17 00:00:00 2001 From: Jakub Senko Date: Sun, 4 Dec 2016 17:30:42 +0100 Subject: [ticket/13429] Replace @change with @changed PHPBB3-13429 --- phpBB/posting.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 6f8225c198..18d17b8006 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -84,7 +84,7 @@ $current_time = time(); * NOTE: Should be actual language strings, NOT * language keys. * @since 3.1.0-a1 -* @change 3.1.2-RC1 Removed 'delete' var as it does not exist +* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist */ $vars = array( 'post_id', @@ -373,7 +373,7 @@ switch ($mode) * @var bool is_authed Does the user have the required permissions? * @var array post_data All post data from database * @since 3.1.3-RC1 -* @change 3.1.10-RC1 Added post_data +* @changed 3.1.10-RC1 Added post_data */ $vars = array( 'post_id', @@ -1261,7 +1261,7 @@ if ($submit || $preview || $refresh) * @var array error Any error strings; a non-empty array aborts form submission. * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 - * @change 3.1.5-RC1 Added poll array to the event + * @changed 3.1.5-RC1 Added poll array to the event */ $vars = array( 'post_data', @@ -1385,7 +1385,7 @@ if ($submit || $preview || $refresh) * @var bool update_subject Boolean if the post subject was changed * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 - * @change 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event + * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event */ $vars = array( 'post_data', @@ -1424,7 +1424,7 @@ if ($submit || $preview || $refresh) * @var string redirect_url URL the user is going to be redirected to * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 - * @change 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event + * @changed 3.1.6-RC1 remove submit and error from event Submit and Error are checked previously prior to running event */ $vars = array( 'post_data', @@ -1869,13 +1869,13 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ * posting page via $template->assign_vars() * @var object message_parser The message parser object * @since 3.1.0-a1 -* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, +* @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title, * s_topic_icons, form_enctype, s_action, s_hidden_fields, * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser -* @change 3.1.2-RC1 Removed 'delete' var as it does not exist -* @change 3.1.5-RC1 Added poll variables to the page_data array -* @change 3.1.6-RC1 Added 'draft_id' var +* @changed 3.1.2-RC1 Removed 'delete' var as it does not exist +* @changed 3.1.5-RC1 Added poll variables to the page_data array +* @changed 3.1.6-RC1 Added 'draft_id' var */ $vars = array( 'post_data', -- cgit v1.2.1 From 7a3e55bdb3725665b229f47ff6a5778a6f259969 Mon Sep 17 00:00:00 2001 From: RMcGirr83 Date: Wed, 24 May 2017 12:58:25 -0400 Subject: [ticket/15237] Fix unguarded includes to functions_user https://tracker.phpbb.com/browse/PHPBB3-15237 PHPBB3-15237 --- phpBB/posting.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 4651a1fd2c..3ab78b5db5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1066,7 +1066,10 @@ if ($submit || $preview || $refresh) // Validate username if (($post_data['username'] && !$user->data['is_registered']) || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS && $post_data['username'] && $post_data['post_username'] && $post_data['post_username'] != $post_data['username'])) { - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + if (!function_exists('validate_username')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } $user->add_lang('ucp'); -- cgit v1.2.1 From ca5243810f313c5438e2c778cdaecfbcb375e8eb Mon Sep 17 00:00:00 2001 From: javiexin Date: Mon, 19 Jun 2017 23:29:54 +0200 Subject: [ticket/15248] Make use of event parameters of core.modify_posting_auth Fixes is_authed and error not behaving as expected by extensions. PHPBB-15248 --- phpBB/posting.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'phpBB/posting.php') diff --git a/phpBB/posting.php b/phpBB/posting.php index 4651a1fd2c..d0fd2b60e8 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -340,11 +340,6 @@ switch ($mode) $is_authed = true; $mode = 'soft_delete'; } - else if (!$is_authed) - { - // Display the same error message for softdelete we use for delete - $mode = 'delete'; - } break; } /** @@ -393,13 +388,13 @@ $vars = array( ); extract($phpbb_dispatcher->trigger_event('core.modify_posting_auth', compact($vars))); -if (!$is_authed) +if (!$is_authed || !empty($error)) { - $check_auth = ($mode == 'quote') ? 'reply' : $mode; + $check_auth = ($mode == 'quote') ? 'reply' : (($mode == 'soft_delete') ? 'delete' : $mode); if ($user->data['is_registered']) { - trigger_error('USER_CANNOT_' . strtoupper($check_auth)); + trigger_error(empty($error) ? 'USER_CANNOT_' . strtoupper($check_auth) : implode('
', $error)); } $message = $user->lang['LOGIN_EXPLAIN_' . strtoupper($mode)]; -- cgit v1.2.1