aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/actions
diff options
context:
space:
mode:
Diffstat (limited to 'mod/messageboard/actions')
-rw-r--r--mod/messageboard/actions/add.php38
-rw-r--r--mod/messageboard/actions/delete.php17
2 files changed, 55 insertions, 0 deletions
diff --git a/mod/messageboard/actions/add.php b/mod/messageboard/actions/add.php
new file mode 100644
index 000000000..971dd22fc
--- /dev/null
+++ b/mod/messageboard/actions/add.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Elgg Message board: add message action
+ *
+ * @package ElggMessageBoard
+ */
+
+$message_content = get_input('message_content');
+$owner_guid = get_input("owner_guid");
+$owner = get_entity($owner_guid);
+
+if ($owner && !empty($message_content)) {
+ $result = messageboard_add(elgg_get_logged_in_user_entity(), $owner, $message_content, $owner->access_id);
+
+ if ($result) {
+ system_message(elgg_echo("messageboard:posted"));
+
+ $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 $output;
+
+ } else {
+ register_error(elgg_echo("messageboard:failure"));
+ }
+
+} else {
+ register_error(elgg_echo("messageboard:blank"));
+}
+
+forward(REFERER);
diff --git a/mod/messageboard/actions/delete.php b/mod/messageboard/actions/delete.php
new file mode 100644
index 000000000..a1f62278c
--- /dev/null
+++ b/mod/messageboard/actions/delete.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Elgg Message board: delete message action
+ *
+ * @package ElggMessageBoard
+ */
+
+$annotation_id = (int) get_input('annotation_id');
+$message = elgg_get_annotation_from_id($annotation_id);
+
+if ($message && $message->canEdit() && $message->delete()) {
+ system_message(elgg_echo("messageboard:deleted"));
+} else {
+ system_message(elgg_echo("messageboard:notdeleted"));
+}
+
+forward(REFERER);