aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/actions/add.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/messageboard/actions/add.php')
-rw-r--r--mod/messageboard/actions/add.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/mod/messageboard/actions/add.php b/mod/messageboard/actions/add.php
index 1058482d9..5a34904d7 100644
--- a/mod/messageboard/actions/add.php
+++ b/mod/messageboard/actions/add.php
@@ -1,30 +1,32 @@
<?php
-
/**
* Elgg Message board: add message action
*
* @package ElggMessageBoard
*/
-// Get input
-$message_content = get_input('message_content'); // the actual message
-$page_owner = get_input("pageOwner"); // the message board owner
-$user = get_entity($page_owner); // the message board owner's details
-
-// Let's see if we can get a user entity from the specified page_owner
-if ($user && !empty($message_content)) {
+$message_content = get_input('message_content');
+$owner_guid = get_input("owner_guid");
+$owner = get_entity($owner_guid);
- if (messageboard_add(elgg_get_logged_in_user_entity(), $user, $message_content, $user->access_id)) {
+if ($owner && !empty($message_content)) {
+ if (messageboard_add(elgg_get_logged_in_user_entity(), $owner, $message_content, $owner->access_id)) {
system_message(elgg_echo("messageboard:posted"));
+
+ // push the newest content out if using ajax
+ $is_ajax = array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
+ if ($is_ajax) {
+ $contents = $owner->getAnnotations('messageboard', 1, 0, 'desc');
+ $post = elgg_view("messageboard/messageboard_content", array('annotation' => $contents[0]));
+ echo json_encode(array('post' => $post));
+ }
+
} else {
register_error(elgg_echo("messageboard:failure"));
}
-
-} else {
+} else {
register_error(elgg_echo("messageboard:blank"));
-
}
-// Forward back to the messageboard
forward(REFERER);