1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-09 16:05:00 +02:00

[ticket/10273] Fixed accepting / denying posts AJAX.

PHPBB3-10273
This commit is contained in:
Callum Macrae 2012-02-19 17:07:24 +00:00 committed by Igor Wiedler
parent 64df9d1406
commit d8e21952fa
2 changed files with 32 additions and 4 deletions

View File

@ -451,6 +451,7 @@ function approve_post($post_id_list, $id, $mode)
{ {
global $db, $template, $user, $config; global $db, $template, $user, $config;
global $phpEx, $phpbb_root_path; global $phpEx, $phpbb_root_path;
global $request;
if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_approve'))) 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 = '<br /><br />' . sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>'); $add_message = '<br /><br />' . sprintf($user->lang['RETURN_POST'], '<a href="' . $post_url . '">', '</a>');
} }
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>') . $add_message); $message = $user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>') . $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 else
{ {
$message = $user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>');
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); meta_refresh(3, $redirect);
trigger_error($user->lang[$success_msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], "<a href=\"$redirect\">", '</a>')); trigger_error($message);
} }
} }

View File

@ -17,8 +17,9 @@ phpbb.add_ajax_callback('post_delete', function() {
}); });
// This callback removes the approve / disapprove div or link. // This callback removes the approve / disapprove div or link.
phpbb.add_ajax_callback('post_approve', function(res, act) { phpbb.add_ajax_callback('post_approve', function(res) {
$(this).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { var remove = (res.approved) ? $(this) : $(this).parents('.post');
$(remove).fadeOut(function() {
$(this).remove(); $(this).remove();
}); });
}); });