[ticket/416] Add method for handling ajax requests
B3P-416
This commit is contained in:
@@ -542,8 +542,7 @@ class portal_module
|
|||||||
$this->template->set_filenames(array(
|
$this->template->set_filenames(array(
|
||||||
'body' => 'portal/acp_portal_modules.html')
|
'body' => 'portal/acp_portal_modules.html')
|
||||||
);
|
);
|
||||||
$json_response = new \phpbb\json_response;
|
$this->modules_manager->handle_ajax_request(array(
|
||||||
$json_response->send(array(
|
|
||||||
'MESSAGE_BODY' => $this->template->assign_display('body'),
|
'MESSAGE_BODY' => $this->template->assign_display('body'),
|
||||||
'MESSAGE_TITLE' => $this->user->lang['ADD_MODULE'],
|
'MESSAGE_TITLE' => $this->user->lang['ADD_MODULE'],
|
||||||
'MESSAGE_TEXT' => $this->user->lang['ADD_MODULE'],
|
'MESSAGE_TEXT' => $this->user->lang['ADD_MODULE'],
|
||||||
|
|||||||
@@ -113,6 +113,23 @@ class manager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ajax request.
|
||||||
|
* Method will return supplied data if request is an ajax request
|
||||||
|
*
|
||||||
|
* @param array $data Data to send
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function handle_ajax_request($data)
|
||||||
|
{
|
||||||
|
if ($this->request->is_ajax())
|
||||||
|
{
|
||||||
|
$json_response = new \phpbb\json_response;
|
||||||
|
$json_response->send($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset module settings to default options
|
* Reset module settings to default options
|
||||||
*
|
*
|
||||||
@@ -188,11 +205,9 @@ class manager
|
|||||||
|
|
||||||
$this->cache->destroy('portal_modules');
|
$this->cache->destroy('portal_modules');
|
||||||
|
|
||||||
if ($this->request->is_ajax())
|
// Handle ajax requests
|
||||||
{
|
$this->handle_ajax_request(array('success' => true));
|
||||||
$json_response = new \phpbb\json_response;
|
|
||||||
$json_response->send(array('success' => true));
|
|
||||||
}
|
|
||||||
redirect($this->u_action); // redirect in order to get rid of excessive URL parameters
|
redirect($this->u_action); // redirect in order to get rid of excessive URL parameters
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,15 +514,13 @@ class manager
|
|||||||
|
|
||||||
$this->cache->purge(); // make sure we don't get errors after re-adding a module
|
$this->cache->purge(); // make sure we don't get errors after re-adding a module
|
||||||
|
|
||||||
if ($this->request->is_ajax())
|
// Handle ajax request
|
||||||
{
|
$this->handle_ajax_request(array(
|
||||||
$json_response = new \phpbb\json_response;
|
|
||||||
$json_response->send(array(
|
|
||||||
'success' => true,
|
'success' => true,
|
||||||
'MESSAGE_TITLE' => $this->user->lang['INFORMATION'],
|
'MESSAGE_TITLE' => $this->user->lang['INFORMATION'],
|
||||||
'MESSAGE_TEXT' => $this->user->lang['SUCCESS_DELETE'],
|
'MESSAGE_TEXT' => $this->user->lang['SUCCESS_DELETE'],
|
||||||
));
|
));
|
||||||
}
|
|
||||||
trigger_error($this->user->lang['SUCCESS_DELETE'] . adm_back_link($this->u_action));
|
trigger_error($this->user->lang['SUCCESS_DELETE'] . adm_back_link($this->u_action));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user