aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/actions.php
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2011-06-18 19:56:33 -0400
committerBrett Profitt <brett.profitt@gmail.com>2011-06-18 19:56:33 -0400
commitec7b94a64aef23b85866ecdac8e8acc712d29bb6 (patch)
treea108205c3fa0b694d8ce0ebaafd259480d6b530a /engine/lib/actions.php
parentc80ba5aa03264dd64c20ed8ae222e87f9371a44d (diff)
parent2b68a4d217c35a5587c462620789493cf2804ba2 (diff)
downloadelgg-ec7b94a64aef23b85866ecdac8e8acc712d29bb6.tar.gz
elgg-ec7b94a64aef23b85866ecdac8e8acc712d29bb6.tar.bz2
Merge branch 'master' of github.com:Elgg/Elgg
Diffstat (limited to 'engine/lib/actions.php')
-rw-r--r--engine/lib/actions.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 47e4dd4a4..ff598916f 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -152,6 +152,7 @@ function action($action, $forwarder = "") {
* @param string $filename Optionally, the filename where this action is located. If not specified,
* will assume the action is in elgg/actions/<action>.php
* @param string $access Who is allowed to execute this action: admin, public, or logged_in.
+ * (default: logged_in)
*
* @see action()
* @see http://docs.elgg.org/Actions
@@ -411,6 +412,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,12 +434,15 @@ 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;
}
header("Content-type: application/json");