From b5544b2f471ce4c93b08d19919ab062725545ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sat, 3 Jan 2015 11:39:29 +0100 Subject: [ticket/13450] Type-hint return value of $phpbb_container->get() PHPBB3-13450 --- phpBB/includes/functions_posting.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 22ade15b48..199a564210 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -27,8 +27,9 @@ function generate_smilies($mode, $forum_id) global $db, $user, $config, $template, $phpbb_dispatcher; global $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_path_helper; - $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id); + /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); + $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id); $start = request_var('start', 0); if ($mode == 'window') @@ -1039,6 +1040,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id global $user, $auth, $db, $template, $bbcode, $cache; global $config, $phpbb_root_path, $phpEx, $phpbb_container; + /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $sql_sort = ($mode == 'post_review') ? 'ASC' : 'DESC'; @@ -1276,6 +1278,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ $db->sql_freeresult($result); } + /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); // (Soft) delete the post @@ -2094,6 +2097,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $is_starter = ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); + /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); $phpbb_content_visibility->set_post_visibility($post_visibility, $data['post_id'], $data['topic_id'], $data['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); } @@ -2272,6 +2276,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'post_subject' => $subject, )); + /* @var $phpbb_notifications \phpbb\notification\manager */ $phpbb_notifications = $phpbb_container->get('notification_manager'); if ($post_visibility == ITEM_APPROVED) -- cgit v1.2.1 From 7fc586080bf5e7b6e90dcf44526200d7c9356d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Mon, 5 Jan 2015 22:21:31 +0100 Subject: [ticket/13468] Update calls to `add_log()` PHPBB3-13468 --- phpBB/includes/functions_posting.php | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 199a564210..9f94064a8f 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1492,7 +1492,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ */ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) { - global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher; + global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log; /** * Modify the data for post submitting @@ -1665,7 +1665,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($user->data['user_id'] != $poster_id) { $log_subject = ($subject) ? $subject : $data['topic_title']; - add_log('mod', $data['forum_id'], $data['topic_id'], 'LOG_POST_EDITED', $log_subject, (!empty($username)) ? $username : $user->lang['GUEST'], $data['post_edit_reason']); + $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array( + 'forum_id' => $data['forum_id'], + 'topic_id' => $data['topic_id'], + $log_subject, + (!empty($username)) ? $username : $user->lang['GUEST'], + $data['post_edit_reason'] + )); } if (!isset($sql_data[POSTS_TABLE]['sql'])) @@ -2455,7 +2461,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u */ function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false) { - global $config, $db, $user, $phpEx, $phpbb_root_path; + global $config, $db, $user, $phpEx, $phpbb_root_path, $phpbb_log; if ($bump_time === false) { @@ -2534,7 +2540,11 @@ function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false) update_forum_tracking_info($forum_id, $forum_last_post_time, $f_mark_time, false); } - add_log('mod', $forum_id, $topic_id, 'LOG_BUMP_TOPIC', $post_data['topic_title']); + $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_BUMP_TOPIC', false, array( + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, + $post_data['topic_title'] + )); $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']}"; @@ -2572,7 +2582,7 @@ function phpbb_upload_popup($forum_style = 0) function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_soft = false, $delete_reason = '') { global $user, $auth, $config, $request; - global $phpbb_root_path, $phpEx; + global $phpbb_root_path, $phpEx, $phpbb_log; $perm_check = ($is_soft) ? 'softdelete' : 'delete'; @@ -2607,14 +2617,26 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $ 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, $delete_reason); + $phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), false, array( + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, + $post_data['topic_title'], + $post_username, + $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, $delete_reason); + $phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), false, array( + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, + $post_data['post_subject'], + $post_username, + $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 a633f3484c63fe4bd70df548b3ae4bd569bdef46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 11 Jan 2015 18:01:52 +0100 Subject: [ticket/13496] Update calls to `set_config_count()` PHPBB3-13496 --- phpBB/includes/functions_posting.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 9f94064a8f..10c0fc90c2 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1909,9 +1909,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { if ($post_mode == 'post') { - set_config_count('num_topics', 1, true); + $config->increment('num_topics', 1, false); } - set_config_count('num_posts', 1, true); + $config->increment('num_posts', 1, false); $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; @@ -2084,8 +2084,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($space_taken && $files_added) { - set_config_count('upload_dir_size', $space_taken, true); - set_config_count('num_files', $files_added, true); + $config->increment('upload_dir_size', $space_taken, false); + $config->increment('num_files', $files_added, false); } } -- cgit v1.2.1 From f6e06da4c68917dafb057bf7fe19f884a3e148c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gae=CC=88tan=20Muller?= Date: Sun, 4 Jan 2015 20:41:04 +0100 Subject: [ticket/13455] Update calls to `request_var()` PHPBB3-13455 --- phpBB/includes/functions_posting.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 38d4df703f..b93a89e773 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -24,13 +24,13 @@ if (!defined('IN_PHPBB')) */ function generate_smilies($mode, $forum_id) { - global $db, $user, $config, $template, $phpbb_dispatcher; + global $db, $user, $config, $template, $phpbb_dispatcher, $request; global $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_path_helper; /* @var $pagination \phpbb\pagination */ $pagination = $phpbb_container->get('pagination'); $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id); - $start = request_var('start', 0); + $start = $request->variable('start', 0); if ($mode == 'window') { @@ -1520,7 +1520,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ */ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) { - global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log; + global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; /** * Modify the data for post submitting @@ -2207,7 +2207,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $db->sql_transaction('commit'); // Delete draft if post was loaded... - $draft_id = request_var('draft_loaded', 0); + $draft_id = $request->variable('draft_loaded', 0); if ($draft_id) { $sql = 'DELETE FROM ' . DRAFTS_TABLE . " -- cgit v1.2.1 From 4bdef6fd21a5dcab455b0cd1ee2652de606929c3 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 12 Mar 2015 00:25:00 +0100 Subject: [ticket/13697] Moving filesystem related functions to filesystem service * Moving filesystem service to \phpbb\filesystem namespace * Wraping Symfony's Filesystem component * Moving filesystem related functions from includes/functions.php into \phpbb\filesystem\filesystem Functions moved (and deprecated): - phpbb_chmod - phpbb_is_writable - phpbb_is_absolute - phpbb_own_realpath - phpbb_realpath * Adding interface for filesystem service PHPBB3-13697 --- phpBB/includes/functions_posting.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 9c6ddffe9f..4233395574 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -407,14 +407,14 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null) { global $auth, $user, $config, $db, $cache; - global $phpbb_root_path, $phpEx, $phpbb_dispatcher; + global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_filesystem; $filedata = array( 'error' => array() ); include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx); - $upload = new fileupload(); + $upload = new fileupload($phpbb_filesystem); if ($config['check_attachment_content'] && isset($config['mime_triggers'])) { @@ -668,7 +668,7 @@ function get_supported_image_types($type = false) */ function create_thumbnail($source, $destination, $mimetype) { - global $config; + global $config, $phpbb_filesystem; $min_filesize = (int) $config['img_min_thumb_filesize']; $img_filesize = (file_exists($source)) ? @filesize($source) : false; @@ -820,7 +820,14 @@ function create_thumbnail($source, $destination, $mimetype) return false; } - phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE); + try + { + $this->filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE); + } + catch (\phpbb\filesystem\exception\filesystem_exception $e) + { + // Do nothing + } return true; } -- cgit v1.2.1 From 571f6dc9b53068ac655924616022e92d0e1c1ce9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 8 May 2015 11:05:01 +0200 Subject: [ticket/13825] Correctly call phpbb_filesystem in create_thumbnail PHPBB3-13825 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4233395574..fcab667cb2 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -822,7 +822,7 @@ function create_thumbnail($source, $destination, $mimetype) try { - $this->filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE); + $phpbb_filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE); } catch (\phpbb\filesystem\exception\filesystem_exception $e) { -- cgit v1.2.1 From 06936bda05a48e5b6e20d7c0b0979cf7fc1a29ae Mon Sep 17 00:00:00 2001 From: JoshyPHP Date: Mon, 22 Jun 2015 04:00:55 +0200 Subject: [ticket/10620] Added enhanced quotes in topic review Added support for enhanced quotes in topic_review's quote button. NOTE: the UI doesn't appear to be testable via PhantomJS. PHPBB3-10620 --- phpBB/includes/functions_posting.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index a1ace42c32..9109c48ab6 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1193,6 +1193,8 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id 'MESSAGE' => $message, 'DECODED_MESSAGE' => $decoded_message, 'POST_ID' => $row['post_id'], + 'POST_TIME' => $row['post_time'], + 'USER_ID' => $row['user_id'], 'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_id'], 'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=post_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'POSTER_QUOTE' => ($show_quote_button && $auth->acl_get('f_reply', $forum_id)) ? addslashes(get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username'])) : '', -- cgit v1.2.1 From 7d31232846e29311e5b76bf32f41f64da7985a79 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Wed, 16 Jul 2014 18:31:12 +0200 Subject: [ticket/8708] Apply permission 'f_announce_global' PHPBB3-8708 --- phpBB/includes/functions_posting.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 9109c48ab6..e4520d7f03 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -337,18 +337,15 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) $toggle = false; $topic_types = array( - 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), - 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'), - 'global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL') + 'sticky' => array('const' => POST_STICKY, 'lang' => 'POST_STICKY'), + 'announce' => array('const' => POST_ANNOUNCE, 'lang' => 'POST_ANNOUNCEMENT'), + 'announce_global' => array('const' => POST_GLOBAL, 'lang' => 'POST_GLOBAL') ); $topic_type_array = array(); foreach ($topic_types as $auth_key => $topic_value) { - // We do not have a special post global announcement permission - $auth_key = ($auth_key == 'global') ? 'announce' : $auth_key; - if ($auth->acl_get('f_' . $auth_key, $forum_id)) { $toggle = true; @@ -378,8 +375,8 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) $template->assign_vars(array( 'S_TOPIC_TYPE_STICKY' => ($auth->acl_get('f_sticky', $forum_id)), - 'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_get('f_announce', $forum_id))) - ); + 'S_TOPIC_TYPE_ANNOUNCE' => ($auth->acl_gets('f_announce', 'f_announce_global', $forum_id)), + )); } return $toggle; -- cgit v1.2.1 From 51600b8f181b20d88c42ea2fb6893200e4e955e7 Mon Sep 17 00:00:00 2001 From: Zoddo Date: Sun, 30 Aug 2015 16:49:25 +0200 Subject: [ticket/9485] Add post_id to relevant $phpbb_log->add() PHPBB3-9485 --- phpBB/includes/functions_posting.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index e4520d7f03..0f42f1950a 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1700,6 +1700,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array( 'forum_id' => $data['forum_id'], 'topic_id' => $data['topic_id'], + 'post_id' => $data['post_id'], $log_subject, (!empty($username)) ? $username : $user->lang['GUEST'], $data['post_edit_reason'] @@ -2666,6 +2667,7 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $ $phpbb_log->add('mod', $user->data['user_id'], $user->ip, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), false, array( 'forum_id' => $forum_id, 'topic_id' => $topic_id, + 'post_id' => $post_id, $post_data['post_subject'], $post_username, $delete_reason -- cgit v1.2.1 From 0cbb713cc2a6249cb12507db7d0fa78ce8663ae6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 31 May 2015 14:47:57 +0200 Subject: [ticket/13904] Fix uploading for use with new filespec class PHPBB3-13904 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index e4520d7f03..e91f8bb56d 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -435,7 +435,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage $file = ($local) ? $upload->local_upload($local_storage, $local_filedata, $mimetype_guesser) : $upload->form_upload($form_name, $mimetype_guesser, $plupload); - if ($file->init_error) + if ($file->init_error()) { $filedata['post_attach'] = false; return $filedata; -- cgit v1.2.1 From 1af6f052d80e693d289258d490c1187a064093b9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Aug 2015 09:03:55 +0200 Subject: [ticket/13904] Load upload class using factory PHPBB3-13904 --- phpBB/includes/functions_posting.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index e91f8bb56d..75ac20a337 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -404,14 +404,14 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null) { global $auth, $user, $config, $db, $cache; - global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_filesystem; + global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container; $filedata = array( 'error' => array() ); include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx); - $upload = new fileupload($phpbb_filesystem); + $upload = $phpbb_container->get('files.upload'); if ($config['check_attachment_content'] && isset($config['mime_triggers'])) { @@ -433,6 +433,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage $extensions = $cache->obtain_attach_extensions((($is_message) ? false : (int) $forum_id)); $upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); + /** @var \phpbb\files\filespec $file */ $file = ($local) ? $upload->local_upload($local_storage, $local_filedata, $mimetype_guesser) : $upload->form_upload($form_name, $mimetype_guesser, $plupload); if ($file->init_error()) -- cgit v1.2.1 From a96e7a8ec6efa483b47dca3395ee2de608cfc675 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 1 Jun 2015 13:57:17 +0200 Subject: [ticket/13904] Get rid of useless parameters and variables PHPBB3-13904 --- phpBB/includes/functions_posting.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 75ac20a337..f625555d49 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -410,7 +410,6 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage 'error' => array() ); - include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx); $upload = $phpbb_container->get('files.upload'); if ($config['check_attachment_content'] && isset($config['mime_triggers'])) @@ -434,7 +433,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage $upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); /** @var \phpbb\files\filespec $file */ - $file = ($local) ? $upload->local_upload($local_storage, $local_filedata, $mimetype_guesser) : $upload->form_upload($form_name, $mimetype_guesser, $plupload); + $file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name, $plupload); if ($file->init_error()) { -- cgit v1.2.1 From 11b2c938c6c3a6a14465f04ed356fbd013276143 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Tue, 14 Jul 2015 16:15:39 +0200 Subject: [ticket/13904] Move form_upload to its own class and define type classes PHPBB3-13904 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f625555d49..4627ff0a9c 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -433,7 +433,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage $upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); /** @var \phpbb\files\filespec $file */ - $file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name, $plupload); + $file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->handle_upload('form', $form_name); if ($file->init_error()) { -- cgit v1.2.1 From adcc901af181b6727dd7af89a3926c9923a58471 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 15 Jul 2015 16:08:20 +0200 Subject: [ticket/13904] Fix minor issues and move local_upload to its own class PHPBB3-13904 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4627ff0a9c..378d14d14d 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -433,7 +433,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage $upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); /** @var \phpbb\files\filespec $file */ - $file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->handle_upload('form', $form_name); + $file = ($local) ? $upload->handle_upload('local', $local_storage, $local_filedata) : $upload->handle_upload('form', $form_name); if ($file->init_error()) { -- cgit v1.2.1 From 40e614f56436447dffd272351e23b79c2da9fa3f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 9 Sep 2015 12:58:22 +0200 Subject: [ticket/13904] Fix tests after changes to factory PHPBB3-13904 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 378d14d14d..cd7c9a82f7 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -433,7 +433,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage $upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); /** @var \phpbb\files\filespec $file */ - $file = ($local) ? $upload->handle_upload('local', $local_storage, $local_filedata) : $upload->handle_upload('form', $form_name); + $file = ($local) ? $upload->handle_upload('files.types.local', $local_storage, $local_filedata) : $upload->handle_upload('files.types.form', $form_name); if ($file->init_error()) { -- cgit v1.2.1 From e50718008a44953181e133de1e37304ed6a5994f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 19 Sep 2015 16:39:17 +0200 Subject: [ticket/14168] Add attachment upload class PHPBB3-14168 --- phpBB/includes/functions_posting.php | 176 ++--------------------------------- 1 file changed, 9 insertions(+), 167 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 8b17dba534..d4923de60c 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -391,183 +391,25 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) * Upload Attachment - filedata is generated here * Uses upload class * +* @deprecated 3.2.0-a1 (To be removed: 3.4.0) +* * @param string $form_name The form name of the file upload input * @param int $forum_id The id of the forum * @param bool $local Whether the file is local or not * @param string $local_storage The path to the local file * @param bool $is_message Whether it is a PM or not -* @param \filespec $local_filedata A filespec object created for the local file -* @param \phpbb\mimetype\guesser $mimetype_guesser The mimetype guesser object if used -* @param \phpbb\plupload\plupload $plupload The plupload object if one is being used +* @param array $local_filedata A filespec object created for the local file * -* @return object filespec +* @return \phpbb\files\filespec */ -function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null) +function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false) { - global $auth, $user, $config, $db, $cache; - global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $phpbb_container; - - $filedata = array( - 'error' => array() - ); - - $upload = $phpbb_container->get('files.upload'); - - if ($config['check_attachment_content'] && isset($config['mime_triggers'])) - { - $upload->set_disallowed_content(explode('|', $config['mime_triggers'])); - } - else if (!$config['check_attachment_content']) - { - $upload->set_disallowed_content(array()); - } - - $filedata['post_attach'] = $local || $upload->is_valid($form_name); + global $phpbb_container; - if (!$filedata['post_attach']) - { - $filedata['error'][] = $user->lang['NO_UPLOAD_FORM_FOUND']; - return $filedata; - } - - $extensions = $cache->obtain_attach_extensions((($is_message) ? false : (int) $forum_id)); - $upload->set_allowed_extensions(array_keys($extensions['_allowed_'])); - - /** @var \phpbb\files\filespec $file */ - $file = ($local) ? $upload->handle_upload('files.types.local', $local_storage, $local_filedata) : $upload->handle_upload('files.types.form', $form_name); - - if ($file->init_error()) - { - $filedata['post_attach'] = false; - return $filedata; - } - - // Whether the uploaded file is in the image category - $is_image = (isset($extensions[$file->get('extension')]['display_cat'])) ? $extensions[$file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false; - - if (!$auth->acl_get('a_') && !$auth->acl_get('m_', $forum_id)) - { - // Check Image Size, if it is an image - if ($is_image) - { - $file->upload->set_allowed_dimensions(0, 0, $config['img_max_width'], $config['img_max_height']); - } - - // Admins and mods are allowed to exceed the allowed filesize - if (!empty($extensions[$file->get('extension')]['max_filesize'])) - { - $allowed_filesize = $extensions[$file->get('extension')]['max_filesize']; - } - else - { - $allowed_filesize = ($is_message) ? $config['max_filesize_pm'] : $config['max_filesize']; - } - - $file->upload->set_max_filesize($allowed_filesize); - } - - $file->clean_filename('unique', $user->data['user_id'] . '_'); - - // Are we uploading an image *and* this image being within the image category? - // Only then perform additional image checks. - $file->move_file($config['upload_path'], false, !$is_image); - - // Do we have to create a thumbnail? - $filedata['thumbnail'] = ($is_image && $config['img_create_thumbnail']) ? 1 : 0; - - if (sizeof($file->error)) - { - $file->remove(); - $filedata['error'] = array_merge($filedata['error'], $file->error); - $filedata['post_attach'] = false; - - return $filedata; - } - - // Make sure the image category only holds valid images... - if ($is_image && !$file->is_image()) - { - $file->remove(); - - if ($plupload && $plupload->is_active()) - { - $plupload->emit_error(104, 'ATTACHED_IMAGE_NOT_IMAGE'); - } - - // If this error occurs a user tried to exploit an IE Bug by renaming extensions - // Since the image category is displaying content inline we need to catch this. - trigger_error($user->lang['ATTACHED_IMAGE_NOT_IMAGE']); - } - - $filedata['filesize'] = $file->get('filesize'); - $filedata['mimetype'] = $file->get('mimetype'); - $filedata['extension'] = $file->get('extension'); - $filedata['physical_filename'] = $file->get('realname'); - $filedata['real_filename'] = $file->get('uploadname'); - $filedata['filetime'] = time(); - - /** - * Event to modify uploaded file before submit to the post - * - * @event core.modify_uploaded_file - * @var array filedata Array containing uploaded file data - * @var bool is_image Flag indicating if the file is an image - * @since 3.1.0-RC3 - */ - $vars = array( - 'filedata', - 'is_image', - ); - extract($phpbb_dispatcher->trigger_event('core.modify_uploaded_file', compact($vars))); - - // Check our complete quota - if ($config['attachment_quota']) - { - if ($config['upload_dir_size'] + $file->get('filesize') > $config['attachment_quota']) - { - $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; - $filedata['post_attach'] = false; - - $file->remove(); - - return $filedata; - } - } - - // Check free disk space - if ($free_space = @disk_free_space($phpbb_root_path . $config['upload_path'])) - { - if ($free_space <= $file->get('filesize')) - { - if ($auth->acl_get('a_')) - { - $filedata['error'][] = $user->lang['ATTACH_DISK_FULL']; - } - else - { - $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; - } - $filedata['post_attach'] = false; - - $file->remove(); - - return $filedata; - } - } - - // Create Thumbnail - if ($filedata['thumbnail']) - { - $source = $file->get('destination_file'); - $destination = $file->get('destination_path') . '/thumb_' . $file->get('realname'); - - if (!create_thumbnail($source, $destination, $file->get('mimetype'))) - { - $filedata['thumbnail'] = 0; - } - } + /** @var \phpbb\attachment\upload $attachment_upload */ + $attachment_upload = $phpbb_container->get('attachment.upload'); - return $filedata; + return $attachment_upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); } /** -- cgit v1.2.1 From 4709c8a12884563170e0c1d3aaa65b893c98ed53 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 21 Sep 2015 10:13:26 +0200 Subject: [ticket/14168] Unset prototype classes after use PHPBB3-14168 --- phpBB/includes/functions_posting.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index d4923de60c..c39b9470a3 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -408,8 +408,10 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage /** @var \phpbb\attachment\upload $attachment_upload */ $attachment_upload = $phpbb_container->get('attachment.upload'); + $file = $attachment_upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); + unset($attachment_upload); - return $attachment_upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); + return $file; } /** -- cgit v1.2.1 From 3937f1f4ae77b29faf69292783cc3ae267785ee4 Mon Sep 17 00:00:00 2001 From: Zoddo Date: Sat, 12 Sep 2015 00:53:33 +0200 Subject: [ticket/14157] Allow to set the alt/title attribute on post icons PHPBB3-14157 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4206c87eb9..deac7bc91d 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -311,10 +311,10 @@ function posting_gen_topic_icons($mode, $icon_id) { $template->assign_block_vars('topic_icon', array( 'ICON_ID' => $id, - 'ICON_NAME' => $data['img'], 'ICON_IMG' => $root_path . $config['icons_path'] . '/' . $data['img'], 'ICON_WIDTH' => $data['width'], 'ICON_HEIGHT' => $data['height'], + 'ICON_ALT' => $data['alt'], 'S_CHECKED' => ($id == $icon_id) ? true : false, 'S_ICON_CHECKED' => ($id == $icon_id) ? ' checked="checked"' : '') -- cgit v1.2.1 From 49312f05f88ca58346cbb00c2f03f01fd2a3d56d Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 12 Oct 2015 11:34:11 +0200 Subject: [ticket/14168] Use attachment manager instead of separate classes PHPBB3-14168 --- phpBB/includes/functions_posting.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index c39b9470a3..297ac80170 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -406,10 +406,10 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage { global $phpbb_container; - /** @var \phpbb\attachment\upload $attachment_upload */ - $attachment_upload = $phpbb_container->get('attachment.upload'); - $file = $attachment_upload->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); - unset($attachment_upload); + /** @var \phpbb\attachment\manager $attachment_manager */ + $attachment_manager = $phpbb_container->get('attachment.manager'); + $file = $attachment_manager->upload($form_name, $forum_id, $local, $local_storage, $is_message, $local_filedata); + unset($attachment_manager); return $file; } -- cgit v1.2.1 From bb2634b5e5bdee53118eff8cdba3fea73932ff47 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 12 Oct 2015 12:11:26 +0200 Subject: [ticket/14168] Correctly state return type of upload and upload_attachment PHPBB3-14168 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 297ac80170..2bd30a383f 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -400,7 +400,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) * @param bool $is_message Whether it is a PM or not * @param array $local_filedata A filespec object created for the local file * -* @return \phpbb\files\filespec +* @return array File data array */ function upload_attachment($form_name, $forum_id, $local = false, $local_storage = '', $is_message = false, $local_filedata = false) { -- cgit v1.2.1 From 578ee077c114f63a6de0c277669ba91bd9f1219f Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 12 Oct 2015 19:26:59 +0200 Subject: [ticket/14234] Fix change version and remove more references PHPBB3-14234 --- phpBB/includes/functions_posting.php | 45 ++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 19756d97b4..97daab8887 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1520,6 +1520,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; + $poll_ary = $poll; + $data_ary = $data; /** * Modify the data for post submitting * @@ -1528,23 +1530,28 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value - * @var array poll Array with the poll data for the post - * @var array data Array with the data for the post + * @var array poll_ary Array with the poll data for the post + * @var array data_ary Array with the data for the post * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated * @since 3.1.0-a4 + * @change 3.2.0-a1 Replaced poll and data with poll_ary and data_ary */ $vars = array( 'mode', 'subject', 'username', 'topic_type', - 'poll', - 'data', + 'poll_ary', + 'data_ary', 'update_message', 'update_search_index', ); extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); + $poll = $poll_ary; + $data = $data_ary; + unset($poll_ary); + unset($data_ary); // We do not handle erasing posts here if ($mode == 'delete') @@ -1869,22 +1876,25 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u break; } + $poll_ary = $poll; + $data_ary = $data; /** * Modify sql query data for post submitting * * @event core.submit_post_modify_sql_data - * @var array data Array with the data for the post - * @var array poll Array with the poll data for the post + * @var array data_ary Array with the data for the post + * @var array poll_ary Array with the poll data for the post * @var string post_mode Variable containing posting mode value * @var bool sql_data Array with the data for the posting SQL query * @var string subject Variable containing post subject value * @var int topic_type Variable containing topic type value * @var string username Variable containing post author name * @since 3.1.3-RC1 + * @change 3.2.0-a1 Replace poll and data with poll_ary and data_ary */ $vars = array( - 'data', - 'poll', + 'data_ary', + 'poll_ary', 'post_mode', 'sql_data', 'subject', @@ -1892,6 +1902,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'username', ); extract($phpbb_dispatcher->trigger_event('core.submit_post_modify_sql_data', compact($vars))); + $poll = $poll_ary; + $data = $data_ary; + unset($poll); + unset($data); // Submit new topic if ($post_mode == 'post') @@ -2439,6 +2453,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $url = (!$params) ? "{$phpbb_root_path}viewforum.$phpEx" : "{$phpbb_root_path}viewtopic.$phpEx"; $url = append_sid($url, 'f=' . $data['forum_id'] . $params) . $add_anchor; + $poll_ary = $poll; + $data_ary = $data; /** * This event is used for performing actions directly after a post or topic * has been submitted. When a new topic is posted, the topic ID is @@ -2452,8 +2468,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value - * @var array poll Array with the poll data for the post - * @var array data Array with the data for the post + * @var array poll_ary Array with the poll data for the post + * @var array data_ary Array with the data for the post * @var int post_visibility Variable containing up to date post visibility * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated @@ -2462,20 +2478,25 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @since 3.1.0-a3 * @change 3.1.0-RC3 Added vars mode, subject, username, topic_type, * poll, update_message, update_search_index + * @change 3.2.0-a1 Replaced data and poll with data_ary and poll_ary */ $vars = array( 'mode', 'subject', 'username', 'topic_type', - 'poll', - 'data', + 'poll_ary', + 'data_ary', 'post_visibility', 'update_message', 'update_search_index', 'url', ); extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars))); + $data = $data_ary; + $poll = $poll_ary; + unset($data_ary); + unset($poll_ary); return $url; } -- cgit v1.2.1 From 75e5e2471e7b6b9e1d605f0c3cce5f1fbd373ac0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 12 Oct 2015 21:56:09 +0200 Subject: [ticket/14234] Get rid of undefined variables PHPBB3-14234 --- phpBB/includes/functions_posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 97daab8887..d94edc4257 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1904,8 +1904,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u extract($phpbb_dispatcher->trigger_event('core.submit_post_modify_sql_data', compact($vars))); $poll = $poll_ary; $data = $data_ary; - unset($poll); - unset($data); + unset($poll_ary); + unset($data_ary); // Submit new topic if ($post_mode == 'post') -- cgit v1.2.1 From 065b0a632f308366c7383a322c620b7f2db7b97d Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 30 Nov 2015 18:05:46 +0100 Subject: [ticket/14325] Preserve event variable BC PHPBB3-14325 --- phpBB/includes/functions_posting.php | 345 +++++++++++++++++------------------ 1 file changed, 171 insertions(+), 174 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 4f14dc8683..a5b3111257 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1360,12 +1360,12 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ * Submit Post * @todo Split up and create lightweight, simple API for this. */ -function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true) +function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data_ary, $update_message = true, $update_search_index = true) { global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; - $poll_ary = $poll; - $data_ary = $data; + $poll = $poll_ary; + $data = $data_ary; /** * Modify the data for post submitting * @@ -1374,28 +1374,27 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value - * @var array poll_ary Array with the poll data for the post - * @var array data_ary Array with the data for the post + * @var array poll Array with the poll data for the post + * @var array data Array with the data for the post * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated * @since 3.1.0-a4 - * @change 3.2.0-a1 Replaced poll and data with poll_ary and data_ary */ $vars = array( 'mode', 'subject', 'username', 'topic_type', - 'poll_ary', - 'data_ary', + 'poll', + 'data', 'update_message', 'update_search_index', ); extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars))); - $poll = $poll_ary; - $data = $data_ary; - unset($poll_ary); - unset($data_ary); + $poll_ary = $poll; + $data_ary = $data; + unset($poll); + unset($data); // We do not handle erasing posts here if ($mode == 'delete') @@ -1403,9 +1402,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u return false; } - if (!empty($data['post_time'])) + if (!empty($data_ary['post_time'])) { - $current_time = $data['post_time']; + $current_time = $data_ary['post_time']; } else { @@ -1424,31 +1423,31 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } else if ($mode == 'edit') { - $post_mode = ($data['topic_posts_approved'] + $data['topic_posts_unapproved'] + $data['topic_posts_softdeleted'] == 1) ? 'edit_topic' : (($data['topic_first_post_id'] == $data['post_id']) ? 'edit_first_post' : (($data['topic_last_post_id'] == $data['post_id']) ? 'edit_last_post' : 'edit')); + $post_mode = ($data_ary['topic_posts_approved'] + $data_ary['topic_posts_unapproved'] + $data_ary['topic_posts_softdeleted'] == 1) ? 'edit_topic' : (($data_ary['topic_first_post_id'] == $data_ary['post_id']) ? 'edit_first_post' : (($data_ary['topic_last_post_id'] == $data_ary['post_id']) ? 'edit_last_post' : 'edit')); } // First of all make sure the subject and topic title are having the correct length. // To achieve this without cutting off between special chars we convert to an array and then count the elements. $subject = truncate_string($subject, 120); - $data['topic_title'] = truncate_string($data['topic_title'], 120); + $data_ary['topic_title'] = truncate_string($data_ary['topic_title'], 120); // Collect some basic information about which tables and which rows to update/insert $sql_data = $topic_row = array(); - $poster_id = ($mode == 'edit') ? $data['poster_id'] : (int) $user->data['user_id']; + $poster_id = ($mode == 'edit') ? $data_ary['poster_id'] : (int) $user->data['user_id']; // Retrieve some additional information if not present - if ($mode == 'edit' && (!isset($data['post_visibility']) || !isset($data['topic_visibility']) || $data['post_visibility'] === false || $data['topic_visibility'] === false)) + if ($mode == 'edit' && (!isset($data_ary['post_visibility']) || !isset($data_ary['topic_visibility']) || $data_ary['post_visibility'] === false || $data_ary['topic_visibility'] === false)) { $sql = 'SELECT p.post_visibility, t.topic_type, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_visibility FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p WHERE t.topic_id = p.topic_id - AND p.post_id = ' . $data['post_id']; + AND p.post_id = ' . $data_ary['post_id']; $result = $db->sql_query($sql); $topic_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $data['topic_visibility'] = $topic_row['topic_visibility']; - $data['post_visibility'] = $topic_row['post_visibility']; + $data_ary['topic_visibility'] = $topic_row['topic_visibility']; + $data_ary['post_visibility'] = $topic_row['post_visibility']; } // This variable indicates if the user is able to post or put into the queue @@ -1456,7 +1455,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Check the permissions for post approval. // Moderators must go through post approval like ordinary users. - if (!$auth->acl_get('f_noapprove', $data['forum_id'])) + if (!$auth->acl_get('f_noapprove', $data_ary['forum_id'])) { // Post not approved, but in queue $post_visibility = ITEM_UNAPPROVED; @@ -1472,13 +1471,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // MODs/Extensions are able to force any visibility on posts - if (isset($data['force_approved_state'])) + if (isset($data_ary['force_approved_state'])) { - $post_visibility = (in_array((int) $data['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data['force_approved_state'] : $post_visibility; + $post_visibility = (in_array((int) $data_ary['force_approved_state'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data_ary['force_approved_state'] : $post_visibility; } - if (isset($data['force_visibility'])) + if (isset($data_ary['force_visibility'])) { - $post_visibility = (in_array((int) $data['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data['force_visibility'] : $post_visibility; + $post_visibility = (in_array((int) $data_ary['force_visibility'], array(ITEM_APPROVED, ITEM_UNAPPROVED, ITEM_DELETED, ITEM_REAPPROVE))) ? (int) $data_ary['force_visibility'] : $post_visibility; } // Start the transaction here @@ -1490,25 +1489,25 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'post': case 'reply': $sql_data[POSTS_TABLE]['sql'] = array( - 'forum_id' => $data['forum_id'], + 'forum_id' => $data_ary['forum_id'], 'poster_id' => (int) $user->data['user_id'], - 'icon_id' => $data['icon_id'], + 'icon_id' => $data_ary['icon_id'], 'poster_ip' => $user->ip, 'post_time' => $current_time, 'post_visibility' => $post_visibility, - 'enable_bbcode' => $data['enable_bbcode'], - 'enable_smilies' => $data['enable_smilies'], - 'enable_magic_url' => $data['enable_urls'], - 'enable_sig' => $data['enable_sig'], + 'enable_bbcode' => $data_ary['enable_bbcode'], + 'enable_smilies' => $data_ary['enable_smilies'], + 'enable_magic_url' => $data_ary['enable_urls'], + 'enable_sig' => $data_ary['enable_sig'], 'post_username' => (!$user->data['is_registered']) ? $username : '', 'post_subject' => $subject, - 'post_text' => $data['message'], - 'post_checksum' => $data['message_md5'], - 'post_attachment' => (!empty($data['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data['bbcode_bitfield'], - 'bbcode_uid' => $data['bbcode_uid'], - 'post_postcount' => ($auth->acl_get('f_postcount', $data['forum_id'])) ? 1 : 0, - 'post_edit_locked' => $data['post_edit_locked'] + 'post_text' => $data_ary['message'], + 'post_checksum' => $data_ary['message_md5'], + 'post_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, + 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], + 'bbcode_uid' => $data_ary['bbcode_uid'], + 'post_postcount' => ($auth->acl_get('f_postcount', $data_ary['forum_id'])) ? 1 : 0, + 'post_edit_locked' => $data_ary['post_edit_locked'] ); break; @@ -1525,19 +1524,19 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // If normal edit display edit info // Display edit info if edit reason given or user is editing his post, which is not the last within the topic. - if ($data['post_edit_reason'] || (!$auth->acl_get('m_edit', $data['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post'))) + if ($data_ary['post_edit_reason'] || (!$auth->acl_get('m_edit', $data_ary['forum_id']) && ($post_mode == 'edit' || $post_mode == 'edit_first_post'))) { - $data['post_edit_reason'] = truncate_string($data['post_edit_reason'], 255, 255, false); + $data_ary['post_edit_reason'] = truncate_string($data_ary['post_edit_reason'], 255, 255, false); $sql_data[POSTS_TABLE]['sql'] = array( 'post_edit_time' => $current_time, - 'post_edit_reason' => $data['post_edit_reason'], - 'post_edit_user' => (int) $data['post_edit_user'], + 'post_edit_reason' => $data_ary['post_edit_reason'], + 'post_edit_user' => (int) $data_ary['post_edit_user'], ); $sql_data[POSTS_TABLE]['stat'][] = 'post_edit_count = post_edit_count + 1'; } - else if (!$data['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data['forum_id'])) + else if (!$data_ary['post_edit_reason'] && $mode == 'edit' && $auth->acl_get('m_edit', $data_ary['forum_id'])) { $sql_data[POSTS_TABLE]['sql'] = array( 'post_edit_reason' => '', @@ -1548,14 +1547,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Could be simplified by only adding to the log if the edit is not tracked - but this may confuse admins/mods if ($user->data['user_id'] != $poster_id) { - $log_subject = ($subject) ? $subject : $data['topic_title']; + $log_subject = ($subject) ? $subject : $data_ary['topic_title']; $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_POST_EDITED', false, array( - 'forum_id' => $data['forum_id'], - 'topic_id' => $data['topic_id'], - 'post_id' => $data['post_id'], + 'forum_id' => $data_ary['forum_id'], + 'topic_id' => $data_ary['topic_id'], + 'post_id' => $data_ary['post_id'], $log_subject, (!empty($username)) ? $username : $user->lang['GUEST'], - $data['post_edit_reason'] + $data_ary['post_edit_reason'] )); } @@ -1565,27 +1564,27 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'forum_id' => $data['forum_id'], - 'poster_id' => $data['poster_id'], - 'icon_id' => $data['icon_id'], + 'forum_id' => $data_ary['forum_id'], + 'poster_id' => $data_ary['poster_id'], + 'icon_id' => $data_ary['icon_id'], // We will change the visibility later //'post_visibility' => $post_visibility, - 'enable_bbcode' => $data['enable_bbcode'], - 'enable_smilies' => $data['enable_smilies'], - 'enable_magic_url' => $data['enable_urls'], - 'enable_sig' => $data['enable_sig'], - 'post_username' => ($username && $data['poster_id'] == ANONYMOUS) ? $username : '', + 'enable_bbcode' => $data_ary['enable_bbcode'], + 'enable_smilies' => $data_ary['enable_smilies'], + 'enable_magic_url' => $data_ary['enable_urls'], + 'enable_sig' => $data_ary['enable_sig'], + 'post_username' => ($username && $data_ary['poster_id'] == ANONYMOUS) ? $username : '', 'post_subject' => $subject, - 'post_checksum' => $data['message_md5'], - 'post_attachment' => (!empty($data['attachment_data'])) ? 1 : 0, - 'bbcode_bitfield' => $data['bbcode_bitfield'], - 'bbcode_uid' => $data['bbcode_uid'], - 'post_edit_locked' => $data['post_edit_locked']) + 'post_checksum' => $data_ary['message_md5'], + 'post_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, + 'bbcode_bitfield' => $data_ary['bbcode_bitfield'], + 'bbcode_uid' => $data_ary['bbcode_uid'], + 'post_edit_locked' => $data_ary['post_edit_locked']) ); if ($update_message) { - $sql_data[POSTS_TABLE]['sql']['post_text'] = $data['message']; + $sql_data[POSTS_TABLE]['sql']['post_text'] = $data_ary['message']; } break; @@ -1600,8 +1599,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'topic_poster' => (int) $user->data['user_id'], 'topic_time' => $current_time, 'topic_last_view_time' => $current_time, - 'forum_id' => $data['forum_id'], - 'icon_id' => $data['icon_id'], + 'forum_id' => $data_ary['forum_id'], + 'icon_id' => $data_ary['icon_id'], 'topic_posts_approved' => ($post_visibility == ITEM_APPROVED) ? 1 : 0, 'topic_posts_softdeleted' => ($post_visibility == ITEM_DELETED) ? 1 : 0, 'topic_posts_unapproved' => ($post_visibility == ITEM_UNAPPROVED) ? 1 : 0, @@ -1611,15 +1610,15 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''), 'topic_first_poster_colour' => $user->data['user_colour'], 'topic_type' => $topic_type, - 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, - 'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : 0, - 'topic_status' => (isset($data['topic_status'])) ? $data['topic_status'] : ITEM_UNLOCKED, + 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data_ary['topic_time_limit'] * 86400) : 0, + 'topic_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, + 'topic_status' => (isset($data_ary['topic_status'])) ? $data_ary['topic_status'] : ITEM_UNLOCKED, ); - if (isset($poll['poll_options']) && !empty($poll['poll_options'])) + if (isset($poll_ary['poll_options']) && !empty($poll_ary['poll_options'])) { - $poll_start = ($poll['poll_start']) ? $poll['poll_start'] : $current_time; - $poll_length = $poll['poll_length'] * 86400; + $poll_start = ($poll_ary['poll_start']) ? $poll_ary['poll_start'] : $current_time; + $poll_length = $poll_ary['poll_length'] * 86400; if ($poll_length < 0) { $poll_start = $poll_start + $poll_length; @@ -1631,15 +1630,15 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $sql_data[TOPICS_TABLE]['sql'] = array_merge($sql_data[TOPICS_TABLE]['sql'], array( - 'poll_title' => $poll['poll_title'], + 'poll_title' => $poll_ary['poll_title'], 'poll_start' => $poll_start, - 'poll_max_options' => $poll['poll_max_options'], + 'poll_max_options' => $poll_ary['poll_max_options'], 'poll_length' => $poll_length, - 'poll_vote_change' => $poll['poll_vote_change']) + 'poll_vote_change' => $poll_ary['poll_vote_change']) ); } - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); + $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data_ary['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); if ($post_visibility == ITEM_APPROVED) { @@ -1665,9 +1664,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u (($post_visibility == ITEM_APPROVED) ? ', topic_posts_approved = topic_posts_approved + 1' : '') . (($post_visibility == ITEM_UNAPPROVED) ? ', topic_posts_unapproved = topic_posts_unapproved + 1' : '') . (($post_visibility == ITEM_DELETED) ? ', topic_posts_softdeleted = topic_posts_softdeleted + 1' : '') . - ((!empty($data['attachment_data']) || (isset($data['topic_attachment']) && $data['topic_attachment'])) ? ', topic_attachment = 1' : ''); + ((!empty($data_ary['attachment_data']) || (isset($data_ary['topic_attachment']) && $data_ary['topic_attachment'])) ? ', topic_attachment = 1' : ''); - $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); + $sql_data[USERS_TABLE]['stat'][] = "user_lastpost_time = $current_time" . (($auth->acl_get('f_postcount', $data_ary['forum_id']) && $post_visibility == ITEM_APPROVED) ? ', user_posts = user_posts + 1' : ''); if ($post_visibility == ITEM_APPROVED) { @@ -1685,10 +1684,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u case 'edit_topic': case 'edit_first_post': - if (isset($poll['poll_options'])) + if (isset($poll_ary['poll_options'])) { - $poll_start = ($poll['poll_start'] || empty($poll['poll_options'])) ? $poll['poll_start'] : $current_time; - $poll_length = $poll['poll_length'] * 86400; + $poll_start = ($poll_ary['poll_start'] || empty($poll_ary['poll_options'])) ? $poll_ary['poll_start'] : $current_time; + $poll_length = $poll_ary['poll_length'] * 86400; if ($poll_length < 0) { $poll_start = $poll_start + $poll_length; @@ -1701,27 +1700,27 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $sql_data[TOPICS_TABLE]['sql'] = array( - 'forum_id' => $data['forum_id'], - 'icon_id' => $data['icon_id'], + 'forum_id' => $data_ary['forum_id'], + 'icon_id' => $data_ary['icon_id'], 'topic_title' => $subject, 'topic_first_poster_name' => $username, 'topic_type' => $topic_type, - 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data['topic_time_limit'] * 86400) : 0, - 'poll_title' => (isset($poll['poll_options'])) ? $poll['poll_title'] : '', - 'poll_start' => (isset($poll['poll_options'])) ? $poll_start : 0, - 'poll_max_options' => (isset($poll['poll_options'])) ? $poll['poll_max_options'] : 1, - 'poll_length' => (isset($poll['poll_options'])) ? $poll_length : 0, - 'poll_vote_change' => (isset($poll['poll_vote_change'])) ? $poll['poll_vote_change'] : 0, + 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data_ary['topic_time_limit'] * 86400) : 0, + 'poll_title' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_title'] : '', + 'poll_start' => (isset($poll_ary['poll_options'])) ? $poll_start : 0, + 'poll_max_options' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_max_options'] : 1, + 'poll_length' => (isset($poll_ary['poll_options'])) ? $poll_length : 0, + 'poll_vote_change' => (isset($poll_ary['poll_vote_change'])) ? $poll_ary['poll_vote_change'] : 0, 'topic_last_view_time' => $current_time, - 'topic_attachment' => (!empty($data['attachment_data'])) ? 1 : (isset($data['topic_attachment']) ? $data['topic_attachment'] : 0), + 'topic_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : (isset($data_ary['topic_attachment']) ? $data_ary['topic_attachment'] : 0), ); break; } - $poll_ary = $poll; - $data_ary = $data; + $poll = $poll_ary; + $data = $data_ary; /** * Modify sql query data for post submitting * @@ -1734,11 +1733,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var int topic_type Variable containing topic type value * @var string username Variable containing post author name * @since 3.1.3-RC1 - * @change 3.2.0-a1 Replace poll and data with poll_ary and data_ary */ $vars = array( - 'data_ary', - 'poll_ary', + 'data', + 'poll', 'post_mode', 'sql_data', 'subject', @@ -1746,10 +1744,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u 'username', ); extract($phpbb_dispatcher->trigger_event('core.submit_post_modify_sql_data', compact($vars))); - $poll = $poll_ary; - $data = $data_ary; - unset($poll_ary); - unset($data_ary); + $poll_ary = $poll; + $data_ary = $data; + unset($poll); + unset($data); // Submit new topic if ($post_mode == 'post') @@ -1758,10 +1756,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $db->sql_build_array('INSERT', $sql_data[TOPICS_TABLE]['sql']); $db->sql_query($sql); - $data['topic_id'] = $db->sql_nextid(); + $data_ary['topic_id'] = $db->sql_nextid(); $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data['topic_id']) + 'topic_id' => $data_ary['topic_id']) ); unset($sql_data[TOPICS_TABLE]['sql']); } @@ -1772,18 +1770,18 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($post_mode == 'reply') { $sql_data[POSTS_TABLE]['sql'] = array_merge($sql_data[POSTS_TABLE]['sql'], array( - 'topic_id' => $data['topic_id'], + 'topic_id' => $data_ary['topic_id'], )); } $sql = 'INSERT INTO ' . POSTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_data[POSTS_TABLE]['sql']); $db->sql_query($sql); - $data['post_id'] = $db->sql_nextid(); + $data_ary['post_id'] = $db->sql_nextid(); if ($post_mode == 'post' || $post_visibility == ITEM_APPROVED) { $sql_data[TOPICS_TABLE]['sql'] = array( - 'topic_last_post_id' => $data['post_id'], + 'topic_last_post_id' => $data_ary['post_id'], 'topic_last_post_time' => $current_time, 'topic_last_poster_id' => $sql_data[POSTS_TABLE]['sql']['poster_id'], 'topic_last_poster_name' => ($user->data['user_id'] == ANONYMOUS) ? $sql_data[POSTS_TABLE]['sql']['post_username'] : $user->data['username'], @@ -1794,7 +1792,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($post_mode == 'post') { - $sql_data[TOPICS_TABLE]['sql']['topic_first_post_id'] = $data['post_id']; + $sql_data[TOPICS_TABLE]['sql']['topic_first_post_id'] = $data_ary['post_id']; } // Update total post count and forum information @@ -1806,7 +1804,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $config->increment('num_posts', 1, false); - $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data['post_id']; + $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_id = ' . $data_ary['post_id']; $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_post_subject = '" . $db->sql_escape($subject) . "'"; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_post_time = ' . $current_time; $sql_data[FORUMS_TABLE]['stat'][] = 'forum_last_poster_id = ' . (int) $user->data['user_id']; @@ -1822,7 +1820,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { $sql = 'UPDATE ' . TOPICS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data[TOPICS_TABLE]['sql']) . ' - WHERE topic_id = ' . $data['topic_id']; + WHERE topic_id = ' . $data_ary['topic_id']; $db->sql_query($sql); unset($sql_data[TOPICS_TABLE]['sql']); @@ -1833,14 +1831,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { $sql = 'UPDATE ' . POSTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_data[POSTS_TABLE]['sql']) . ' - WHERE post_id = ' . $data['post_id']; + WHERE post_id = ' . $data_ary['post_id']; $db->sql_query($sql); unset($sql_data[POSTS_TABLE]['sql']); } // Update Poll Tables - if (isset($poll['poll_options'])) + if (isset($poll_ary['poll_options'])) { $cur_poll_options = array(); @@ -1848,7 +1846,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u { $sql = 'SELECT * FROM ' . POLL_OPTIONS_TABLE . ' - WHERE topic_id = ' . $data['topic_id'] . ' + WHERE topic_id = ' . $data_ary['topic_id'] . ' ORDER BY poll_option_id'; $result = $db->sql_query($sql); @@ -1862,25 +1860,25 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql_insert_ary = array(); - for ($i = 0, $size = sizeof($poll['poll_options']); $i < $size; $i++) + for ($i = 0, $size = sizeof($poll_ary['poll_options']); $i < $size; $i++) { - if (strlen(trim($poll['poll_options'][$i]))) + if (strlen(trim($poll_ary['poll_options'][$i]))) { if (empty($cur_poll_options[$i])) { // If we add options we need to put them to the end to be able to preserve votes... $sql_insert_ary[] = array( 'poll_option_id' => (int) sizeof($cur_poll_options) + 1 + sizeof($sql_insert_ary), - 'topic_id' => (int) $data['topic_id'], - 'poll_option_text' => (string) $poll['poll_options'][$i] + 'topic_id' => (int) $data_ary['topic_id'], + 'poll_option_text' => (string) $poll_ary['poll_options'][$i] ); } - else if ($poll['poll_options'][$i] != $cur_poll_options[$i]) + else if ($poll_ary['poll_options'][$i] != $cur_poll_options[$i]) { $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . " - SET poll_option_text = '" . $db->sql_escape($poll['poll_options'][$i]) . "' + SET poll_option_text = '" . $db->sql_escape($poll_ary['poll_options'][$i]) . "' WHERE poll_option_id = " . $cur_poll_options[$i]['poll_option_id'] . ' - AND topic_id = ' . $data['topic_id']; + AND topic_id = ' . $data_ary['topic_id']; $db->sql_query($sql); } } @@ -1888,29 +1886,29 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $db->sql_multi_insert(POLL_OPTIONS_TABLE, $sql_insert_ary); - if (sizeof($poll['poll_options']) < sizeof($cur_poll_options)) + if (sizeof($poll_ary['poll_options']) < sizeof($cur_poll_options)) { $sql = 'DELETE FROM ' . POLL_OPTIONS_TABLE . ' - WHERE poll_option_id > ' . sizeof($poll['poll_options']) . ' - AND topic_id = ' . $data['topic_id']; + WHERE poll_option_id > ' . sizeof($poll_ary['poll_options']) . ' + AND topic_id = ' . $data_ary['topic_id']; $db->sql_query($sql); } // If edited, we would need to reset votes (since options can be re-ordered above, you can't be sure if the change is for changing the text or adding an option - if ($mode == 'edit' && sizeof($poll['poll_options']) != sizeof($cur_poll_options)) + if ($mode == 'edit' && sizeof($poll_ary['poll_options']) != sizeof($cur_poll_options)) { - $db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data['topic_id']); - $db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data['topic_id']); + $db->sql_query('DELETE FROM ' . POLL_VOTES_TABLE . ' WHERE topic_id = ' . $data_ary['topic_id']); + $db->sql_query('UPDATE ' . POLL_OPTIONS_TABLE . ' SET poll_option_total = 0 WHERE topic_id = ' . $data_ary['topic_id']); } } // Submit Attachments - if (!empty($data['attachment_data']) && $data['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) + if (!empty($data_ary['attachment_data']) && $data_ary['post_id'] && in_array($mode, array('post', 'reply', 'quote', 'edit'))) { $space_taken = $files_added = 0; $orphan_rows = array(); - foreach ($data['attachment_data'] as $pos => $attach_row) + foreach ($data_ary['attachment_data'] as $pos => $attach_row) { $orphan_rows[(int) $attach_row['attach_id']] = array(); } @@ -1932,7 +1930,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $db->sql_freeresult($result); } - foreach ($data['attachment_data'] as $pos => $attach_row) + foreach ($data_ary['attachment_data'] as $pos => $attach_row) { if ($attach_row['is_orphan'] && !isset($orphan_rows[$attach_row['attach_id']])) { @@ -1960,8 +1958,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $files_added++; $attach_sql = array( - 'post_msg_id' => $data['post_id'], - 'topic_id' => $data['topic_id'], + 'post_msg_id' => $data_ary['post_id'], + 'topic_id' => $data_ary['topic_id'], 'is_orphan' => 0, 'poster_id' => $poster_id, 'attach_comment' => $attach_row['attach_comment'], @@ -1983,32 +1981,32 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } $first_post_has_topic_info = ($post_mode == 'edit_first_post' && - (($post_visibility == ITEM_DELETED && $data['topic_posts_softdeleted'] == 1) || - ($post_visibility == ITEM_UNAPPROVED && $data['topic_posts_unapproved'] == 1) || - ($post_visibility == ITEM_REAPPROVE && $data['topic_posts_unapproved'] == 1) || - ($post_visibility == ITEM_APPROVED && $data['topic_posts_approved'] == 1))); + (($post_visibility == ITEM_DELETED && $data_ary['topic_posts_softdeleted'] == 1) || + ($post_visibility == ITEM_UNAPPROVED && $data_ary['topic_posts_unapproved'] == 1) || + ($post_visibility == ITEM_REAPPROVE && $data_ary['topic_posts_unapproved'] == 1) || + ($post_visibility == ITEM_APPROVED && $data_ary['topic_posts_approved'] == 1))); // Fix the post's and topic's visibility and first/last post information, when the post is edited - if (($post_mode != 'post' && $post_mode != 'reply') && $data['post_visibility'] != $post_visibility) + if (($post_mode != 'post' && $post_mode != 'reply') && $data_ary['post_visibility'] != $post_visibility) { // If the post was not approved, it could also be the starter, // so we sync the starter after approving/restoring, to ensure that the stats are correct // Same applies for the last post - $is_starter = ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); - $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data['post_visibility'] != ITEM_APPROVED); + $is_starter = ($post_mode == 'edit_first_post' || $post_mode == 'edit_topic' || $data_ary['post_visibility'] != ITEM_APPROVED); + $is_latest = ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $data_ary['post_visibility'] != ITEM_APPROVED); /* @var $phpbb_content_visibility \phpbb\content_visibility */ $phpbb_content_visibility = $phpbb_container->get('content.visibility'); - $phpbb_content_visibility->set_post_visibility($post_visibility, $data['post_id'], $data['topic_id'], $data['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); + $phpbb_content_visibility->set_post_visibility($post_visibility, $data_ary['post_id'], $data_ary['topic_id'], $data_ary['forum_id'], $user->data['user_id'], time(), '', $is_starter, $is_latest); } else if ($post_mode == 'edit_last_post' || $post_mode == 'edit_topic' || $first_post_has_topic_info) { - if ($post_visibility == ITEM_APPROVED || $data['topic_visibility'] == $post_visibility) + if ($post_visibility == ITEM_APPROVED || $data_ary['topic_visibility'] == $post_visibility) { // only the subject can be changed from edit $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_post_subject = '" . $db->sql_escape($subject) . "'"; // Maybe not only the subject, but also changing anonymous usernames. ;) - if ($data['poster_id'] == ANONYMOUS) + if ($data_ary['poster_id'] == ANONYMOUS) { $sql_data[TOPICS_TABLE]['stat'][] = "topic_last_poster_name = '" . $db->sql_escape($username) . "'"; } @@ -2019,13 +2017,13 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // it just means that we might have to $sql = 'SELECT forum_last_post_id, forum_last_post_subject FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . (int) $data['forum_id']; + WHERE forum_id = ' . (int) $data_ary['forum_id']; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // this post is the latest post in the forum, better update - if ($row['forum_last_post_id'] == $data['post_id'] && ($row['forum_last_post_subject'] !== $subject || $data['poster_id'] == ANONYMOUS)) + if ($row['forum_last_post_id'] == $data_ary['post_id'] && ($row['forum_last_post_subject'] !== $subject || $data_ary['poster_id'] == ANONYMOUS)) { // the post's subject changed if ($row['forum_last_post_subject'] !== $subject) @@ -2034,7 +2032,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Update the user name if poster is anonymous... just in case a moderator changed it - if ($data['poster_id'] == ANONYMOUS) + if ($data_ary['poster_id'] == ANONYMOUS) { $sql_data[FORUMS_TABLE]['stat'][] = "forum_last_poster_name = '" . $db->sql_escape($username) . "'"; } @@ -2045,9 +2043,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Update forum stats $where_sql = array( - POSTS_TABLE => 'post_id = ' . $data['post_id'], - TOPICS_TABLE => 'topic_id = ' . $data['topic_id'], - FORUMS_TABLE => 'forum_id = ' . $data['forum_id'], + POSTS_TABLE => 'post_id = ' . $data_ary['post_id'], + TOPICS_TABLE => 'topic_id = ' . $data_ary['topic_id'], + FORUMS_TABLE => 'forum_id = ' . $data_ary['forum_id'], USERS_TABLE => 'user_id = ' . $poster_id ); @@ -2064,7 +2062,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($topic_type == POST_GLOBAL) { $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE topic_moved_id = ' . $data['topic_id']; + WHERE topic_moved_id = ' . $data_ary['topic_id']; $db->sql_query($sql); } @@ -2082,7 +2080,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Index message contents - if ($update_search_index && $data['enable_indexing']) + if ($update_search_index && $data_ary['enable_indexing']) { // Select the search method and do some additional checks to ensure it can actually be utilised $search_type = $config['search_type']; @@ -2100,23 +2098,23 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u trigger_error($error); } - $search->index($mode, $data['post_id'], $data['message'], $subject, $poster_id, $data['forum_id']); + $search->index($mode, $data_ary['post_id'], $data_ary['message'], $subject, $poster_id, $data_ary['forum_id']); } // Topic Notification, do not change if moderator is changing other users posts... if ($user->data['user_id'] == $poster_id) { - if (!$data['notify_set'] && $data['notify']) + if (!$data_ary['notify_set'] && $data_ary['notify']) { $sql = 'INSERT INTO ' . TOPICS_WATCH_TABLE . ' (user_id, topic_id) - VALUES (' . $user->data['user_id'] . ', ' . $data['topic_id'] . ')'; + VALUES (' . $user->data['user_id'] . ', ' . $data_ary['topic_id'] . ')'; $db->sql_query($sql); } - else if (($config['email_enable'] || $config['jab_enable']) && $data['notify_set'] && !$data['notify']) + else if (($config['email_enable'] || $config['jab_enable']) && $data_ary['notify_set'] && !$data_ary['notify']) { $sql = 'DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' - AND topic_id = ' . $data['topic_id']; + AND topic_id = ' . $data_ary['topic_id']; $db->sql_query($sql); } } @@ -2124,12 +2122,12 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') { // Mark this topic as posted to - markread('post', $data['forum_id'], $data['topic_id']); + markread('post', $data_ary['forum_id'], $data_ary['topic_id']); } // Mark this topic as read // We do not use post_time here, this is intended (post_time can have a date in the past if editing a message) - markread('topic', $data['forum_id'], $data['topic_id'], time()); + markread('topic', $data_ary['forum_id'], $data_ary['topic_id'], time()); // if ($config['load_db_lastread'] && $user->data['is_registered']) @@ -2137,7 +2135,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $sql = 'SELECT mark_time FROM ' . FORUMS_TRACK_TABLE . ' WHERE user_id = ' . $user->data['user_id'] . ' - AND forum_id = ' . $data['forum_id']; + AND forum_id = ' . $data_ary['forum_id']; $result = $db->sql_query($sql); $f_mark_time = (int) $db->sql_fetchfield('mark_time'); $db->sql_freeresult($result); @@ -2152,12 +2150,12 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u // Update forum info $sql = 'SELECT forum_last_post_time FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $data['forum_id']; + WHERE forum_id = ' . $data_ary['forum_id']; $result = $db->sql_query($sql); $forum_last_post_time = (int) $db->sql_fetchfield('forum_last_post_time'); $db->sql_freeresult($result); - update_forum_tracking_info($data['forum_id'], $forum_last_post_time, $f_mark_time, false); + update_forum_tracking_info($data_ary['forum_id'], $forum_last_post_time, $f_mark_time, false); } // If a username was supplied or the poster is a guest, we will use the supplied username. @@ -2166,11 +2164,11 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u $username = ($username !== '' || !$user->data['is_registered']) ? $username : $user->data['username']; // Send Notifications - $notification_data = array_merge($data, array( - 'topic_title' => (isset($data['topic_title'])) ? $data['topic_title'] : $subject, + $notification_data = array_merge($data_ary, array( + 'topic_title' => (isset($data_ary['topic_title'])) ? $data_ary['topic_title'] : $subject, 'post_username' => $username, 'poster_id' => $poster_id, - 'post_text' => $data['message'], + 'post_text' => $data_ary['message'], 'post_time' => $current_time, 'post_subject' => $subject, )); @@ -2281,24 +2279,24 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($post_visibility == ITEM_APPROVED) { - $params .= '&t=' . $data['topic_id']; + $params .= '&t=' . $data_ary['topic_id']; if ($mode != 'post') { - $params .= '&p=' . $data['post_id']; - $add_anchor = '#p' . $data['post_id']; + $params .= '&p=' . $data_ary['post_id']; + $add_anchor = '#p' . $data_ary['post_id']; } } else if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic') { - $params .= '&t=' . $data['topic_id']; + $params .= '&t=' . $data_ary['topic_id']; } $url = (!$params) ? "{$phpbb_root_path}viewforum.$phpEx" : "{$phpbb_root_path}viewtopic.$phpEx"; - $url = append_sid($url, 'f=' . $data['forum_id'] . $params) . $add_anchor; + $url = append_sid($url, 'f=' . $data_ary['forum_id'] . $params) . $add_anchor; - $poll_ary = $poll; - $data_ary = $data; + $poll = $poll_ary; + $data = $data_ary; /** * This event is used for performing actions directly after a post or topic * has been submitted. When a new topic is posted, the topic ID is @@ -2312,8 +2310,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @var string subject Variable containing post subject value * @var string username Variable containing post author name * @var int topic_type Variable containing topic type value - * @var array poll_ary Array with the poll data for the post - * @var array data_ary Array with the data for the post + * @var array poll Array with the poll data for the post + * @var array data Array with the data for the post * @var int post_visibility Variable containing up to date post visibility * @var bool update_message Flag indicating if the post will be updated * @var bool update_search_index Flag indicating if the search index will be updated @@ -2322,25 +2320,24 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u * @since 3.1.0-a3 * @change 3.1.0-RC3 Added vars mode, subject, username, topic_type, * poll, update_message, update_search_index - * @change 3.2.0-a1 Replaced data and poll with data_ary and poll_ary */ $vars = array( 'mode', 'subject', 'username', 'topic_type', - 'poll_ary', - 'data_ary', + 'poll', + 'data', 'post_visibility', 'update_message', 'update_search_index', 'url', ); extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars))); - $data = $data_ary; - $poll = $poll_ary; - unset($data_ary); - unset($poll_ary); + $data_ary = $data; + $poll_ary = $poll; + unset($data); + unset($poll); return $url; } -- cgit v1.2.1 From fad26c97bc6c1abceda71dfee5b84823b5a70083 Mon Sep 17 00:00:00 2001 From: Mate Bartus Date: Mon, 30 Nov 2015 18:27:06 +0100 Subject: [ticket/14325] Fix variable names in docblocks PHPBB3-14325 --- phpBB/includes/functions_posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index a5b3111257..66140a5278 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1725,8 +1725,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data * Modify sql query data for post submitting * * @event core.submit_post_modify_sql_data - * @var array data_ary Array with the data for the post - * @var array poll_ary Array with the poll data for the post + * @var array data Array with the data for the post + * @var array poll Array with the poll data for the post * @var string post_mode Variable containing posting mode value * @var bool sql_data Array with the data for the posting SQL query * @var string subject Variable containing post subject value -- cgit v1.2.1 From f50ba9ab4f6e74e4d472c9e2012dfdd29720dfe9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 3 Dec 2015 18:19:02 +0100 Subject: [ticket/13454] Remove unused variables This is part 2 of the pr. PHPBB3-13454 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 66140a5278..e5532d336d 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -333,7 +333,7 @@ function posting_gen_topic_icons($mode, $icon_id) */ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) { - global $auth, $user, $template, $topic_type; + global $auth, $user, $template; $toggle = false; -- cgit v1.2.1 From 266576c6a4224f4b803040c678020e825a1510b5 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 4 Dec 2015 11:50:39 +0100 Subject: [ticket/13454] Remove unused variables Part 4 PHPBB3-13454 --- phpBB/includes/functions_posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index e5532d336d..3addf0ddb4 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -833,7 +833,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms foreach ($draft_rows as $draft) { $link_topic = $link_forum = $link_pm = false; - $insert_url = $view_url = $title = ''; + $view_url = $title = ''; if (isset($topic_rows[$draft['topic_id']]) && ( -- cgit v1.2.1 From 7a6a16e3a52128179a4f518958f22e773dd94084 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Dec 2015 13:45:16 +0100 Subject: [ticket/13454] Remove unused variables This is part 5 and there is more to come. PHPBB3-13454 --- phpBB/includes/functions_posting.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 3addf0ddb4..22a98411ad 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -959,11 +959,9 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id $db->sql_freeresult($result); // Grab extensions - $extensions = $attachments = array(); + $attachments = array(); if ($has_attachments && $auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id)) { - $extensions = $cache->obtain_attach_extensions($forum_id); - // Get attachments... $sql = 'SELECT * FROM ' . ATTACHMENTS_TABLE . ' @@ -1101,7 +1099,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id */ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $softdelete_reason = '') { - global $db, $user, $auth, $phpbb_container; + global $db, $user, $phpbb_container; global $config, $phpEx, $phpbb_root_path; // Specify our post mode @@ -1190,7 +1188,6 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ if ($is_soft) { - $topic_row = array(); $phpbb_content_visibility->set_topic_visibility(ITEM_DELETED, $topic_id, $forum_id, $user->data['user_id'], time(), $softdelete_reason); } else @@ -1589,7 +1586,6 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data break; } - $topic_row = array(); // And the topic ladies and gentlemen switch ($post_mode) -- cgit v1.2.1 From 73900d1857a9a59eff82b224537a79110466ce7e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 5 Dec 2015 16:07:14 +0100 Subject: [ticket/13454] Remove more unused variables This should be the last part. Off to checking if the changes were correct. PHPBB3-13454 --- phpBB/includes/functions_posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 22a98411ad..56d2408e88 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -886,7 +886,7 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms */ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id = 0, $show_quote_button = true) { - global $user, $auth, $db, $template, $cache; + global $user, $auth, $db, $template; global $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher; /* @var $phpbb_content_visibility \phpbb\content_visibility */ @@ -1359,7 +1359,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $ */ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data_ary, $update_message = true, $update_search_index = true) { - global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; + global $db, $auth, $user, $config, $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request; $poll = $poll_ary; $data = $data_ary; -- cgit v1.2.1 From 0e49dc44092b31223b927487b2ef98aea25dc667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Bartus?= Date: Wed, 9 Mar 2016 20:25:27 +0100 Subject: [ticket/13264] Don't force approved state if post visibility is known (3.2) The previous PR broke 3.2 because of different variable names PHPBB3-13264 --- phpBB/includes/functions_posting.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 452c989c76..2bc7ed471e 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1492,9 +1492,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data break; } } - else if (isset($data['post_visibility']) && $data['post_visibility'] !== false) + else if (isset($data_ary['post_visibility']) && $data_ary['post_visibility'] !== false) { - $post_visibility = $data['post_visibility']; + $post_visibility = $data_ary['post_visibility']; } // MODs/Extensions are able to force any visibility on posts @@ -2304,8 +2304,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data $params = $add_anchor = ''; if ($post_visibility == ITEM_APPROVED || - ($auth->acl_get('m_softdelete', $data['forum_id']) && $post_visibility == ITEM_DELETED) || - ($auth->acl_get('m_approve', $data['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE)))) + ($auth->acl_get('m_softdelete', $data_ary['forum_id']) && $post_visibility == ITEM_DELETED) || + ($auth->acl_get('m_approve', $data_ary['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE)))) { $params .= '&t=' . $data_ary['topic_id']; -- cgit v1.2.1 From 38cf5c10f91b4af6f22059185f758a1da8e7d04e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 24 Mar 2017 23:15:07 +0100 Subject: [ticket/15137] Global Announcements shouldn't always be never ending PHPBB3-15137 --- phpBB/includes/functions_posting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 0edf9304a3..7bc9608536 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1676,7 +1676,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data 'topic_first_poster_name' => (!$user->data['is_registered'] && $username) ? $username : (($user->data['user_id'] != ANONYMOUS) ? $user->data['username'] : ''), 'topic_first_poster_colour' => $user->data['user_colour'], 'topic_type' => $topic_type, - 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data_ary['topic_time_limit'] * 86400) : 0, + 'topic_time_limit' => $topic_type != POST_NORMAL ? ($data_ary['topic_time_limit'] * 86400) : 0, 'topic_attachment' => (!empty($data_ary['attachment_data'])) ? 1 : 0, 'topic_status' => (isset($data_ary['topic_status'])) ? $data_ary['topic_status'] : ITEM_UNLOCKED, ); @@ -1771,7 +1771,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data 'topic_title' => $subject, 'topic_first_poster_name' => $username, 'topic_type' => $topic_type, - 'topic_time_limit' => ($topic_type == POST_STICKY || $topic_type == POST_ANNOUNCE) ? ($data_ary['topic_time_limit'] * 86400) : 0, + 'topic_time_limit' => $topic_type != POST_NORMAL ? ($data_ary['topic_time_limit'] * 86400) : 0, 'poll_title' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_title'] : '', 'poll_start' => (isset($poll_ary['poll_options'])) ? $poll_start : 0, 'poll_max_options' => (isset($poll_ary['poll_options'])) ? $poll_ary['poll_max_options'] : 1, -- cgit v1.2.1 From 68c3a0307de19fdefd7ae716247fffea3ee30c0c Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 16 Aug 2017 21:57:11 +0700 Subject: [ticket/15324] Add more core and template events PHPBB3-15324 --- phpBB/includes/functions_posting.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/functions_posting.php') diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index afa4bb56c4..d9f395efb3 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -712,7 +712,7 @@ function posting_gen_inline_attachments(&$attachment_data) */ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true) { - global $template, $config, $phpbb_root_path, $phpEx, $user; + global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher; // Some default template variables $template->assign_vars(array( @@ -730,6 +730,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a foreach ($attachment_data as $count => $attach_row) { $hidden = ''; + $attachrow_template_vars = array(); $attach_row['real_filename'] = utf8_basename($attach_row['real_filename']); foreach ($attach_row as $key => $value) @@ -739,7 +740,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a $download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&id=' . (int) $attach_row['attach_id'], true, ($attach_row['is_orphan']) ? $user->session_id : false); - $template->assign_block_vars('attach_row', array( + $attachrow_template_vars[(int) $attach_row['attach_id']] = array( 'FILENAME' => utf8_basename($attach_row['real_filename']), 'A_FILENAME' => addslashes(utf8_basename($attach_row['real_filename'])), 'FILE_COMMENT' => $attach_row['attach_comment'], @@ -749,9 +750,22 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a 'FILESIZE' => get_formatted_filesize($attach_row['filesize']), 'U_VIEW_ATTACHMENT' => $download_link, - 'S_HIDDEN' => $hidden) + 'S_HIDDEN' => $hidden, ); } + + /** + * Modify inline attachments template vars + * + * @event core.modify_inline_attachments_template_vars + * @var array attachment_data Array containing attachments data + * @var array attachrow_template_vars Array containing attachments template vars + * @since 3.2.2-RC1 + */ + $vars = array('attachment_data', 'attachrow_template_vars'); + extract($phpbb_dispatcher->trigger_event('core.modify_inline_attachments_template_vars', compact($vars))); + + $template->assign_block_vars_array('attach_row', $attachrow_template_vars); } return sizeof($attachment_data); -- cgit v1.2.1