Skip to content
Snippets Groups Projects
Verified Commit 87b020b7 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Upravy show_results

parent 6da1c567
Branches
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ image: docker:20.10.9 ...@@ -2,7 +2,7 @@ image: docker:20.10.9
variables: variables:
DOCKER_TLS_CERTDIR: "/certs" DOCKER_TLS_CERTDIR: "/certs"
BUILD_VERSION: p2 BUILD_VERSION: p3
services: services:
- docker:20.10.9-dind - docker:20.10.9-dind
......
...@@ -256,7 +256,7 @@ function generate_smilies($mode, $forum_id) ...@@ -256,7 +256,7 @@ function generate_smilies($mode, $forum_id)
*/ */
function update_post_information($type, $ids, $return_update_sql = false) function update_post_information($type, $ids, $return_update_sql = false)
{ {
global $db; global $db, $phpbb_dispatcher;
if (empty($ids)) if (empty($ids))
{ {
...@@ -340,14 +340,35 @@ function update_post_information($type, $ids, $return_update_sql = false) ...@@ -340,14 +340,35 @@ function update_post_information($type, $ids, $return_update_sql = false)
if (count($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 $sql_ary = array(
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u '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',
WHERE p.poster_id = u.user_id 'FROM' => array(
AND ' . $db->sql_in_set('p.post_id', $last_post_ids); POSTS_TABLE => 'p',
$result = $db->sql_query($sql); USERS_TABLE => 'u',
),
'WHERE' => $db->sql_in_set('p.post_id', $last_post_ids) . '
AND p.poster_id = u.user_id',
);
/**
* Event to modify the SQL array to get the post and user data from all last posts
*
* @event core.update_post_info_modify_posts_sql
* @var string type The table being updated (forum or topic)
* @var array sql_ary SQL array to get some of the last posts' data
* @since 3.3.5-RC1
*/
$vars = [
'type',
'sql_ary',
];
extract($phpbb_dispatcher->trigger_event('core.update_post_info_modify_posts_sql', compact($vars)));
$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
$rowset = array();
while ($row = $db->sql_fetchrow($result)) while ($row = $db->sql_fetchrow($result))
{ {
$rowset[] = $row;
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id']; $update_sql[$row["{$type}_id"]][] = $type . '_last_post_id = ' . (int) $row['post_id'];
$update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'"; $update_sql[$row["{$type}_id"]][] = "{$type}_last_post_subject = '" . $db->sql_escape($row['post_subject']) . "'";
$update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time']; $update_sql[$row["{$type}_id"]][] = $type . '_last_post_time = ' . (int) $row['post_time'];
...@@ -356,6 +377,23 @@ function update_post_information($type, $ids, $return_update_sql = false) ...@@ -356,6 +377,23 @@ function update_post_information($type, $ids, $return_update_sql = false)
$update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'"; $update_sql[$row["{$type}_id"]][] = "{$type}_last_poster_name = '" . (($row['poster_id'] == ANONYMOUS) ? $db->sql_escape($row['post_username']) : $db->sql_escape($row['username'])) . "'";
} }
$db->sql_freeresult($result); $db->sql_freeresult($result);
/**
* Event to modify the update_sql array to add new update data for forum or topic last posts
*
* @event core.update_post_info_modify_sql
* @var string type The table being updated (forum or topic)
* @var array rowset Array with the posts data
* @var array update_sql Array with SQL data to update the forums or topics table with
* @since 3.3.5-RC1
*/
$vars = [
'type',
'rowset',
'update_sql',
];
extract($phpbb_dispatcher->trigger_event('core.update_post_info_modify_sql', compact($vars)));
unset($rowset);
} }
unset($empty_forums, $ids, $last_post_ids); unset($empty_forums, $ids, $last_post_ids);
...@@ -775,20 +813,42 @@ function posting_gen_inline_attachments(&$attachment_data) ...@@ -775,20 +813,42 @@ function posting_gen_inline_attachments(&$attachment_data)
} }
/** /**
* Generate inline attachment entry * Generate inline attachment entry
*/ *
function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true) * @param array $attachment_data The attachment data
* @param string $filename_data The filename data (filecomment)
* @param bool $show_attach_box Whether to show the attach box
* @param mixed $forum_id The forum id to check or false if private message
* @return int
*/
function posting_gen_attachment_entry($attachment_data, &$filename_data, $show_attach_box = true, $forum_id = false)
{ {
global $template, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher; global $template, $cache, $config, $phpbb_root_path, $phpEx, $user, $phpbb_dispatcher;
$allowed_attachments = array_keys($cache->obtain_attach_extensions($forum_id)['_allowed_']);
// Some default template variables // Some default template variables
$template->assign_vars(array( $default_vars = [
'S_SHOW_ATTACH_BOX' => $show_attach_box, 'S_SHOW_ATTACH_BOX' => $show_attach_box,
'S_HAS_ATTACHMENTS' => count($attachment_data), 'S_HAS_ATTACHMENTS' => count($attachment_data),
'FILESIZE' => $config['max_filesize'], 'FILESIZE' => $config['max_filesize'],
'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '', 'FILE_COMMENT' => (isset($filename_data['filecomment'])) ? $filename_data['filecomment'] : '',
'MAX_ATTACHMENT_FILESIZE' => $config['max_filesize'] > 0 ? $user->lang('MAX_ATTACHMENT_FILESIZE', get_formatted_filesize($config['max_filesize'])) : '', 'MAX_ATTACHMENT_FILESIZE' => $config['max_filesize'] > 0 ? $user->lang('MAX_ATTACHMENT_FILESIZE', get_formatted_filesize($config['max_filesize'])) : '',
)); 'ALLOWED_ATTACHMENTS' => !empty($allowed_attachments) ? implode(',', $allowed_attachments) : '',
];
/**
* Modify default attachments template vars
*
* @event core.modify_default_attachments_template_vars
* @var array allowed_attachments Array containing allowed attachments data
* @var array default_vars Array containing default attachments template vars
* @since 3.3.6-RC1
*/
$vars = ['allowed_attachments', 'default_vars'];
extract($phpbb_dispatcher->trigger_event('core.modify_default_attachments_template_vars', compact($vars)));
$template->assign_vars($default_vars);
if (count($attachment_data)) if (count($attachment_data))
{ {
...@@ -937,10 +997,10 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms ...@@ -937,10 +997,10 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0, $pm_action = '', $ms
$topic_forum_id = ($topic_rows[$draft['topic_id']]['forum_id']) ? $topic_rows[$draft['topic_id']]['forum_id'] : $forum_id; $topic_forum_id = ($topic_rows[$draft['topic_id']]['forum_id']) ? $topic_rows[$draft['topic_id']]['forum_id'] : $forum_id;
$link_topic = true; $link_topic = true;
$view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id']); $view_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $draft['topic_id']);
$title = $topic_rows[$draft['topic_id']]['topic_title']; $title = $topic_rows[$draft['topic_id']]['topic_title'];
$insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 'f=' . $topic_forum_id . '&t=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']); $insert_url = append_sid("{$phpbb_root_path}posting.$phpEx", 't=' . $draft['topic_id'] . '&mode=reply&d=' . $draft['draft_id']);
} }
else if ($draft['forum_id'] && $auth->acl_get('f_read', $draft['forum_id'])) else if ($draft['forum_id'] && $auth->acl_get('f_read', $draft['forum_id']))
{ {
...@@ -1160,7 +1220,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id ...@@ -1160,7 +1220,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
$post_subject = censor_text($post_subject); $post_subject = censor_text($post_subject);
$post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id']; $post_anchor = ($mode == 'post_review') ? 'ppr' . $row['post_id'] : 'pr' . $row['post_id'];
$u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "f=$forum_id&t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}"); $u_show_post = append_sid($phpbb_root_path . 'viewtopic.' . $phpEx, "t=$topic_id&p={$row['post_id']}&view=show#p{$row['post_id']}");
$l_deleted_message = ''; $l_deleted_message = '';
if ($row['post_visibility'] == ITEM_DELETED) if ($row['post_visibility'] == ITEM_DELETED)
...@@ -1193,11 +1253,11 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id ...@@ -1193,11 +1253,11 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false, 'S_HAS_ATTACHMENTS' => !empty($attachments[$row['post_id']]),
'S_FRIEND' => ($row['friend']) ? true : false, 'S_FRIEND' => (bool) $row['friend'],
'S_IGNORE_POST' => ($row['foe']) ? true : false, 'S_IGNORE_POST' => (bool) $row['foe'],
'L_IGNORE_POST' => ($row['foe']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"phpbb.toggleDisplay('{$post_anchor}', 1); return false;\">", '</a>') : '', 'L_IGNORE_POST' => $row['foe'] ? $user->lang('POST_BY_FOE', get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), "<a href=\"{$u_show_post}\" onclick=\"phpbb.toggleDisplay('{$post_anchor}', 1); return false;\">", '</a>') : '',
'S_POST_DELETED' => ($row['post_visibility'] == ITEM_DELETED) ? true : false, 'S_POST_DELETED' => $row['post_visibility'] == ITEM_DELETED,
'L_DELETE_POST' => $l_deleted_message, 'L_DELETE_POST' => $l_deleted_message,
'POST_SUBJECT' => $post_subject, 'POST_SUBJECT' => $post_subject,
...@@ -1209,7 +1269,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id ...@@ -1209,7 +1269,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
'POST_TIME' => $row['post_time'], 'POST_TIME' => $row['post_time'],
'USER_ID' => $row['user_id'], 'USER_ID' => $row['user_id'],
'U_MINI_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $row['post_id']) . '#p' . $row['post_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) : '', 'U_MCP_DETAILS' => ($auth->acl_get('m_info', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=post_details&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'])) : '', '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'])) : '',
); );
...@@ -1843,7 +1903,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data ...@@ -1843,7 +1903,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
,'poll_show_results' => $poll_ary['poll_show_results'] ,'poll_show_results' => $poll_ary['poll_show_results']
/* END SHOW_RESULTS */ /* END SHOW_RESULTS */
) )
); );
} }
...@@ -2517,27 +2577,35 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data ...@@ -2517,27 +2577,35 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
} }
} }
$params = $add_anchor = ''; $params = [];
$add_anchor = '';
$url = "{$phpbb_root_path}viewtopic.$phpEx";
if ($post_visibility == ITEM_APPROVED || if ($post_visibility == ITEM_APPROVED ||
($auth->acl_get('m_softdelete', $data_ary['forum_id']) && $post_visibility == ITEM_DELETED) || ($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)))) ($auth->acl_get('m_approve', $data_ary['forum_id']) && in_array($post_visibility, array(ITEM_UNAPPROVED, ITEM_REAPPROVE))))
{ {
$params .= '&amp;t=' . $data_ary['topic_id'];
if ($mode != 'post') if ($mode != 'post')
{ {
$params .= '&amp;p=' . $data_ary['post_id']; $params['p'] = $data_ary['post_id'];
$add_anchor = '#p' . $data_ary['post_id']; $add_anchor = '#p' . $data_ary['post_id'];
} }
else
{
$params['t'] = $data_ary['topic_id'];
}
} }
else if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic') else if ($mode != 'post' && $post_mode != 'edit_first_post' && $post_mode != 'edit_topic')
{ {
$params .= '&amp;t=' . $data_ary['topic_id']; $params['t'] = $data_ary['topic_id'];
}
else
{
$url = "{$phpbb_root_path}viewforum.$phpEx";
$params['f'] = $data_ary['forum_id'];
} }
$url = (!$params) ? "{$phpbb_root_path}viewforum.$phpEx" : "{$phpbb_root_path}viewtopic.$phpEx"; $url = append_sid($url, $params) . $add_anchor;
$url = append_sid($url, 'f=' . $data_ary['forum_id'] . $params) . $add_anchor;
$poll = $poll_ary; $poll = $poll_ary;
$data = $data_ary; $data = $data_ary;
...@@ -2598,7 +2666,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data ...@@ -2598,7 +2666,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll_ary, &$data
* - 'topic_last_poster_name' * - 'topic_last_poster_name'
* - 'topic_last_poster_colour' * - 'topic_last_poster_colour'
* @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time(). * @param int $bump_time The time at which topic was bumped, usually it is a current time as obtained via time().
* @return string An URL to the bumped topic, example: ./viewtopic.php?forum_id=1&amptopic_id=2&ampp=3#p3 * @return string An URL to the bumped topic, example: ./viewtopic.php?p=3#p3
*/ */
function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false) function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false)
{ {
...@@ -2687,7 +2755,7 @@ function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false) ...@@ -2687,7 +2755,7 @@ function phpbb_bump_topic($forum_id, $topic_id, $post_data, $bump_time = false)
$post_data['topic_title'] $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']}"; $url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p={$post_data['topic_last_post_id']}") . "#p{$post_data['topic_last_post_id']}";
return $url; return $url;
} }
...@@ -2818,7 +2886,7 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $ ...@@ -2818,7 +2886,7 @@ function phpbb_handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $
$delete_reason $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"; $meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "p=$next_post_id") . "#p$next_post_id";
$message = $user->lang['POST_DELETED']; $message = $user->lang['POST_DELETED'];
if (!$request->is_ajax()) if (!$request->is_ajax())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment