From 34602037dcbd357985baa8416dc748f3dd570ec3 Mon Sep 17 00:00:00 2001 From: javiexin Date: Wed, 29 Apr 2015 20:15:20 +0200 Subject: [PATCH 1/3] [ticket/13795] Modify core event in posting to include poll data Modified the core.posting_modify_template_vars event in posting.php to extend the content of the page_data array to include poll data. That required moving the event and merging the new set of template vars. PHPBB3-13795 --- phpBB/posting.php | 48 ++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index ac412c0c73..20cb14b4b5 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1784,6 +1784,30 @@ $page_data = array( 'S_IN_POSTING' => true, ); +// Build custom bbcodes array +display_custom_bbcodes(); + +// Poll entry +if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) + && $auth->acl_get('f_poll', $forum_id)) +{ + $page_data = array_merge($page_data, array( + 'S_SHOW_POLL_BOX' => true, + 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), + 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), + 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, + + 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), + + 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', + 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', + 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', + 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, + 'POLL_LENGTH' => $post_data['poll_length'], + ) + ); +} + /** * This event allows you to modify template variables for the posting screen * @@ -1822,6 +1846,7 @@ $page_data = array( * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser * @change 3.1.2-RC1 Removed 'delete' var as it does not exist +* @change 3.1.4-RC1 Added poll variables to the page_data array */ $vars = array( 'post_data', @@ -1850,29 +1875,6 @@ extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', co // Start assigning vars for main posting page ... $template->assign_vars($page_data); -// Build custom bbcodes array -display_custom_bbcodes(); - -// Poll entry -if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id']/* && (!$post_data['poll_last_vote'] || $auth->acl_get('m_edit', $forum_id))*/)) - && $auth->acl_get('f_poll', $forum_id)) -{ - $template->assign_vars(array( - 'S_SHOW_POLL_BOX' => true, - 'S_POLL_VOTE_CHANGE' => ($auth->acl_get('f_votechg', $forum_id) && $auth->acl_get('f_vote', $forum_id)), - 'S_POLL_DELETE' => ($mode == 'edit' && sizeof($post_data['poll_options']) && ((!$post_data['poll_last_vote'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id)) || $auth->acl_get('m_delete', $forum_id))), - 'S_POLL_DELETE_CHECKED' => (!empty($poll_delete)) ? true : false, - - 'L_POLL_OPTIONS_EXPLAIN' => $user->lang('POLL_OPTIONS_' . (($mode == 'edit') ? 'EDIT_' : '') . 'EXPLAIN', (int) $config['max_poll_options']), - - 'VOTE_CHANGE_CHECKED' => (!empty($post_data['poll_vote_change'])) ? ' checked="checked"' : '', - 'POLL_TITLE' => (isset($post_data['poll_title'])) ? $post_data['poll_title'] : '', - 'POLL_OPTIONS' => (!empty($post_data['poll_options'])) ? implode("\n", $post_data['poll_options']) : '', - 'POLL_MAX_OPTIONS' => (isset($post_data['poll_max_options'])) ? (int) $post_data['poll_max_options'] : 1, - 'POLL_LENGTH' => $post_data['poll_length']) - ); -} - // Show attachment box for adding attachments if true $allowed = ($auth->acl_get('f_attach', $forum_id) && $auth->acl_get('u_attach') && $config['allow_attachments'] && $form_enctype); From 6e0d12094abed711e4c50d0d9d62de9d425673fd Mon Sep 17 00:00:00 2001 From: javiexin Date: Mon, 4 May 2015 20:34:54 +0200 Subject: [PATCH 2/3] [ticket/13795] Modify core event in posting to include poll data Modified the core.posting_modify_template_vars event in posting.php to extend the content of the page_data array to include poll data. That required moving the event and merging the new set of template vars. Also include the poll variable in the parameter list for event core.posting_modify_submission_errors, as it was missing, and any modification here on post_data for poll related data is silently ignored. PHPBB3-13795 --- phpBB/posting.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/posting.php b/phpBB/posting.php index 20cb14b4b5..1ee4e0c22a 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1238,6 +1238,7 @@ if ($submit || $preview || $refresh) * * @event core.posting_modify_submission_errors * @var array post_data Array with post data + * @var array poll Array with poll data from post (must be used instead of the post_data equivalent) * @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 @@ -1251,6 +1252,7 @@ if ($submit || $preview || $refresh) */ $vars = array( 'post_data', + 'poll', 'mode', 'page_title', 'post_id', From e80bb565ce3cecbb30880e626afd614a83292616 Mon Sep 17 00:00:00 2001 From: javiexin Date: Thu, 28 May 2015 14:39:22 +0200 Subject: [PATCH 3/3] [ticket/13795] Modify core event in posting to include poll data Modified the core.posting_modify_template_vars event in posting.php to extend the content of the page_data array to include poll data. That required moving the event and merging the new set of template vars. Also include the poll variable in the parameter list for event core.posting_modify_submission_errors, as it was missing, and any modification here on post_data for poll related data is silently ignored. Added correct @change tags to both events. PHPBB3-13795 --- phpBB/posting.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 1ee4e0c22a..2d44e0b6e7 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1249,6 +1249,7 @@ if ($submit || $preview || $refresh) * @var array error Any error strings; a non-empty array aborts form submission. * NOTE: Should be actual language strings, NOT language keys. * @since 3.1.0-RC5 + * @change 3.1.5-RC1 Added poll array to the event */ $vars = array( 'post_data', @@ -1848,7 +1849,7 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_ * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser * @change 3.1.2-RC1 Removed 'delete' var as it does not exist -* @change 3.1.4-RC1 Added poll variables to the page_data array +* @change 3.1.5-RC1 Added poll variables to the page_data array */ $vars = array( 'post_data',