aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/functions_posting.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/functions_posting.php')
-rw-r--r--phpBB/includes/functions_posting.php783
1 files changed, 392 insertions, 391 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index 9712b6e922..1956f65666 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -24,12 +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;
- $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id);
+ /* @var $pagination \phpbb\pagination */
$pagination = $phpbb_container->get('pagination');
- $start = request_var('start', 0);
+ $base_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&f=' . $forum_id);
+ $start = $request->variable('start', 0);
if ($mode == 'window')
{
@@ -51,9 +52,29 @@ function generate_smilies($mode, $forum_id)
page_header($user->lang['SMILIES']);
- $sql = 'SELECT COUNT(smiley_id) AS item_count
- FROM ' . SMILIES_TABLE . '
- GROUP BY smiley_url';
+ $sql_ary = [
+ 'SELECT' => 'COUNT(s.smiley_id) AS item_count',
+ 'FROM' => [
+ SMILIES_TABLE => 's',
+ ],
+ 'GROUP_BY' => 's.smiley_url',
+ ];
+
+ /**
+ * Modify SQL query that fetches the total number of smilies in window mode
+ *
+ * @event core.generate_smilies_count_sql_before
+ * @var int forum_id Forum where smilies are generated
+ * @var array sql_ary Array with the SQL query
+ * @since 3.2.9-RC1
+ */
+ $vars = [
+ 'forum_id',
+ 'sql_ary',
+ ];
+ extract($phpbb_dispatcher->trigger_event('core.generate_smilies_count_sql_before', compact($vars)));
+
+ $sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql, 3600);
$smiley_count = 0;
@@ -113,7 +134,23 @@ function generate_smilies($mode, $forum_id)
}
$db->sql_freeresult($result);
- if (sizeof($smilies))
+ /**
+ * Modify smilies before they are assigned to the template
+ *
+ * @event core.generate_smilies_modify_rowset
+ * @var string mode Smiley mode, either window or inline
+ * @var int forum_id Forum where smilies are generated
+ * @var array smilies Smiley rows fetched from the database
+ * @since 3.2.9-RC1
+ */
+ $vars = [
+ 'mode',
+ 'forum_id',
+ 'smilies',
+ ];
+ extract($phpbb_dispatcher->trigger_event('core.generate_smilies_modify_rowset', compact($vars)));
+
+ if (count($smilies))
{
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_path_helper->get_web_root_path();
@@ -199,13 +236,15 @@ function update_post_information($type, $ids, $return_update_sql = false)
$topic_condition = '';
}
- if (sizeof($ids) == 1)
+ if (count($ids) == 1)
{
- $sql = 'SELECT MAX(p.post_id) as last_post_id
+ $sql = 'SELECT p.post_id as last_post_id
FROM ' . POSTS_TABLE . " p $topic_join
WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . "
$topic_condition
- AND p.post_visibility = " . ITEM_APPROVED;
+ AND p.post_visibility = " . ITEM_APPROVED . "
+ ORDER BY p.post_id DESC";
+ $result = $db->sql_query_limit($sql, 1);
}
else
{
@@ -215,13 +254,13 @@ function update_post_information($type, $ids, $return_update_sql = false)
$topic_condition
AND p.post_visibility = " . ITEM_APPROVED . "
GROUP BY p.{$type}_id";
+ $result = $db->sql_query($sql);
}
- $result = $db->sql_query($sql);
$last_post_ids = array();
while ($row = $db->sql_fetchrow($result))
{
- if (sizeof($ids) == 1)
+ if (count($ids) == 1)
{
$row[$type . '_id'] = $ids[0];
}
@@ -255,7 +294,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
}
}
- if (sizeof($last_post_ids))
+ if (count($last_post_ids))
{
$sql = 'SELECT p.' . $type . '_id, p.post_id, p.post_subject, p.post_time, p.poster_id, p.post_username, u.user_id, u.username, u.user_colour
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
@@ -276,7 +315,7 @@ function update_post_information($type, $ids, $return_update_sql = false)
}
unset($empty_forums, $ids, $last_post_ids);
- if ($return_update_sql || !sizeof($update_sql))
+ if ($return_update_sql || !count($update_sql))
{
return $update_sql;
}
@@ -309,7 +348,7 @@ function posting_gen_topic_icons($mode, $icon_id)
$template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"');
}
- if (sizeof($icons))
+ if (count($icons))
{
$root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;
@@ -319,10 +358,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"' : '')
@@ -341,23 +380,20 @@ 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;
$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;
@@ -387,8 +423,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;
@@ -402,183 +438,27 @@ 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 array File data array
*/
-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;
-
- $filedata = array(
- 'error' => array()
- );
-
- include_once($phpbb_root_path . 'includes/functions_upload.' . $phpEx);
- $upload = new fileupload();
-
- 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);
-
- 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_']));
-
- $file = ($local) ? $upload->local_upload($local_storage, $local_filedata, $mimetype_guesser) : $upload->form_upload($form_name, $mimetype_guesser, $plupload);
-
- 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');
+ global $phpbb_container;
- if (!create_thumbnail($source, $destination, $file->get('mimetype')))
- {
- $filedata['thumbnail'] = 0;
- }
- }
+ /** @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 $filedata;
+ return $file;
}
/**
@@ -677,7 +557,7 @@ function get_supported_image_types($type = false)
*/
function create_thumbnail($source, $destination, $mimetype)
{
- global $config;
+ global $config, $phpbb_filesystem, $phpbb_dispatcher;
$min_filesize = (int) $config['img_min_thumb_filesize'];
$img_filesize = (file_exists($source)) ? @filesize($source) : false;
@@ -709,25 +589,31 @@ function create_thumbnail($source, $destination, $mimetype)
return false;
}
- $used_imagick = false;
-
- // Only use ImageMagick if defined and the passthru function not disabled
- if ($config['img_imagick'] && function_exists('passthru'))
- {
- if (substr($config['img_imagick'], -1) !== '/')
- {
- $config['img_imagick'] .= '/';
- }
-
- @passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
+ $thumbnail_created = false;
- if (file_exists($destination))
- {
- $used_imagick = true;
- }
- }
+ /**
+ * Create thumbnail event to replace GD thumbnail creation with for example ImageMagick
+ *
+ * @event core.thumbnail_create_before
+ * @var string source Image source path
+ * @var string destination Thumbnail destination path
+ * @var string mimetype Image mime type
+ * @var float new_width Calculated thumbnail width
+ * @var float new_height Calculated thumbnail height
+ * @var bool thumbnail_created Set to true to skip default GD thumbnail creation
+ * @since 3.2.4
+ */
+ $vars = array(
+ 'source',
+ 'destination',
+ 'mimetype',
+ 'new_width',
+ 'new_height',
+ 'thumbnail_created',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.thumbnail_create_before', compact($vars)));
- if (!$used_imagick)
+ if (!$thumbnail_created)
{
$type = get_supported_image_types($type);
@@ -829,7 +715,14 @@ function create_thumbnail($source, $destination, $mimetype)
return false;
}
- phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE);
+ try
+ {
+ $phpbb_filesystem->phpbb_chmod($destination, CHMOD_READ | CHMOD_WRITE);
+ }
+ catch (\phpbb\filesystem\exception\filesystem_exception $e)
+ {
+ // Do nothing
+ }
return true;
}
@@ -841,7 +734,7 @@ function posting_gen_inline_attachments(&$attachment_data)
{
global $template;
- if (sizeof($attachment_data))
+ if (count($attachment_data))
{
$s_inline_attachment_options = '';
@@ -863,21 +756,23 @@ 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(
'S_SHOW_ATTACH_BOX' => $show_attach_box,
- 'S_HAS_ATTACHMENTS' => sizeof($attachment_data),
+ 'S_HAS_ATTACHMENTS' => count($attachment_data),
'FILESIZE' => $config['max_filesize'],
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
));
- if (sizeof($attachment_data))
+ if (count($attachment_data))
{
// We display the posted attachments within the desired order.
($config['display_order']) ? krsort($attachment_data) : ksort($attachment_data);
+ $attachrow_template_vars = [];
+
foreach ($attachment_data as $count => $attach_row)
{
$hidden = '';
@@ -890,7 +785,7 @@ function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_a
$download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'mode=view&amp;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'],
@@ -900,12 +795,25 @@ 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);
+ return count($attachment_data);
}
//
@@ -953,13 +861,13 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms
}
$db->sql_freeresult($result);
- if (!sizeof($draft_rows))
+ if (!count($draft_rows))
{
return;
}
$topic_rows = array();
- if (sizeof($topic_ids))
+ if (count($topic_ids))
{
$sql = 'SELECT topic_id, forum_id, topic_title, topic_poster
FROM ' . TOPICS_TABLE . '
@@ -993,7 +901,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']])
&& (
@@ -1046,9 +954,10 @@ 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 */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
$sql_sort = ($mode == 'post_review') ? 'ASC' : 'DESC';
@@ -1071,7 +980,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$db->sql_freeresult($result);
- if (!sizeof($post_list))
+ if (!count($post_list))
{
return false;
}
@@ -1105,6 +1014,30 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
AND u.user_id = p.poster_id',
);
+ /**
+ * Event to modify the SQL query for topic reviews
+ *
+ * @event core.topic_review_modify_sql_ary
+ * @var int topic_id The topic ID that is being reviewed
+ * @var int forum_id The topic's forum ID
+ * @var string mode The topic review mode
+ * @var int cur_post_id Post offset ID
+ * @var bool show_quote_button Flag indicating if the quote button should be displayed
+ * @var array post_list Array with the post IDs
+ * @var array sql_ary Array with the SQL query
+ * @since 3.2.8-RC1
+ */
+ $vars = array(
+ 'topic_id',
+ 'forum_id',
+ 'mode',
+ 'cur_post_id',
+ 'show_quote_button',
+ 'post_list',
+ 'sql_ary',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_sql_ary', compact($vars)));
+
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
@@ -1122,11 +1055,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 . '
@@ -1168,7 +1099,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
);
extract($phpbb_dispatcher->trigger_event('core.topic_review_modify_post_list', compact($vars)));
- for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
+ for ($i = 0, $end = count($post_list); $i < $end; ++$i)
{
// A non-existing rowset only happens if there was no user present for the entered poster_id
// This could be a broken posts table.
@@ -1251,6 +1182,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&amp;mode=post_details&amp;f=' . $forum_id . '&amp;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'])) : '',
@@ -1315,7 +1248,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, $phpbb_dispatcher;
+ global $db, $user, $phpbb_container, $phpbb_dispatcher;
global $config, $phpEx, $phpbb_root_path;
// Specify our post mode
@@ -1362,6 +1295,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
@@ -1392,7 +1326,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
foreach ($shadow_forum_ids as $updated_forum => $topic_count)
{
- // counting is fun! we only have to do sizeof($forum_ids) number of queries,
+ // counting is fun! we only have to do count($forum_ids) number of queries,
// even if the topic is moved back to where its shadow lives (we count how many times it is in a forum)
$sql = 'UPDATE ' . FORUMS_TABLE . '
SET forum_topics_approved = forum_topics_approved - ' . $topic_count . '
@@ -1403,7 +1337,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
@@ -1411,9 +1344,10 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
delete_topics('topic_id', array($topic_id), false);
$phpbb_content_visibility->remove_topic_from_statistic($data, $sql_data);
+ $config->increment('num_posts', -1, false);
$update_sql = update_post_information('forum', $forum_id, true);
- if (sizeof($update_sql))
+ if (count($update_sql))
{
$sql_data[FORUMS_TABLE] .= ($sql_data[FORUMS_TABLE]) ? ', ' : '';
$sql_data[FORUMS_TABLE] .= implode(', ', $update_sql[$forum_id]);
@@ -1462,7 +1396,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $
{
// Update last post information when hard deleting. Soft delete already did that by itself.
$update_sql = update_post_information('forum', $forum_id, true);
- if (sizeof($update_sql))
+ if (count($update_sql))
{
$sql_data[FORUMS_TABLE] = (($sql_data[FORUMS_TABLE]) ? $sql_data[FORUMS_TABLE] . ', ' : '') . implode(', ', $update_sql[$forum_id]);
}
@@ -1601,10 +1535,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;
+ global $db, $auth, $user, $config, $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request;
+ $poll = $poll_ary;
+ $data = $data_ary;
/**
* Modify the data for post submitting
*
@@ -1630,6 +1566,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'update_search_index',
);
extract($phpbb_dispatcher->trigger_event('core.modify_submit_post_data', compact($vars)));
+ $poll_ary = $poll;
+ $data_ary = $data;
+ unset($poll);
+ unset($data);
// We do not handle erasing posts here
if ($mode == 'delete')
@@ -1637,9 +1577,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
{
@@ -1658,31 +1598,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
@@ -1690,7 +1630,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;
@@ -1704,19 +1644,19 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
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
- 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
@@ -1728,25 +1668,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;
@@ -1763,19 +1703,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' => '',
@@ -1786,8 +1726,15 @@ 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'];
- add_log('mod', $data['forum_id'], $data['topic_id'], 'LOG_POST_EDITED', $log_subject, (!empty($username)) ? $username : $user->lang['GUEST'], $data['post_edit_reason']);
+ $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_ary['forum_id'],
+ 'topic_id' => $data_ary['topic_id'],
+ 'post_id' => $data_ary['post_id'],
+ $log_subject,
+ (!empty($username)) ? $username : $user->lang['GUEST'],
+ $data_ary['post_edit_reason']
+ ));
}
if (!isset($sql_data[POSTS_TABLE]['sql']))
@@ -1796,32 +1743,31 @@ 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;
}
- $topic_row = array();
// And the topic ladies and gentlemen
switch ($post_mode)
@@ -1831,8 +1777,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,
@@ -1842,15 +1788,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_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,
);
- 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;
@@ -1862,15 +1808,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)
{
@@ -1896,9 +1842,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)
{
@@ -1916,10 +1862,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;
@@ -1932,25 +1878,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_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,
+ '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 = $poll_ary;
+ $data = $data_ary;
/**
* Modify sql query data for post submitting
*
@@ -1974,6 +1922,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_ary = $poll;
+ $data_ary = $data;
+ unset($poll);
+ unset($data);
// Submit new topic
if ($post_mode == 'post')
@@ -1982,10 +1934,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']);
}
@@ -1996,18 +1948,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'],
@@ -2018,7 +1970,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
@@ -2026,11 +1978,11 @@ 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_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'];
@@ -2046,7 +1998,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']);
@@ -2057,14 +2009,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();
@@ -2072,7 +2024,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);
@@ -2086,25 +2038,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 = count($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]
+ 'poll_option_id' => (int) count($cur_poll_options) + 1 + count($sql_insert_ary),
+ '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);
}
}
@@ -2112,34 +2064,34 @@ 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 (count($poll_ary['poll_options']) < count($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 > ' . count($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' && count($poll_ary['poll_options']) != count($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();
}
- if (sizeof($orphan_rows))
+ if (count($orphan_rows))
{
$sql = 'SELECT attach_id, filesize, physical_filename
FROM ' . ATTACHMENTS_TABLE . '
@@ -2156,13 +2108,18 @@ 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']]))
{
continue;
}
+ if (preg_match('/[\x{10000}-\x{10FFFF}]/u', $attach_row['attach_comment']))
+ {
+ trigger_error('ATTACH_COMMENT_NO_EMOJIS');
+ }
+
if (!$attach_row['is_orphan'])
{
// update entry in db if attachment already stored in db and filespace
@@ -2184,8 +2141,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'],
@@ -2201,37 +2158,38 @@ 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);
}
}
$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) . "'";
}
@@ -2242,13 +2200,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)
@@ -2257,7 +2215,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) . "'";
}
@@ -2268,9 +2226,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
);
@@ -2287,7 +2245,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);
}
@@ -2295,7 +2253,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 . "
@@ -2305,7 +2263,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'];
@@ -2323,23 +2281,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);
}
}
@@ -2347,12 +2305,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'])
@@ -2360,7 +2318,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);
@@ -2375,12 +2333,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.
@@ -2389,15 +2347,29 @@ 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,
));
+ /**
+ * This event allows you to modify the notification data upon submission
+ *
+ * @event core.modify_submit_notification_data
+ * @var array notification_data The notification data to be inserted in to the database
+ * @var array data_ary The data array with a lot of the post submission data
+ * @var string mode The posting mode
+ * @var int poster_id The poster id
+ * @since 3.2.4-RC1
+ */
+ $vars = array('notification_data', 'data_ary', 'mode', 'poster_id');
+ extract($phpbb_dispatcher->trigger_event('core.modify_submit_notification_data', compact($vars)));
+
+ /* @var $phpbb_notifications \phpbb\notification\manager */
$phpbb_notifications = $phpbb_container->get('notification_manager');
if ($post_visibility == ITEM_APPROVED)
@@ -2424,8 +2396,14 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
case 'edit_first_post':
case 'edit':
case 'edit_last_post':
+ if ($user->data['user_id'] == $poster_id)
+ {
+ $phpbb_notifications->update_notifications(array(
+ 'notification.type.quote',
+ ), $notification_data);
+ }
+
$phpbb_notifications->update_notifications(array(
- 'notification.type.quote',
'notification.type.bookmark',
'notification.type.topic',
'notification.type.post',
@@ -2502,25 +2480,27 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
$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 .= '&amp;t=' . $data['topic_id'];
+ $params .= '&amp;t=' . $data_ary['topic_id'];
if ($mode != 'post')
{
- $params .= '&amp;p=' . $data['post_id'];
- $add_anchor = '#p' . $data['post_id'];
+ $params .= '&amp;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 .= '&amp;t=' . $data['topic_id'];
+ $params .= '&amp;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 = $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
@@ -2558,6 +2538,10 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
'url',
);
extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars)));
+ $data_ary = $data;
+ $poll_ary = $poll;
+ unset($data);
+ unset($poll);
return $url;
}
@@ -2578,7 +2562,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)
{
@@ -2657,7 +2641,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&amp;t=$topic_id&amp;p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}";
@@ -2704,7 +2692,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, $phpbb_dispatcher;
+ global $phpbb_root_path, $phpEx, $phpbb_log, $phpbb_dispatcher;
$force_delete_allowed = $force_softdelete_allowed = false;
$perm_check = ($is_soft) ? 'softdelete' : 'delete';
@@ -2768,14 +2756,27 @@ 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_id' => $post_id,
+ $post_data['post_subject'],
+ $post_username,
+ $delete_reason
+ ));
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;p=$next_post_id") . "#p$next_post_id";
$message = $user->lang['POST_DELETED'];