aboutsummaryrefslogtreecommitdiff
path: root/mod/messages/actions
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-15 22:28:46 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-01-15 22:28:46 +0000
commit43c33492d2ab65a783c17559cf8dabd7832e9ea1 (patch)
tree7107fed1b5424db1405b842972c7e4c47f11bfd3 /mod/messages/actions
parente8d148970261207efbe5435e1abcf68c5ed59cc8 (diff)
downloadelgg-43c33492d2ab65a783c17559cf8dabd7832e9ea1.tar.gz
elgg-43c33492d2ab65a783c17559cf8dabd7832e9ea1.tar.bz2
Updated the messages plugin to use the new CSS/HTML
git-svn-id: http://code.elgg.org/elgg/trunk@7886 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/messages/actions')
-rw-r--r--mod/messages/actions/delete.php62
-rw-r--r--mod/messages/actions/messages/delete.php20
-rw-r--r--mod/messages/actions/messages/process.php35
-rw-r--r--mod/messages/actions/messages/send.php46
-rw-r--r--mod/messages/actions/send.php57
5 files changed, 101 insertions, 119 deletions
diff --git a/mod/messages/actions/delete.php b/mod/messages/actions/delete.php
deleted file mode 100644
index 4ccc1d2ba..000000000
--- a/mod/messages/actions/delete.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-/**
-* Elgg delete a message action page
-* It is worth noting that due to the nature of a messaging system and the fact 2 people access
-* the same message, messages don't actually delete, they are just removed from view for the user who deletes
-*
-* @package ElggMessages
-*/
-
-// grab details sent from the form
-$message_id_array = get_input('message_id');
-if (!is_array($message_id_array)) $message_id_array = array($message_id_array);
-$type = get_input('type'); // sent message or inbox
-$success = true;
-$submit = get_input('submit');
-$offset = get_input('offset');
-
-foreach($message_id_array as $message_id) {
-
-// get the message object
- $message = get_entity($message_id);
-
-// Make sure we actually have permission to edit and that the object is of sub-type messages
- if ($message && $message->getSubtype() == "messages") {
-
- if ($submit == elgg_echo('delete')) {
- if ($message->delete()) {
- } else {
- $success = false;
- }
- } else {
- if ($message->readYet = 1) {
- } else {
- $success = false;
- }
- }
-
- }else{
-
- // display the error message
- $success = false;
-
- }
-
-}
-
-if ($success) {
- if ($submit == elgg_echo('delete')) {
- system_message(elgg_echo("messages:deleted"));
- } else {
- system_message(elgg_echo("messages:markedread"));
- }
- // check to see if it is a sent message to be deleted
- if($type == 'sent'){
- forward("mod/messages/sent.php?offset={$offset}");
- }else{
- forward("mod/messages/?username=" . get_loggedin_user()->username . "&offset={$offset}");
- }
-} else {
- register_error(elgg_echo("messages:notfound"));
- forward(REFERER);
-} \ No newline at end of file
diff --git a/mod/messages/actions/messages/delete.php b/mod/messages/actions/messages/delete.php
new file mode 100644
index 000000000..ffdb3b3a3
--- /dev/null
+++ b/mod/messages/actions/messages/delete.php
@@ -0,0 +1,20 @@
+<?php
+/**
+ * Delete message
+ */
+
+$guid = (int) get_input('guid');
+
+$message = get_entity($guid);
+if (!$message || !$message->canEdit()) {
+ register_error(elgg_echo('messages:error:delete:single'));
+ forward(REFERER);
+}
+
+if (!$message->delete()) {
+ register_error(elgg_echo('messages:error:delete:single'));
+} else {
+ system_message(elgg_echo('messages:success:delete:single'));
+}
+
+forward(REFERER);
diff --git a/mod/messages/actions/messages/process.php b/mod/messages/actions/messages/process.php
new file mode 100644
index 000000000..d929ae190
--- /dev/null
+++ b/mod/messages/actions/messages/process.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * Process a set of messages
+ */
+
+$message_ids = get_input('message_id', array());
+
+if (!$message_ids) {
+ register_error(elgg_echo('messages:error:messages_not_selected'));
+ forward(REFERER);
+}
+
+$delete_flag = get_input('delete', false);
+$read_flag = get_input('read', false);
+
+if ($delete_flag) {
+ $success_msg = elgg_echo('messages:success:delete');
+ foreach ($message_ids as $guid) {
+ $message = get_entity($guid);
+ if ($message && $message->getSubtype() == 'messages' && $message->canEdit()) {
+ $message->delete();
+ }
+ }
+} else {
+ $success_msg = elgg_echo('messages:success:read');
+ foreach ($message_ids as $guid) {
+ $message = get_entity($guid);
+ if ($message && $message->getSubtype() == 'messages' && $message->canEdit()) {
+ $message->readYet = 1;
+ }
+ }
+}
+
+system_message($success_msg);
+forward(REFERER);
diff --git a/mod/messages/actions/messages/send.php b/mod/messages/actions/messages/send.php
new file mode 100644
index 000000000..f6bac606d
--- /dev/null
+++ b/mod/messages/actions/messages/send.php
@@ -0,0 +1,46 @@
+<?php
+/**
+* Ssend a message action
+*
+* @package ElggMessages
+*/
+
+$subject = strip_tags(get_input('subject'));
+$body = get_input('body');
+$recipient_guid = get_input('recipient_guid');
+
+elgg_make_sticky_form('messages');
+
+//$reply = get_input('reply',0); // this is the guid of the message replying to
+
+if (!$recipient_guid) {
+ register_error(elgg_echo("messages:user:blank"));
+ forward("pg/messages/compose");
+}
+
+$user = get_user($recipient_guid);
+if (!$user) {
+ register_error(elgg_echo("messages:user:nonexist"));
+ forward("pg/messages/compose");
+}
+
+// Make sure the message field, send to field and title are not blank
+if (!$body || !$subject) {
+ register_error(elgg_echo("messages:blank"));
+ forward("pg/messages/compose");
+}
+
+// Otherwise, 'send' the message
+$result = messages_send($subject, $body, $recipient_guid, 0, $reply);
+
+// Save 'send' the message
+if (!$result) {
+ register_error(elgg_echo("messages:error"));
+ forward("pg/messages/compose");
+}
+
+elgg_clear_sticky_form('messages');
+
+system_message(elgg_echo("messages:posted"));
+
+forward('pg/messages/inbox/' . get_loggedin_user()->username);
diff --git a/mod/messages/actions/send.php b/mod/messages/actions/send.php
deleted file mode 100644
index 59d90a9d2..000000000
--- a/mod/messages/actions/send.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
-* Elgg send a message action page
-*
-* @package ElggMessages
-*/
-
-// Make sure we're logged in (send us to the front page if not)
-if (!isloggedin()) forward();
-
-// Get input data
-$title = strip_tags(get_input('title')); // message title
-$message_contents = get_input('message'); // the message
-$send_to = get_input('send_to'); // this is the user guid to whom the message is going to be sent
-$reply = get_input('reply',0); // this is the guid of the message replying to
-
-// Cache to the session to make form sticky
-$_SESSION['msg_to'] = $send_to;
-$_SESSION['msg_title'] = $title;
-$_SESSION['msg_contents'] = $message_contents;
-
-if (empty($send_to)) {
- register_error(elgg_echo("messages:user:blank"));
- forward("mod/messages/send.php");
-}
-
-$user = get_user($send_to);
-if (!$user) {
- register_error(elgg_echo("messages:user:nonexist"));
- forward("mod/messages/send.php");
-}
-
-// Make sure the message field, send to field and title are not blank
-if (empty($message_contents) || empty($title)) {
- register_error(elgg_echo("messages:blank"));
- forward("mod/messages/send.php");
-}
-
-// Otherwise, 'send' the message
-$result = messages_send($title,$message_contents,$send_to,0,$reply);
-
-// Save 'send' the message
-if (!$result) {
- register_error(elgg_echo("messages:error"));
- forward("mod/messages/send.php");
-}
-
-// successful so uncache form values
-unset($_SESSION['msg_to']);
-unset($_SESSION['msg_title']);
-unset($_SESSION['msg_contents']);
-
-// Success message
-system_message(elgg_echo("messages:posted"));
-
-// Forward to the users inbox
-forward('mod/messages/sent.php');