aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/viewtopic.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/viewtopic.php')
-rw-r--r--phpBB/viewtopic.php98
1 files changed, 76 insertions, 22 deletions
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index a0cd590e58..789d53c676 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package phpBB3
-* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
*
*/
@@ -642,6 +646,7 @@ $template->assign_vars(array(
'U_TOPIC' => "{$server_path}viewtopic.$phpEx?f=$forum_id&amp;t=$topic_id",
'U_FORUM' => $server_path,
'U_VIEW_TOPIC' => $viewtopic_url,
+ 'U_CANONICAL' => generate_board_url() . '/' . append_sid("viewtopic.$phpEx", "t=$topic_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($start) ? "&amp;start=$start" : ''), true, ''),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_OLDER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
'U_VIEW_NEWER_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;view=next"),
@@ -930,7 +935,7 @@ else
// Container for user details, only process once
$post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = $post_delete_list = array();
-$has_attachments = $display_notice = false;
+$has_unapproved_attachments = $has_approved_attachments = $display_notice = false;
$bbcode_bitfield = '';
$i = $i_total = 0;
@@ -1041,7 +1046,11 @@ while ($row = $db->sql_fetchrow($result))
if ($row['post_visibility'] == ITEM_UNAPPROVED || $row['post_visibility'] == ITEM_REAPPROVE)
{
- $has_attachments = true;
+ $has_unapproved_attachments = true;
+ }
+ else if ($row['post_visibility'] == ITEM_APPROVED)
+ {
+ $has_approved_attachments = true;
}
}
@@ -1345,7 +1354,7 @@ if (sizeof($attach_list))
$db->sql_query($sql);
}
}
- else if ($has_attachments && !$topic_data['topic_attachment'])
+ else if ($has_approved_attachments && !$topic_data['topic_attachment'])
{
// Topic has approved attachments but its flag is wrong
$sql = 'UPDATE ' . TOPICS_TABLE . "
@@ -1355,6 +1364,11 @@ if (sizeof($attach_list))
$topic_data['topic_attachment'] = 1;
}
+ else if ($has_unapproved_attachments && !$topic_data['topic_attachment'])
+ {
+ // Topic has only unapproved attachments but we have the right to see and download them
+ $topic_data['topic_attachment'] = 1;
+ }
}
else
{
@@ -1582,27 +1596,67 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
$s_first_unread = $first_unread = true;
}
- $edit_allowed = ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (
- $user->data['user_id'] == $poster_id &&
- $auth->acl_get('f_edit', $forum_id) &&
- $topic_data['topic_status'] != ITEM_LOCKED &&
- !$row['post_edit_locked'] &&
- ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])
+ $force_edit_allowed = $force_delete_allowed = false;
+
+ $s_cannot_edit = !$auth->acl_get('f_edit', $forum_id) || $user->data['user_id'] != $poster_id;
+ $s_cannot_edit_time = $config['edit_time'] && $row['post_time'] <= time() - ($config['edit_time'] * 60);
+ $s_cannot_edit_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked'];
+
+ $s_cannot_delete = $user->data['user_id'] != $poster_id || (
+ !$auth->acl_get('f_delete', $forum_id) &&
+ (!$auth->acl_get('f_softdelete', $forum_id) || $row['post_visibility'] == ITEM_DELETED)
+ );
+ $s_cannot_delete_lastpost = $topic_data['topic_last_post_id'] != $row['post_id'];
+ $s_cannot_delete_time = $config['delete_time'] && $row['post_time'] <= time() - ($config['delete_time'] * 60);
+ // we do not want to allow removal of the last post if a moderator locked it!
+ $s_cannot_delete_locked = $topic_data['topic_status'] == ITEM_LOCKED || $row['post_edit_locked'];
+
+ /**
+ * This event allows you to modify the conditions for the "can edit post" and "can delete post" checks
+ *
+ * @event core.viewtopic_modify_post_action_conditions
+ * @var array row Array with post data
+ * @var array topic_data Array with topic data
+ * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored)
+ * @var bool s_cannot_edit User can not edit the post because it's not his
+ * @var bool s_cannot_edit_locked User can not edit the post because it's locked
+ * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed
+ * @var bool force_delete_allowed Allow the user to delete the post (all permissions and conditions are ignored)
+ * @var bool s_cannot_delete User can not delete the post because it's not his
+ * @var bool s_cannot_delete_lastpost User can not delete the post because it's not the last post of the topic
+ * @var bool s_cannot_delete_locked User can not delete the post because it's locked
+ * @var bool s_cannot_delete_time User can not delete the post because edit_time has passed
+ * @since 3.1.0-b4
+ */
+ $vars = array(
+ 'row',
+ 'topic_data',
+ 'force_edit_allowed',
+ 's_cannot_edit',
+ 's_cannot_edit_locked',
+ 's_cannot_edit_time',
+ 'force_delete_allowed',
+ 's_cannot_delete',
+ 's_cannot_delete_lastpost',
+ 's_cannot_delete_locked',
+ 's_cannot_delete_time',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_action_conditions', compact($vars)));
+
+ $edit_allowed = $force_edit_allowed || ($user->data['is_registered'] && ($auth->acl_get('m_edit', $forum_id) || (
+ !$s_cannot_edit &&
+ !$s_cannot_edit_time &&
+ !$s_cannot_edit_locked
)));
$quote_allowed = $auth->acl_get('m_edit', $forum_id) || ($topic_data['topic_status'] != ITEM_LOCKED &&
($user->data['user_id'] == ANONYMOUS || $auth->acl_get('f_reply', $forum_id))
);
- $delete_allowed = ($user->data['is_registered'] && (($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) || (
- $user->data['user_id'] == $poster_id &&
- ($auth->acl_get('f_delete', $forum_id) || ($auth->acl_get('f_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) &&
- $topic_data['topic_status'] != ITEM_LOCKED &&
- $topic_data['topic_last_post_id'] == $row['post_id'] &&
- ($row['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time']) &&
- // we do not want to allow removal of the last post if a moderator locked it!
- !$row['post_edit_locked']
- )));
+ $delete_allowed = $force_delete_allowed || ($user->data['is_registered'] && (
+ ($auth->acl_get('m_delete', $forum_id) || ($auth->acl_get('m_softdelete', $forum_id) && $row['post_visibility'] != ITEM_DELETED)) ||
+ (!$s_cannot_delete && !$s_cannot_delete_lastpost && !$s_cannot_delete_time && !$s_cannot_delete_locked)
+ ));
// Can this user receive a Private Message?
$can_receive_pm = (
@@ -1755,7 +1809,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
$contact_fields = array(
array(
'ID' => 'pm',
- 'NAME' => $user->lang['PRIVATE_MESSAGES'],
+ 'NAME' => $user->lang['SEND_PRIVATE_MESSAGE'],
'U_CONTACT' => $u_pm,
),
array(