From d8e21952fa4660ba2ccc6587bef6275c8cddab37 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 19 Feb 2012 17:07:24 +0000 Subject: [PATCH] [ticket/10273] Fixed accepting / denying posts AJAX. PHPBB3-10273 --- phpBB/includes/mcp/mcp_queue.php | 31 +++++++++++++++++++++++-- phpBB/styles/prosilver/template/ajax.js | 5 ++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index ef32b5f03c..59fa8b7263 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -451,6 +451,7 @@ function approve_post($post_id_list, $id, $mode) { global $db, $template, $user, $config; global $phpEx, $phpbb_root_path; + global $request; if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) { @@ -709,7 +710,20 @@ function approve_post($post_id_list, $id, $mode) $add_message = '

' . sprintf($user->lang['RETURN_POST'], '', ''); } - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message); + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '') . $add_message; + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'approved' => true + )); + } + + trigger_error($message); } } @@ -968,7 +982,20 @@ function disapprove_post($post_id_list, $id, $mode) } else { + $message = $user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", ''); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => null, + 'approved' => false + )); + } + meta_refresh(3, $redirect); - trigger_error($user->lang[$success_msg] . '

' . sprintf($user->lang['RETURN_PAGE'], "", '')); + trigger_error($message); } } diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index f82da9f70e..f42c37fbce 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -17,8 +17,9 @@ phpbb.add_ajax_callback('post_delete', function() { }); // This callback removes the approve / disapprove div or link. -phpbb.add_ajax_callback('post_approve', function(res, act) { - $(this).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { +phpbb.add_ajax_callback('post_approve', function(res) { + var remove = (res.approved) ? $(this) : $(this).parents('.post'); + $(remove).fadeOut(function() { $(this).remove(); }); });