aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/actions.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/actions.php')
-rw-r--r--engine/lib/actions.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 47e4dd4a4..df7c92de4 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -411,6 +411,16 @@ function elgg_is_xhr() {
*/
function ajax_forward_hook($hook, $type, $reason, $params) {
if (elgg_is_xhr()) {
+ // always pass the full structure to avoid boilerplate JS code.
+ $params = array(
+ 'output' => '',
+ 'status' => 0,
+ 'system_messages' => array(
+ 'error' => array(),
+ 'success' => array()
+ )
+ );
+
//grab any data echo'd in the action
$output = ob_get_clean();
@@ -423,9 +433,14 @@ function ajax_forward_hook($hook, $type, $reason, $params) {
}
//Grab any system messages so we can inject them via ajax too
- $params['system_messages'] = system_messages(NULL, "");
+ $system_messages = system_messages(NULL, "");
+
+ if (isset($system_messages['success'])) {
+ $params['system_messages']['success'] = $system_messages['success'];
+ }
- if (isset($params['system_messages']['error'])) {
+ if (isset($system_messages['error'])) {
+ $params['system_messages']['error'] = $system_messages['error'];
$params['status'] = -1;
} else {
$params['status'] = 0;