aboutsummaryrefslogtreecommitdiff
path: root/mod/messages/actions
diff options
context:
space:
mode:
Diffstat (limited to 'mod/messages/actions')
-rw-r--r--mod/messages/actions/delete.php132
-rw-r--r--mod/messages/actions/send.php109
2 files changed, 117 insertions, 124 deletions
diff --git a/mod/messages/actions/delete.php b/mod/messages/actions/delete.php
index 17bae2808..e8a7dfd58 100644
--- a/mod/messages/actions/delete.php
+++ b/mod/messages/actions/delete.php
@@ -1,73 +1,69 @@
<?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
+* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+* @author Curverider Ltd <info@elgg.com>
+* @copyright Curverider Ltd 2008-2010
+* @link http://elgg.com/
+*/
- /**
- * 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
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.com/
- */
-
- // Need to be logged in to do this
- gatekeeper();
-
- // 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');
+// Need to be logged in to do this
+gatekeeper();
+
+// 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;
+ }
+ }
- foreach($message_id_array as $message_id) {
+ }else{
- // 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;
-
- }
+ // 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=" . $_SESSION['user']->username . "&offset={$offset}");
- }
- } else {
- register_error(elgg_echo("messages:notfound"));
- forward($_SERVER['HTTP_REFERER']);
- }
-
-
-?> \ No newline at end of file
+ }
+
+}
+
+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=" . $_SESSION['user']->username . "&offset={$offset}");
+ }
+} else {
+ register_error(elgg_echo("messages:notfound"));
+ forward($_SERVER['HTTP_REFERER']);
+} \ No newline at end of file
diff --git a/mod/messages/actions/send.php b/mod/messages/actions/send.php
index e48703e5a..cf9de8ba5 100644
--- a/mod/messages/actions/send.php
+++ b/mod/messages/actions/send.php
@@ -1,64 +1,61 @@
<?php
+/**
+* Elgg send a message action page
+*
+* @package ElggMessages
+* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+* @author Curverider Ltd <info@elgg.com>
+* @copyright Curverider Ltd 2008-2010
+* @link http://elgg.com/
+*/
- /**
- * Elgg send a message action page
- *
- * @package ElggMessages
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010
- * @link http://elgg.com/
- */
-
- // Make sure we're logged in (send us to the front page if not)
- if (!isloggedin()) forward();
+// Make sure we're logged in (send us to the front page if not)
+if (!isloggedin()) forward();
- // Get input data
- $title = 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;
+// Get input data
+$title = 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
- 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");
- }
+// Cache to the session to make form sticky
+$_SESSION['msg_to'] = $send_to;
+$_SESSION['msg_title'] = $title;
+$_SESSION['msg_contents'] = $message_contents;
- // 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");
- }
+if (empty($send_to)) {
+ register_error(elgg_echo("messages:user:blank"));
+ 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"));
+$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']);
- // Forward to the users inbox
- forward('mod/messages/sent.php');
+// Success message
+system_message(elgg_echo("messages:posted"));
-?>
+// Forward to the users inbox
+forward('mod/messages/sent.php'); \ No newline at end of file