aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/actions/add.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 05:19:31 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 05:19:31 +0000
commit458af185465d2fb2377b0c2151627e0a9b9eb65a (patch)
tree65f1868aa6b8e4222d22ee1583163e9214292170 /mod/messageboard/actions/add.php
parent0d4fe65e8ebb11a44fa33b72c4e32cc89e58a25f (diff)
downloadelgg-458af185465d2fb2377b0c2151627e0a9b9eb65a.tar.gz
elgg-458af185465d2fb2377b0c2151627e0a9b9eb65a.tar.bz2
Refs #2916: Moved messageboard js into elgg.messageboard object. Moved forms into forms/messageboard. Can post now, but wow this plugin needs cleaned up.
git-svn-id: http://code.elgg.org/elgg/trunk@8320 36083f99-b078-4883-b0ff-0f9b5a30f544
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);