aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/posting.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/posting.php')
-rw-r--r--phpBB/posting.php131
1 files changed, 99 insertions, 32 deletions
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 054f6edb50..60bb595da6 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.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.
*
*/
@@ -381,19 +385,46 @@ if (($post_data['forum_status'] == ITEM_LOCKED || (isset($post_data['topic_statu
// else it depends on editing times, lock status and if we're the correct user
if ($mode == 'edit' && !$auth->acl_get('m_edit', $forum_id))
{
- if ($user->data['user_id'] != $post_data['poster_id'])
- {
- trigger_error('USER_CANNOT_EDIT');
- }
-
- if (!($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']))
- {
- trigger_error('CANNOT_EDIT_TIME');
- }
+ $force_edit_allowed = false;
+
+ $s_cannot_edit = $user->data['user_id'] != $post_data['poster_id'];
+ $s_cannot_edit_time = $config['edit_time'] && $post_data['post_time'] <= time() - ($config['edit_time'] * 60);
+ $s_cannot_edit_locked = $post_data['post_edit_locked'];
+
+ /**
+ * This event allows you to modify the conditions for the "cannot edit post" checks
+ *
+ * @event core.posting_modify_cannot_edit_conditions
+ * @var array post_data Array with post data
+ * @var bool force_edit_allowed Allow the user to edit the post (all permissions and conditions are ignored)
+ * @var bool s_cannot_edit User can not edit the post because it's not his
+ * @var bool s_cannot_edit_locked User can not edit the post because it's locked
+ * @var bool s_cannot_edit_time User can not edit the post because edit_time has passed
+ * @since 3.1.0-b4
+ */
+ $vars = array(
+ 'post_data',
+ 'force_edit_allowed',
+ 's_cannot_edit',
+ 's_cannot_edit_locked',
+ 's_cannot_edit_time',
+ );
+ extract($phpbb_dispatcher->trigger_event('core.posting_modify_cannot_edit_conditions', compact($vars)));
- if ($post_data['post_edit_locked'])
+ if (!$force_edit_allowed)
{
- trigger_error('CANNOT_EDIT_POST_LOCKED');
+ if ($s_cannot_edit)
+ {
+ trigger_error('USER_CANNOT_EDIT');
+ }
+ else if ($s_cannot_edit_time)
+ {
+ trigger_error('CANNOT_EDIT_TIME');
+ }
+ else if ($s_cannot_edit_locked)
+ {
+ trigger_error('CANNOT_EDIT_POST_LOCKED');
+ }
}
}
@@ -1491,8 +1522,8 @@ $form_enctype = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_up
add_form_key('posting');
-// Start assigning vars for main posting page ...
-$template->assign_vars(array(
+// Build array of variables for main posting page
+$page_data = array(
'L_POST_A' => $page_title,
'L_ICON' => ($mode == 'reply' || $mode == 'quote' || ($mode == 'edit' && $post_id != $post_data['topic_first_post_id'])) ? $user->lang['POST_ICON'] : $user->lang['TOPIC_ICON'],
'L_MESSAGE_BODY_EXPLAIN' => $user->lang('MESSAGE_BODY_EXPLAIN', (int) $config['max_post_chars']),
@@ -1515,6 +1546,7 @@ $template->assign_vars(array(
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],
'EDIT_REASON' => $request->variable('edit_reason', ''),
+ 'SHOW_PANEL' => $request->variable('show_panel', ''),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"),
'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id") : '',
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&amp;mode=popup"),
@@ -1540,7 +1572,6 @@ $template->assign_vars(array(
'S_LOCK_POST_ALLOWED' => ($mode == 'edit' && $auth->acl_get('m_edit', $forum_id)) ? true : false,
'S_LOCK_POST_CHECKED' => ($lock_post_checked) ? ' checked="checked"' : '',
'S_SOFTDELETE_CHECKED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? ' checked="checked"' : '',
- 'S_DELETE_REASON' => ($mode == 'edit' && $auth->acl_get('m_softdelete', $forum_id)) ? true : false,
'S_SOFTDELETE_ALLOWED' => ($mode == 'edit' && $phpbb_content_visibility->can_soft_delete($forum_id, $post_data['poster_id'], $lock_post_checked)) ? true : false,
'S_RESTORE_ALLOWED' => $auth->acl_get('m_approve', $forum_id),
'S_IS_DELETED' => ($mode == 'edit' && $post_data['post_visibility'] == ITEM_DELETED) ? true : false,
@@ -1560,24 +1591,46 @@ $template->assign_vars(array(
'S_HIDDEN_FIELDS' => $s_hidden_fields,
'S_ATTACH_DATA' => json_encode($message_parser->attachment_data),
'S_IN_POSTING' => true,
-));
+);
/**
* This event allows you to modify template variables for the posting screen
*
* @event core.posting_modify_template_vars
-* @var array post_data Array with post data
-* @var array moderators Array with forum moderators
-* @var string mode What action to take if the form is submitted
-* post|reply|quote|edit|delete|bump|smilies|popup
-* @var string page_title Title of the mode page
+* @var array post_data Array with post data
+* @var array moderators Array with forum moderators
+* @var string mode What action to take if the form is submitted
+* post|reply|quote|edit|delete|bump|smilies|popup
+* @var string page_title Title of the mode page
* @var bool s_topic_icons Whether or not to show the topic icons
-* @var string form_enctype If attachments are allowed for this form the value of
-* this is "multipart/form-data" else it is the empty string
-* @var string s_action The URL to submit the POST data to
-* @var string s_hidden_fields The concatenated input tags of the form's hidden fields
+* @var string form_enctype If attachments are allowed for this form
+* "multipart/form-data" or empty string
+* @var string s_action The URL to submit the POST data to
+* @var string s_hidden_fields Concatenated hidden input tags of posting form
+* @var int post_id ID of the post
+* @var int topic_id ID of the topic
+* @var int forum_id ID of the forum
+* @var bool submit Whether or not the form has been submitted
+* @var bool preview Whether or not the post is being previewed
+* @var bool save Whether or not a draft is being saved
+* @var bool load Whether or not a draft is being loaded
+* @var bool delete Whether or not the post is being deleted
+* @var bool cancel Whether or not to cancel the form (returns to
+* viewtopic or viewforum depending on if the user
+* is posting a new topic or editing a post)
+* @var array error Any error strings; a non-empty array aborts
+* form submission.
+* NOTE: Should be actual language strings, NOT
+* language keys.
+* @var bool refresh Whether or not to retain previously submitted data
+* @var array page_data Posting page data that should be passed to the
+* posting page via $template->assign_vars()
+* @var object message_parser The message parser object
* @since 3.1.0-a1
-* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, s_topic_icons, form_enctype, s_action, s_hidden_fields
+* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title,
+* s_topic_icons, form_enctype, s_action, s_hidden_fields,
+* post_id, topic_id, forum_id, submit, preview, save, load,
+* delete, cancel, refresh, error, page_data, message_parser
*/
$vars = array(
'post_data',
@@ -1588,9 +1641,25 @@ $vars = array(
'form_enctype',
's_action',
's_hidden_fields',
+ 'post_id',
+ 'topic_id',
+ 'forum_id',
+ 'submit',
+ 'preview',
+ 'save',
+ 'load',
+ 'delete',
+ 'cancel',
+ 'refresh',
+ 'error',
+ 'page_data',
+ 'message_parser',
);
extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars)));
+// Start assigning vars for main posting page ...
+$template->assign_vars($page_data);
+
// Build custom bbcodes array
display_custom_bbcodes();
@@ -1712,14 +1781,14 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
if ($next_post_id === false)
{
- add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username);
+ add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_TOPIC' : 'LOG_DELETE_TOPIC'), $post_data['topic_title'], $post_username, $soft_delete_reason);
$meta_info = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id");
$message = $user->lang['POST_DELETED'];
}
else
{
- add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username);
+ add_log('mod', $forum_id, $topic_id, (($is_soft) ? 'LOG_SOFTDELETE_POST' : 'LOG_DELETE_POST'), $post_data['post_subject'], $post_username, $soft_delete_reason);
$meta_info = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id&amp;p=$next_post_id") . "#p$next_post_id";
$message = $user->lang['POST_DELETED'];
@@ -1743,14 +1812,12 @@ function handle_post_delete($forum_id, $topic_id, $post_id, &$post_data, $is_sof
$can_delete = $auth->acl_get('m_delete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_delete', $forum_id));
$can_softdelete = $auth->acl_get('m_softdelete', $forum_id) || ($post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('f_softdelete', $forum_id));
- $display_reason = $auth->acl_get('m_softdelete', $forum_id) || ($can_delete && $can_softdelete);
$template->assign_vars(array(
'S_SOFTDELETED' => $post_data['post_visibility'] == ITEM_DELETED,
'S_CHECKED_PERMANENT' => $request->is_set_post('delete_permanent') ? ' checked="checked"' : '',
'S_ALLOWED_DELETE' => $can_delete,
'S_ALLOWED_SOFTDELETE' => $can_softdelete,
- 'S_DELETE_REASON' => $display_reason,
));
$l_confirm = 'DELETE_POST';