aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-05-11 20:04:00 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-05-11 21:27:21 +0200
commitb430979f604c89bd4ee8e48c6a637ed52dcc5609 (patch)
tree9f305a8231bf795a450d737cabf73c2ee6969e56 /phpBB
parentaeb5189be0ee203831a0f369142aced3107ee05b (diff)
downloadforums-b430979f604c89bd4ee8e48c6a637ed52dcc5609.tar
forums-b430979f604c89bd4ee8e48c6a637ed52dcc5609.tar.gz
forums-b430979f604c89bd4ee8e48c6a637ed52dcc5609.tar.bz2
forums-b430979f604c89bd4ee8e48c6a637ed52dcc5609.tar.xz
forums-b430979f604c89bd4ee8e48c6a637ed52dcc5609.zip
[ticket/12518] Add event to overwrite the cannot edit condition in posting.php
PHPBB3-12518
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/posting.php49
1 files changed, 38 insertions, 11 deletions
diff --git a/phpBB/posting.php b/phpBB/posting.php
index d48157dcd6..6e1bde42f8 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -381,19 +381,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 = !($post_data['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time']);
+ $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');
+ }
}
}