mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/13827] Correctly return JSON instead of HTML when valled from AJAX
PHPBB3-13827
This commit is contained in:
parent
0e7448e2b3
commit
66279e1a57
1 changed files with 20 additions and 3 deletions
|
@ -212,12 +212,29 @@ class helper
|
||||||
public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200)
|
public function message($message, array $parameters = array(), $title = 'INFORMATION', $code = 200)
|
||||||
{
|
{
|
||||||
array_unshift($parameters, $message);
|
array_unshift($parameters, $message);
|
||||||
|
$message_text = call_user_func_array(array($this->user, 'lang'), $parameters);
|
||||||
|
$message_title = $this->user->lang($title);
|
||||||
|
|
||||||
|
if ($this->request->is_ajax())
|
||||||
|
{
|
||||||
|
global $refresh_data;
|
||||||
|
|
||||||
|
$json_response = new \phpbb\json_response;
|
||||||
|
$json_response->send(array(
|
||||||
|
'MESSAGE_TITLE' => $message_title,
|
||||||
|
'MESSAGE_TEXT' => $message_text,
|
||||||
|
'S_USER_WARNING' => false,
|
||||||
|
'S_USER_NOTICE' => false,
|
||||||
|
'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$this->template->assign_vars(array(
|
$this->template->assign_vars(array(
|
||||||
'MESSAGE_TEXT' => call_user_func_array(array($this->user, 'lang'), $parameters),
|
'MESSAGE_TEXT' => $message_text,
|
||||||
'MESSAGE_TITLE' => $this->user->lang($title),
|
'MESSAGE_TITLE' => $message_title,
|
||||||
));
|
));
|
||||||
|
|
||||||
return $this->render('message_body.html', $this->user->lang($title), $code);
|
return $this->render('message_body.html', $message_title, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue