aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/actions
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 19:31:34 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 19:31:34 +0000
commit02a52af62e1579ad174b1160071b82ec11ee31e3 (patch)
treecd14f5338df64b69dffb03499ce7222f93c9f988 /mod/messageboard/actions
parent93cf8041ef996eae3912116cee572f7ff26efc92 (diff)
downloadelgg-02a52af62e1579ad174b1160071b82ec11ee31e3.tar.gz
elgg-02a52af62e1579ad174b1160071b82ec11ee31e3.tar.bz2
Refs #2916. More cleanup of the messageboard widget.
git-svn-id: http://code.elgg.org/elgg/trunk@8344 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/messageboard/actions')
-rw-r--r--mod/messageboard/actions/add.php21
-rw-r--r--mod/messageboard/actions/delete.php29
2 files changed, 22 insertions, 28 deletions
diff --git a/mod/messageboard/actions/add.php b/mod/messageboard/actions/add.php
index 5a34904d7..55bc5775a 100644
--- a/mod/messageboard/actions/add.php
+++ b/mod/messageboard/actions/add.php
@@ -10,15 +10,28 @@ $owner_guid = get_input("owner_guid");
$owner = get_entity($owner_guid);
if ($owner && !empty($message_content)) {
- if (messageboard_add(elgg_get_logged_in_user_entity(), $owner, $message_content, $owner->access_id)) {
+ $result = messageboard_add(elgg_get_logged_in_user_entity(), $owner, $message_content, $owner->access_id);
+
+ if ($result) {
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));
+ // always return the entity with the full ul and li
+ // this is parsed out as needed by js.
+ // if this is the only post we need to return the entire ul
+ $options = array(
+ 'annotations_name' => 'messageboard',
+ 'guid' => $owner->getGUID(),
+ 'limit' => $num_display,
+ 'pagination' => false,
+ 'reverse_order_by' => true,
+ 'limit' => 1
+ );
+
+ $output = elgg_list_annotations($options);
+ echo json_encode(array('post' => $output));
}
} else {
diff --git a/mod/messageboard/actions/delete.php b/mod/messageboard/actions/delete.php
index 1cc20f285..a40329cb5 100644
--- a/mod/messageboard/actions/delete.php
+++ b/mod/messageboard/actions/delete.php
@@ -1,37 +1,18 @@
<?php
-
/**
* Elgg Message board: delete message action
*
* @package ElggMessageBoard
*/
-// Make sure we can get the comment in question
$annotation_id = (int) get_input('annotation_id');
+$message = elgg_get_annotation_from_id($annotation_id);
-//make sure that there is a message on the message board matching the passed id
-if ($message = elgg_get_annotation_from_id($annotation_id)) {
-
- //grab the user or group entity
- $entity = get_entity($message->entity_guid);
-
- //check to make sure the current user can actually edit the message board
- if ($message->canEdit()) {
- //delete the comment
- $message->delete();
- // delete river entry
- remove_from_river_by_annotation($annotation_id);
- //display message
- system_message(elgg_echo("messageboard:deleted"));
- //generate the url to forward to
- $url = "pg/messageboard/" . $entity->username;
- //forward the user back to their message board
- forward($url);
- }
-
+if ($message && $message->canEdit() && $message->delete()) {
+ remove_from_river_by_annotation($annotation_id);
+ system_message(elgg_echo("messageboard:deleted"));
} else {
- $url = "";
system_message(elgg_echo("messageboard:notdeleted"));
}
-forward($url);
+forward(REFERER);