From 4766f36a4d74924f21ff329c4318ce4e069ffa04 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 3 Mar 2010 17:53:05 +0000 Subject: Pulled in the interface changes. git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/messages/actions/send.php | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 mod/messages/actions/send.php (limited to 'mod/messages/actions/send.php') diff --git a/mod/messages/actions/send.php b/mod/messages/actions/send.php new file mode 100644 index 000000000..e48703e5a --- /dev/null +++ b/mod/messages/actions/send.php @@ -0,0 +1,64 @@ + + * @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(); + + // 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; + + 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'); + +?> -- cgit v1.2.3