From b2bfcda19c20ca695f8228ef49de9295c191a316 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2014 14:40:50 +0200 Subject: [PATCH 1/6] [ticket/12407] Allow changing of post_data, etc. at end of posting.php The current event core.posting_modify_template_vars is just ran using dispatch but it doesn't pass any data from posting.php to the listener. Because of that, it's not possible to know anything from posting.php and therefore limits the use cases of this event. This will change it to allow similar actions as with the event core.modify_posting_parameters. PHPBB3-12407 --- phpBB/posting.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index f592402fc6..b6a388dc64 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1473,8 +1473,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']), @@ -1542,15 +1542,42 @@ $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 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 bool refresh Whether or not to retain previously submitted data +* @var string mode What action to take if the form has been sumitted +* post|reply|quote|edit|delete|bump|smilies|popup +* @var array error Any error strings; a non-empty array aborts +* form submission. +* NOTE: Should be actual language strings, NOT +* language keys. +* @var array s_hidden_fields Hidden fields of posting form +* @var array post_data Post data of the post to create, edit, etc. +* @var array page_data Posting page data that should be passed to the +* posting page via $template->assign_vars() * @since 3.1-A1 +* @changed 3.1.0-b3 Introduced variables passed to listener */ -$phpbb_dispatcher->dispatch('core.posting_modify_template_vars'); +$vars = array('post_id', 'topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error', 's_hidden_fields', 'post_data', 'page_data'); +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(); From 61f4802b5a40c0d30de8398a058a24baf2cab182 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 14 Apr 2014 16:00:12 +0200 Subject: [PATCH 2/6] [ticket/12407] Add message_parser as passed variable to event PHPBB3-12407 --- phpBB/posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index b6a388dc64..7a90a473a7 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1570,10 +1570,11 @@ $page_data = array( * @var array post_data Post data of the post to create, edit, etc. * @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-A1 * @changed 3.1.0-b3 Introduced variables passed to listener */ -$vars = array('post_id', 'topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error', 's_hidden_fields', 'post_data', 'page_data'); +$vars = array('post_id', 'topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error', 's_hidden_fields', 'post_data', 'page_data', 'message_parser'); extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars))); // Start assigning vars for main posting page ... From a3dbfb749ec71e67f20f65c7f8acdd2f61612561 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 16 Apr 2014 11:10:29 +0200 Subject: [PATCH 3/6] [ticket/12407] Assign template variables again after merging develop-ascraeus PHPBB3-12407 --- phpBB/posting.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/posting.php b/phpBB/posting.php index 7f374338ff..3262a3353b 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1588,6 +1588,9 @@ $vars = array('post_data', 'moderators', 'mode', 'page_title', 's_topic_icons', $vars += array('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(); From bfd66ef2fdc1721ded267b6a0af3883f827840c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 20 Apr 2014 12:38:55 +0200 Subject: [PATCH 4/6] [ticket/12407] Merge @change in doc block of event PHPBB3-12407 --- phpBB/posting.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 3262a3353b..cac0aa30c0 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1579,10 +1579,9 @@ $page_data = array( * @var object message_parser The message parser object * @since 3.1-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_id, topic_id, forum_id, submit, preview, -* save, load, delete, cancel, refresh, error, page_data, -* message_parser +* 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', 'moderators', 'mode', 'page_title', 's_topic_icons', 'form_enctype', 's_action', 's_hidden_fields', 'post_id'); $vars += array('topic_id', 'forum_id', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'error', 'page_data', 'message_parser'); From 0bc5e951987ff77b2f1611981fcdb33efcc55ad6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 11 May 2014 09:40:26 +0200 Subject: [PATCH 5/6] [ticket/12407] Fix incorrect @since line in event PHPBB3-12407 --- phpBB/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index bdb4d21924..345b5b094e 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1596,7 +1596,7 @@ $page_data = array( * @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-A1 +* @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, * post_id, topic_id, forum_id, submit, preview, save, load, From e7923336fb146c90d14ee0ccb3c164017bd3aef6 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 11 May 2014 10:10:26 +0200 Subject: [PATCH 6/6] [ticket/12407] Remove merge marker from posting.php PHPBB3-12407 --- phpBB/posting.php | 1 - 1 file changed, 1 deletion(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 345b5b094e..d48157dcd6 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1572,7 +1572,6 @@ $page_data = array( * 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 -<<<<<<< HEAD * @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