]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Updated the messages plugin to use the new CSS/HTML
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 15 Jan 2011 22:28:46 +0000 (22:28 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Sat, 15 Jan 2011 22:28:46 +0000 (22:28 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7886 36083f99-b078-4883-b0ff-0f9b5a30f544

26 files changed:
mod/messages/actions/delete.php [deleted file]
mod/messages/actions/messages/delete.php [new file with mode: 0644]
mod/messages/actions/messages/process.php [new file with mode: 0644]
mod/messages/actions/messages/send.php [new file with mode: 0644]
mod/messages/actions/send.php [deleted file]
mod/messages/inbox.php [new file with mode: 0644]
mod/messages/index.php [deleted file]
mod/messages/languages/en.php
mod/messages/lib/messages.php [new file with mode: 0644]
mod/messages/read.php
mod/messages/readme.txt
mod/messages/send.php
mod/messages/sent.php
mod/messages/start.php
mod/messages/views/default/forms/messages/process.php [new file with mode: 0644]
mod/messages/views/default/forms/messages/reply.php [new file with mode: 0644]
mod/messages/views/default/forms/messages/send.php [new file with mode: 0644]
mod/messages/views/default/messages/css.php
mod/messages/views/default/messages/forms/reply.php [deleted file]
mod/messages/views/default/messages/forms/send.php [deleted file]
mod/messages/views/default/messages/forms/view.php [deleted file]
mod/messages/views/default/messages/menu.php [deleted file]
mod/messages/views/default/messages/messages.php [deleted file]
mod/messages/views/default/messages/topbar.php
mod/messages/views/default/messages/view.php [deleted file]
mod/messages/views/default/object/messages.php [new file with mode: 0644]

diff --git a/mod/messages/actions/delete.php b/mod/messages/actions/delete.php
deleted file mode 100644 (file)
index 4ccc1d2..0000000
+++ /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 (file)
index 0000000..ffdb3b3
--- /dev/null
@@ -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 (file)
index 0000000..d929ae1
--- /dev/null
@@ -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 (file)
index 0000000..f6bac60
--- /dev/null
@@ -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 (file)
index 59d90a9..0000000
+++ /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');
diff --git a/mod/messages/inbox.php b/mod/messages/inbox.php
new file mode 100644 (file)
index 0000000..b5c54a4
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Elgg messages inbox page
+ *
+ * @package ElggMessages
+*/
+
+gatekeeper();
+
+$page_owner = elgg_get_page_owner();
+if (!$page_owner) {
+       register_error(elgg_echo());
+       forward();
+}
+
+elgg_push_breadcrumb(elgg_echo('messages:inbox'));
+
+$title = elgg_echo('messages:user', array($page_owner->name));
+
+$list = elgg_list_entities_from_metadata(array(
+       'type' => 'object',
+       'subtype' => 'messages',
+       'metadata_name' => 'toId',
+       'metadata_value' => elgg_get_page_owner_guid(),
+       'owner_guid' => elgg_get_page_owner_guid(),
+       'full_view' => false,
+));
+
+$body_vars = array(
+       'folder' => 'inbox',
+       'list' => $list,
+);
+$content = elgg_view_form('messages/process', array(), $body_vars);
+
+$body = elgg_view_layout('content', array(
+       'content' => $content,
+       'title' => elgg_echo('messages:inbox'),
+       'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/mod/messages/index.php b/mod/messages/index.php
deleted file mode 100644 (file)
index 0225755..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * Elgg messages inbox page
- *
- * @package ElggMessages
-*/
-
-
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-gatekeeper();
-global $CONFIG;
-
-$offset = get_input('offset', 0);
-$limit = 10;
-
-// Get the logged in user, you can't see other peoples messages so use session id
-$page_owner = get_loggedin_user();
-set_page_owner($page_owner->getGUID());
-
-// Get the user's inbox, this will be all messages where the 'toId' field matches their guid
-// @todo - fix hack where limit + 1 messages are requested
-$messages = elgg_get_entities_from_metadata(array(
-       'type' => 'object',
-       'subtype' => 'messages',
-       'metadata_name' => 'toId',
-       'metadata_value' => $page_owner->getGUID(),
-       'owner_guid' => $page_owner->guid,
-       'limit' => $limit + 1,
-       'offset' => $offset
-));
-
-// Set the page title
-$area2 = "<div id='content-header'><div class='content-header-title'>";
-$area2 .= elgg_view_title(elgg_echo("messages:inbox"))."</div>";
-$area2 .= "<div class='content-header-options'><a class='elgg-action-button' href='".elgg_get_site_url()."mod/messages/send.php'>" . elgg_echo('messages:compose') . "</a></div></div>";
-
-// Display them. The last variable 'page_view' is to allow the view page to know where this data is coming from,
-// in this case it is the inbox, this is necessary to ensure the correct display
-$area2 .= elgg_view("messages/forms/view",array('entity' => $messages, 'page_view' => "inbox", 'limit' => $limit, 'offset' => $offset));
-
-// Sidebar menu options
-//$area3 = elgg_view("messages/menu_options", array('context' => 'inbox'));
-
-// format
-$body = elgg_view_layout("one_column_with_sidebar", array('content' => $area2));
-
-
-// Draw page
-echo elgg_view_page(elgg_echo('messages:user', array($page_owner->name)), $body);
index f1ad226238a4828ff1f97a24c2c73d3326814b26..4ad6b761750ec35ee381e401827d0af5fd25e863 100644 (file)
@@ -12,14 +12,13 @@ $english = array(
 
        'messages' => "Messages",
        'messages:back' => "back to messages",
-       'messages:user' => "Your inbox",
-       'messages:sentMessages' => "Sent messages",
+       'messages:user' => "%s's inbox",
        'messages:posttitle' => "%s's messages: %s",
        'messages:inbox' => "Inbox",
-       'messages:send' => "Send a message",
-       'messages:sent' => "Sent messages",
+       'messages:send' => "Send",
+       'messages:sent' => "Sent",
        'messages:message' => "Message",
-       'messages:title' => "Title",
+       'messages:title' => "Subject",
        'messages:to' => "To",
        'messages:from' => "From",
        'messages:fly' => "Send",
@@ -27,6 +26,7 @@ $english = array(
        'messages:inbox' => "Inbox",
        'messages:sendmessage' => "Send a message",
        'messages:compose' => "Compose a message",
+       'messages:add' => "Compose a message",
        'messages:sentmessages' => "Sent messages",
        'messages:recent' => "Recent messages",
        'messages:original' => "Original message",
@@ -35,6 +35,7 @@ $english = array(
        'messages:toggle' => 'Toggle all',
        'messages:markread' => 'Mark read',
        'messages:recipient' => 'Choose a recipient&hellip;',
+       'messages:to_user' => 'To: %s',
 
        'messages:new' => 'New message',
 
@@ -49,8 +50,11 @@ $english = array(
        */
 
        'messages:posted' => "Your message was successfully sent.",
-       'messages:deleted' => "Your messages were successfully deleted.",
-       'messages:markedread' => "Your messages were successfully marked as read.",
+       'messages:success:delete:single' => 'Message was deleted',
+       'messages:success:delete' => 'Messages deleted',
+       'messages:success:read' => 'Messages marked as read',
+       'messages:error:messages_not_selected' => 'No messages selected',
+       'messages:error:delete:single' => 'Unable to delete the message',
 
        /**
        * Email messages
diff --git a/mod/messages/lib/messages.php b/mod/messages/lib/messages.php
new file mode 100644 (file)
index 0000000..062670f
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Messages helper functions
+ *
+ * @package ElggMessages
+ */
+
+/**
+ * Prepare the compose form variables
+ *
+ * @return array
+ */
+function messages_prepare_form_vars($recipient_guid = 0) {
+
+       // input names => defaults
+       $values = array(
+               'subject' => '',
+               'body' => '',
+               'recipient_guid' => $recipient_guid,
+       );
+
+       if (elgg_is_sticky_form('messages')) {
+               foreach (array_keys($values) as $field) {
+                       $values[$field] = elgg_get_sticky_value('messages', $field);
+               }
+       }
+
+       elgg_clear_sticky_form('messages');
+
+       return $values;
+}
+
index 4e404de5cbf231e395661d56a595a2a6588003a7..0c0fa60dd07484b035b2a53e27cc9f01a22d7455 100644 (file)
@@ -1,58 +1,56 @@
 <?php
 /**
-* Elgg read a message page
+* Read a message page
 *
 * @package ElggMessages
 */
 
-// Load Elgg engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// If we're not logged in, forward to the front page
 gatekeeper();
 
-$page_owner = get_loggedin_user();
-$mbox_type = get_input('type', 'inbox');
-
-// Get the full message object to read
-$message = get_entity(get_input("message"));
-
-// If no message, must have been deleted, send user to inbox/sent mail
+$message = get_entity(get_input('guid'));
 if (!$message) {
-       if ($mbox_type == 'sent') {
-               forward("mod/messages/sent.php");
-       } else {
-               forward("pg/messages/{$page_owner->username}");
-       }
-}
-
-// If the message is being read from the inbox, mark it as read, otherwise don't.
-// This stops a user who checks out a message they have sent having it being marked
-// as read for the recipient
-if($mbox_type != "sent"){
-       // Mark the message as being read now
-       if ($message->getSubtype() == "messages") {
-               //set the message metadata to 1 which equals read
-               $message->readYet = 1;
-       }
+       forward();
 }
 
-set_page_owner($page_owner->getGUID());
+elgg_set_page_owner_guid($message->getOwnerGUID());
+$page_owner = elgg_get_page_owner();
 
-// Display it
-$content = elgg_view("messages/messages",array(
-                                                                       'entity' => $message,
-                                                                       'entity_owner' => $page_owner,
-                                                                       'full' => true
-                                                                       ));
+$title = $message->title;
 
-$sidebar = elgg_view("messages/menu_options");
+$inbox = false;
+if ($page_owner->getGUID() == $message->toId) {
+       $inbox = true;
+       elgg_push_breadcrumb(elgg_echo('messages:inbox'), 'pg/messages/inbox/' . $page_owner->username);
+} else {
+       elgg_push_breadcrumb(elgg_echo('messages:sent'), 'pg/messages/sent/' . $page_owner->username);
+}
+elgg_push_breadcrumb($title);
+
+$buttons = '';
+$content = elgg_view_entity($message, true);
+if ($inbox) {
+       $form_params = array(
+               'internalid' => 'messages-reply-form',
+               'class' => 'hidden',
+               'action' => 'messages/send',
+       );
+       $body_params = array('message' => $message);
+       $content .= elgg_view_form('messages/reply', $form_params, $body_params);
+
+       if (get_loggedin_userid() == elgg_get_page_owner_guid()) {
+               $buttons = elgg_view('output/url', array(
+                       'text' => elgg_echo('messages:answer'),
+                       'class' => 'elgg-action-button',
+                       'internalid' => 'messages-show-reply',
+               ));
+       }
+}
 
-$params = array(
+$body = elgg_view_layout('content', array(
        'content' => $content,
-       'sidebar' => $sidebar
-);
-$body = elgg_view_layout("one_column_with_sidebar", $params);
+       'title' => $title,
+       'filter' => '',
+       'buttons' => $buttons,
+));
 
-// Display page
-echo elgg_view_page(elgg_echo('messages:message'), $body);
\ No newline at end of file
+echo elgg_view_page($title, $body);
index 04142be1971508002a8208b8974a55dc792b1d4c..9d267f3fbb6e86645e80835ef175e71ee2620419 100644 (file)
@@ -1,12 +1,11 @@
 /**
- * Elgg readme
+ * Elgg messages readme
  * 
  * @package ElggMessages
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Dave Tosh <dave@elgg.com>
- * @copyright Curverider Ltd 2008-2009
- * @link http://elgg.com/
-*/
+ * @author Dave Tosh <dave@elgg.org>
+ * @link http://elgg.org/
+ */
 
 Install: drop the plugin into your mod folder, that is it.
 
index 3e1baa496669bbf3e7deee0357aec9bef15be3e1..1f31e9e0277a377cc4bc5337c7a23002643cb253 100644 (file)
@@ -1,42 +1,28 @@
 <?php
 /**
-* Elgg send a message page
+* Compose a message
 *
 * @package ElggMessages
 */
 
-// Load Elgg engine
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-
-// If we're not logged in, forward to the front page
 gatekeeper();
 
-// Get the current page's owner
-$page_owner = elgg_get_page_owner();
-if ($page_owner === false || is_null($page_owner)) {
-       $page_owner = get_loggedin_user();
-       set_page_owner($page_owner->getGUID());
-}
-
-// Get the users friends; this is used in the drop down to select who to send the message to
-$user = get_loggedin_user();
-$friends = $user->getFriends('', 9999);
+$page_owner = get_loggedin_user();
+set_page_owner($page_owner->getGUID());
 
-// Set the page title
-$area2 = elgg_view_title(elgg_echo("messages:sendmessage"));
+$title = elgg_echo('messages:add');
 
-// Get the send form
-$area2 .= elgg_view("messages/forms/send",array('friends' => $friends));
+elgg_push_breadcrumb($title);
 
-// Sidebar menu options
-$area3 = elgg_view("messages/menu_options");
+$params = messages_prepare_form_vars(get_input('send_to'));
+$params['friends'] = $page_owner->getFriends();
+$content = elgg_view_form('messages/send', array(), $params);
 
-// Format
-$params = array(
-       'content' => $area2,
-       'sidebar' => $area3
-);
-$body = elgg_view_layout("one_column_with_sidebar", $params);
+$body = elgg_view_layout('content', array(
+       'content' => $content,
+       'title' => $title,
+       'filter' => '',
+       'buttons' => '',
+));
 
-// Draw page
-echo elgg_view_page(elgg_echo('messages:send', array($page_owner->name)), $body);
\ No newline at end of file
+echo elgg_view_page($title, $body);
index e70d34711d00ae80bcde40c30edebab08f8c8bdd..36c9badd3bde59d5ef7ae2ae50e92311acfd4f46 100644 (file)
@@ -5,36 +5,37 @@
 * @package ElggMessages
 */
 
-require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
-global $CONFIG;
-
 gatekeeper();
 
-// Get the logged in user
-$page_owner = get_loggedin_user();
-set_page_owner($page_owner->guid);
-
-// Get offset
-$offset = get_input('offset',0);
-
-// Set limit
-$limit = 10;
-
-// Display all the messages a user owns, these will make up the sentbox
-// @todo - fix hack where limit + 1 is passed
-$messages = elgg_get_entities_from_metadata(array('metadata_name' => 'fromId', 'metadata_value' => get_loggedin_userid(), 'types' => 'object', 'subtypes' => 'messages', 'owner_guid' => $page_owner->guid, 'limit' => $limit + 1, 'offset' => $offset));
-
-
-// Set the page title
-$area2 = "<div id='content-header'><div class='content-header-title'>";
-$area2 .= elgg_view_title(elgg_echo("messages:sentmessages"))."</div>";
-$area2 .= "<div class='content-header-options'><a class='elgg-action-button' href='".elgg_get_site_url()."mod/messages/send.php'>" . elgg_echo('messages:compose') . "</a></div></div>";
-
-// Set content
-$area2 .= elgg_view("messages/forms/view",array('entity' => $messages, 'page_view' => "sent", 'limit' => $limit, 'offset' => $offset));
-
-// Format
-$body = elgg_view_layout("one_column_with_sidebar", array('content' => $area2));
-
-// Draw page
-echo elgg_view_page(elgg_echo('messages:sentMessages', array($page_owner->name)), $body);
+$page_owner = elgg_get_page_owner();
+if (!$page_owner) {
+       register_error(elgg_echo());
+       forward();
+}
+
+elgg_push_breadcrumb(elgg_echo('messages:sent'));
+
+$title = elgg_echo('messages:sentmessages', array($page_owner->name));
+
+$list = elgg_list_entities_from_metadata(array(
+       'type' => 'object',
+       'subtype' => 'messages',
+       'metadata_name' => 'fromId',
+       'metadata_value' => elgg_get_page_owner_guid(),
+       'owner_guid' => elgg_get_page_owner_guid(),
+       'full_view' => false,
+));
+
+$body_vars = array(
+       'folder' => 'sent',
+       'list' => $list,
+);
+$content = elgg_view_form('messages/process', array(), $body_vars);
+
+$body = elgg_view_layout('content', array(
+       'content' => $content,
+       'title' => $title,
+       'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
index cf17ee0131405e16bbc466329c1bc91cb4ba7844..ccb92d94f2b4821fe1025089ac9871a080ca7681 100644 (file)
@@ -11,19 +11,24 @@ elgg_register_event_handler('init', 'system', 'messages_init');
 
 function messages_init() {
 
+       // register a library of helper functions
+       elgg_register_library('elgg:messages', elgg_get_plugin_path() . 'messages/lib/messages.php');
+
        // add page menu items
-       elgg_register_menu_item('page', array(
-               'name' => 'messages:inbox',
-               'title' => elgg_echo('messages:inbox'),
-               'url' => "pg/messages/" . get_loggedin_user()->username,
-               'context' => 'messages',
-       ));
-       elgg_register_menu_item('page', array(
-               'name' => 'messages:sentmessages',
-               'title' => elgg_echo('messages:sentmessages'),
-               'url' => "mod/messages/sent.php",
-               'context' => 'messages',
-       ));
+       if (isloggedin()) {
+               elgg_register_menu_item('page', array(
+                       'name' => 'messages:inbox',
+                       'title' => elgg_echo('messages:inbox'),
+                       'url' => "pg/messages/inbox/" . get_loggedin_user()->username,
+                       'context' => 'messages',
+               ));
+               elgg_register_menu_item('page', array(
+                       'name' => 'messages:sentmessages',
+                       'title' => elgg_echo('messages:sentmessages'),
+                       'url' => "pg/messages/sent/" . get_loggedin_user()->username,
+                       'context' => 'messages',
+               ));
+       }
 
        // Extend system CSS with our own styles, which are defined in the shouts/css view
        elgg_extend_view('css/screen', 'messages/css');
@@ -54,9 +59,10 @@ function messages_init() {
        elgg_register_plugin_hook_handler('container_permissions_check', 'object', 'messages_can_edit_container');
 
        // Register actions
-       $action_path = elgg_get_plugin_path() . 'messages/actions';
+       $action_path = elgg_get_plugin_path() . 'messages/actions/messages';
        elgg_register_action("messages/send", "$action_path/send.php");
        elgg_register_action("messages/delete", "$action_path/delete.php");
+       elgg_register_action("messages/process", "$action_path/process.php");
 }
 
 /**
@@ -67,27 +73,49 @@ function messages_init() {
  */
 function messages_page_handler($page) {
 
-       // The first component of a messages URL is the username
-       if (isset($page[0])) {
-               set_input('username', $page[0]);
+       elgg_load_library('elgg:messages');
+
+       elgg_push_breadcrumb(elgg_echo('messages'), 'pg/messages/inbox/' . get_loggedin_user()->username);
+
+       if (!isset($page[0])) {
+               $page[0] = 'inbox';
        }
 
-       // The second part dictates what we're doing
-       if (isset($page[1])) {
-               switch($page[1]) {
-                       case "read":
-                               set_input('message',$page[2]);
-                               include(dirname(__FILE__) . "/read.php");
-                               return true;
-                               break;
-               }
-       // If the URL is just 'messages/username', or just 'messages/', load the standard messages index
-       } else {
-               include(dirname(__FILE__) . "/index.php");
-               return true;
+       // supporting the old inbox url /pg/messages/<username>
+       $user = get_user_by_username($page[0]);
+       if ($user) {
+               $page[1] = $page[0];
+               $page[0] = 'inbox';
+       }
+
+       if (!isset($page[1])) {
+               $page[1] = get_loggedin_user()->username;
        }
 
-       return false;
+       $base_dir = elgg_get_plugin_path() . 'messages';
+
+       switch ($page[0]) {
+               case 'inbox':
+                       set_input('username', $page[1]);
+                       include("$base_dir/inbox.php");
+                       break;
+               case 'sent':
+                       set_input('username', $page[1]);
+                       include("$base_dir/sent.php");
+                       break;
+               case 'read':
+                       set_input('guid', $page[1]);
+                       include("$base_dir/read.php");
+                       break;
+               case 'compose':
+               case 'add':
+                       include("$base_dir/send.php");
+                       break;
+               default:
+                       return false;
+       }
+
+       return true;
 }
 
 /**
@@ -239,9 +267,9 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify
                $body = elgg_echo('messages:email:body', array(
                        get_loggedin_user()->name,
                        $message_contents,
-                       elgg_get_site_url() . "pg/messages/" . $user->username,
+                       elgg_get_site_url() . "pg/messages/inbox/" . $user->username,
                        get_loggedin_user()->name,
-                       elgg_get_site_url() . "mod/messages/send.php?send_to=" . get_loggedin_userid()
+                       elgg_get_site_url() . "pg/messages/compose?send_to=" . get_loggedin_userid()
                ));
 
                notify_user($send_to, get_loggedin_userid(), $subject, $body);
@@ -258,8 +286,7 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify
  * @return string
  */
 function messages_url($message) {
-       $url = elgg_get_site_url() . 'pg/messages/';
-       $url .= $message->getOwnerEntity()->username . '/read/' . $message->getGUID();
+       $url = elgg_get_site_url() . 'pg/messages/read/' . $message->getGUID();
        return $url;
 }
 
@@ -322,7 +349,7 @@ function messages_user_hover_menu($hook, $type, $return, $params) {
        $user = $params['entity'];
 
        if (isloggedin() && get_loggedin_userid() != $user->guid) {
-               $url = "mod/messages/send.php?send_to={$user->guid}";
+               $url = "pg/messages/compose?send_to={$user->guid}";
                $item = new ElggMenuItem('send', elgg_echo('messages:sendmessage'), $url);
                $item->setSection('action');
                $return[] = $item;
diff --git a/mod/messages/views/default/forms/messages/process.php b/mod/messages/views/default/forms/messages/process.php
new file mode 100644 (file)
index 0000000..2c97fcb
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Messages folder view (inbox, sent)
+ *
+ * Provides form body for mass deleting messages
+ *
+ * @uses $vars['list'] List of messages
+ * 
+ */
+
+echo $vars['list'];
+
+echo '<div class="messages-buttonbank">';
+echo elgg_view('input/submit', array(
+       'value' => elgg_echo('delete'),
+       'internalname' => 'delete',
+));
+
+if ($vars['folder'] == "inbox") {
+       echo elgg_view('input/submit', array(
+               'value' => elgg_echo('messages:markread'),
+               'internalname' => 'read',
+       ));
+}
+
+echo elgg_view('input/button', array(
+       'value' => elgg_echo('messages:toggle'),
+       'class' => 'elgg-cancel-button',
+       'internalid' => 'messages-toggle',
+));
+
+echo '</div>';
+
+?>
+<script type="text/javascript">
+$(document).ready(function() {
+       $("#messages-toggle").click(function() {
+               $('input[type=checkbox]').click();
+       });
+});
+</script>
diff --git a/mod/messages/views/default/forms/messages/reply.php b/mod/messages/views/default/forms/messages/reply.php
new file mode 100644 (file)
index 0000000..22c982e
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Reply form
+ *
+ * @uses $vars['message']
+ */
+
+// fix for RE: RE: RE: that builds on replies
+$reply_title = $vars['message']->title;
+if (strncmp($reply_title, "RE:", 3) != 0) {
+       $reply_title = "RE: " . $reply_title;
+}
+
+echo elgg_view('input/hidden', array(
+       'internalname' => 'recipient_guid',
+       'value' => $vars['message']->fromId,
+));
+?>
+
+<p>
+       <label><?php echo elgg_echo("messages:title"); ?>: <br /></label>
+       <?php echo elgg_view('input/text', array(
+               'internalname' => 'subject',
+               'value' => $reply_title,
+       ));
+       ?>
+</p>
+<p>
+       <label><?php echo elgg_echo("messages:message"); ?>:</label>
+       <?php echo elgg_view("input/longtext", array(
+               'internalname' => 'body',
+               'value' => '',
+       ));
+       ?>
+</p>
+<p>
+       <?php echo elgg_view('input/submit', array('value' => elgg_echo('messages:send'))); ?>
+</p>
+
+<script type="text/javascript">
+$(document).ready(function() {
+       $("#messages-show-reply").click(function() {
+               $('#messages-reply-form').slideToggle('medium');
+       });
+});
+       
+</script>
\ No newline at end of file
diff --git a/mod/messages/views/default/forms/messages/send.php b/mod/messages/views/default/forms/messages/send.php
new file mode 100644 (file)
index 0000000..0a25109
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Compse message form
+ *
+ * @package ElggMessages
+ * @uses $vars['friends']
+ */
+
+$recipient_guid = elgg_get_array_value('recipient_guid', $vars, 0);
+$subject = elgg_get_array_value('subject', $vars, '');
+$body = elgg_get_array_value('body', $vars, '');
+
+$recipients_options = array();
+foreach ($vars['friends'] as $friend) {
+       $recipients_options[$friend->guid] = $friend->name;
+}
+
+$recipient_drop_down = elgg_view('input/pulldown', array(
+       'internalname' => 'recipient_guid',
+       'value' => $recipient_guid,
+       'options_values' => $recipients_options,
+));
+
+?>
+<p>
+       <label><?php echo elgg_echo("messages:to"); ?>: </label>
+       <?php echo $recipient_drop_down; ?>
+</p>
+<p>
+       <label><?php echo elgg_echo("messages:title"); ?>: <br /></label>
+       <?php echo elgg_view('input/text', array(
+               'internalname' => 'subject',
+               'value' => $subject,
+       ));
+       ?>
+</p>
+<p>
+       <label><?php echo elgg_echo("messages:message"); ?>:</label>
+       <?php echo elgg_view("input/longtext", array(
+               'internalname' => 'body',
+               'value' => $body,
+       ));
+       ?>
+</p>
+<p>
+       <?php echo elgg_view('input/submit', array('value' => elgg_echo('messages:send'))); ?>
+</p>
index 3e58c2607b6f9f508b2f86dea5cf36a1aa6eb51c..ba8444f03010d0667a6b0b9974101ab29e2ffee7 100644 (file)
@@ -6,84 +6,60 @@
  */
 ?>
 
-/* messages/new messages icon & counter in elgg-topbar */
-a.privatemessages {
-       background:transparent url(<?php echo elgg_get_site_url(); ?>mod/messages/graphics/toolbar_messages_icon.gif) no-repeat left 2px;
-       padding-left:16px;
-       margin:4px 15px 0 5px;
-       cursor:pointer;
-}
-a.privatemessages:hover {
-       text-decoration: none;
-       background:transparent url(<?php echo elgg_get_site_url(); ?>mod/messages/graphics/toolbar_messages_icon.gif) no-repeat left -36px;
+
+.message.unread a {
+       color: #d40005;
 }
-a.privatemessages.new {
-       background:transparent url(<?php echo elgg_get_site_url(); ?>mod/messages/graphics/toolbar_messages_icon.gif) no-repeat left 2px;
-       padding-left:18px;
-       margin:4px 15px 0 5px;
-       color:white;
+.messages-buttonbank {
+       text-align: right;
 }
-a.privatemessages.new:hover {
-       text-decoration: none;
-       background:transparent url(<?php echo elgg_get_site_url(); ?>mod/messages/graphics/toolbar_messages_icon.gif) no-repeat left -36px;
-}
-a.privatemessages.new span {
-       background-color: red;
-       -webkit-border-radius: 10px; 
-       -moz-border-radius: 10px;
-       -webkit-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.50); /* safari v3+ */
-       -moz-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.50); /* FF v3.5+ */
-       color:white;
-       display:block;
-       float:right;
-       padding:0;
-       position:relative;
-       text-align:center;
-       top:-3px;
-       right:5px;
-       min-width: 16px;
-       height:16px;
-       font-size:10px;
-       font-weight:bold;
+.messages-buttonbank input {
+       margin-left: 10px;
 }
 
-/* page content */
-.message {
-       border-bottom:1px dotted #cccccc;
-       padding:5px 0 7px 0;
+/*** message metadata ***/
+.messages-owner {
+       float: left;
+       width: 20%;
+       margin-right: 2%;
 }
-.message.notread .entity-listing-info p.entity-title a {
-       color:#d40005;
+.messages-subject {
+       float: left;
+       width: 55%;
+       margin-right: 2%;
 }
-.message_sender {
-       float:left;
-       width:180px;
-       overflow: hidden;
+.messages-timestamp {
+       float: left;
+       width: 14%;
+       margin-right: 2%;
 }
-.messages_to {
+.messages-delete {
        float: left;
-       margin-right: 10px;
+       width: 5%;
 }
 
-/* view and reply to message view */
-.message_body {
-       margin-left: 120px;
-}
-.message_subject {
-       float:left;
-       width:513px;
-       padding-top:6px;
-}
-.message .delete-button {
-       margin-top:3px;
-}
-.entity-listing.messages:hover {
-       background-color:white;
+/*** messages/new messages icon & counter in elgg-topbar ***/
+.messages-icon {
+       background:transparent url(<?php echo elgg_get_site_url(); ?>mod/messages/graphics/toolbar_messages_icon.gif) no-repeat left 2px;
+       position: relative;
 }
-.messages_buttonbank {
-       margin:5px 0;
-       text-align: right;
+.messages-icon:hover {
+       text-decoration: none;
+       background-position: left -36px;
 }
-.messages_buttonbank input {
-       margin:0 0 0 10px;
+.messages-icon.new span {
+       color: white;
+       background-color: red;
+       -webkit-border-radius: 10px; 
+       -moz-border-radius: 10px;
+       -webkit-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.50); /* safari v3+ */
+       -moz-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.50); /* FF v3.5+ */
+       position: absolute;
+       text-align: center;
+       top: -2px;
+       left: 10px;
+       min-width: 16px;
+       height: 16px;
+       font-size: 10px;
+       font-weight: bold;
 }
diff --git a/mod/messages/views/default/messages/forms/reply.php b/mod/messages/views/default/messages/forms/reply.php
deleted file mode 100644 (file)
index 107b861..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-    /**
-        * Elgg reply to a message form
-        * @uses $vars['entity'] This is the message being replied to
-        */
-       
-       // fix for RE: RE: RE: that builds on replies
-       $reply_title = $vars['entity']->title;
-       if (strncmp($reply_title, "RE:", 3) != 0) {
-               $reply_title = "RE: " . $reply_title;
-       }
-?>
-
-<form class="margin-top" id="messages_reply_form" action="<?php echo elgg_get_site_url(); ?>action/messages/send" method="post" name="messageForm">
-       <?php echo elgg_view('action/securitytoken'); ?>
-
-    <!-- populate the title space with the orginal message title, inserting re: before it -->                                                  
-       <p><label><?php echo elgg_echo("messages:title"); ?>: <br /><input type='text' name='title' class="elgg-input-text" value='<?php echo $reply_title; ?>' /></label></p>
-       <p><label><?php echo elgg_echo("messages:message"); ?>: <br /><textarea name='message' value='' class="elgg-input-textarea" /></textarea></label></p>
-               
-       <p>
-           <?php
-                
-               //pass across the guid of the message being replied to
-           echo "<input type='hidden' name='reply' value='" . $vars['entity']->getGUID() . "' />";
-           //pass along the owner of the message being replied to
-           echo "<input type='hidden' name='send_to' value='BAAA" . $vars['entity']->fromId . "' />";
-
-                       echo elgg_view('input/submit', array('value' => elgg_echo("messages:fly")));
-           ?>
-       </p>
-       
-</form>
-       
-       <?php
-        //display the message you are replying to
-               if (isset($vars['entity'])) {
-               
-               echo "<h3>" . elgg_echo("messages:replying") . "</h3>";
-               echo $vars['entity']->description;
-               
-               }
-    ?>
diff --git a/mod/messages/views/default/messages/forms/send.php b/mod/messages/views/default/messages/forms/send.php
deleted file mode 100644 (file)
index 6ddf7e5..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
-* Elgg send a message view
-* 
-* @package ElggMessages
- * @uses $vars['friends'] This is an array of a user's friends and is used to populate the list of
- * people the user can message
- *
- */
-//grab the user id to send a message to. This will only happen if a user clicks on the 'send a message'
-//link on a user's profile or hover-over menu
-$send_to = get_input('send_to');
-if ($send_to === "")
-       $send_to = $_SESSION['msg_to'];
-
-$msg_title = $_SESSION['msg_title'];
-$msg_content = $_SESSION['msg_contents'];
-
-// clear sticky form cache in case user browses away from page and comes back 
-unset($_SESSION['msg_to']);
-unset($_SESSION['msg_title']);
-unset($_SESSION['msg_contents']);
-?>
-<form id="messages_send_form" action="<?php echo elgg_get_site_url(); ?>action/messages/send" method="post" name="messageForm">
-<?php
-       echo elgg_view('input/securitytoken'); 
-        //check to see if the message recipient has already been selected
-               if($send_to){
-                       
-                       //get the user object  
-               $user = get_user($send_to);
-               
-               echo "<div class='entity-listing messages clearfix'><div class='entity-listing-icon'>".elgg_view("profile/icon",array('entity' => $user, 'size' => 'tiny'))."</div>";
-               
-               //draw it
-                       echo "<div class='entity-listing-info'>".elgg_echo("messages:to").": <a href='" . $user->getURL() . "'>".$user->name."</a>";
-                       //set the hidden input field to the recipients guid
-               echo "<input type='hidden' name='send_to' value=\"{$send_to}\" />";     
-                       echo "</div></div>";
-                   
-        } else {
-    ?>
-        
-        <p class="margin-top"><label><?php echo elgg_echo("messages:to"); ?>: </label>
-           <select name='send_to'>
-           <?php 
-                       // make the first option blank
-               echo "<option value=''>".elgg_echo("messages:recipient")."</option>";
-               foreach($vars['friends'] as $friend){
-               //populate the send to box with a user's friends
-                           echo "<option value='{$friend->guid}'>" . $friend->name . "</option>";
-                   }
-        ?>
-               </select></p>
-    <?php
-        }
-    ?>
-    
-       <p class="margin-top"><label><?php echo elgg_echo("messages:title"); ?>: <br /><input type='text' name='title' value='<?php echo $msg_title; ?>' class="elgg-input-text" /></label></p>
-       <p class="longtext_inputarea"><label><?php echo elgg_echo("messages:message"); ?>:</label>
-       <?php
-               echo elgg_view("input/longtext", array(
-                                               "internalname" => "message",
-                                               "value" => $msg_content,
-               ));
-       ?>
-       </p>
-       <p>
-       <?php
-               echo elgg_view('input/submit', array('value' => elgg_echo("messages:fly")));
-       ?>
-       </p>
-</form>
diff --git a/mod/messages/views/default/messages/forms/view.php b/mod/messages/views/default/messages/forms/view.php
deleted file mode 100644 (file)
index 5b92633..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-/**
-* View message
-* 
-* @package ElggMessages
-*/
-
-$body = elgg_view("messages/view",$vars);
-
-$body .= '<div class="messages_buttonbank">';
-$body .= '<input type="hidden" name="type" value="'.$vars['page_view'].'" />';
-$body .= '<input type="hidden" name="offset" value="'.$vars['offset'].'" />';
-$body .= '<input type="submit" name="submit" value="'.elgg_echo('delete').'" /> ';
-
-if($vars['page_view'] == "inbox"){
-       $body .= '<input type="submit" name="submit" value="'.elgg_echo('messages:markread').'" /> ';
-}
-
-$body .= '<input class="elgg-cancel-button" type="button" onclick="javascript:$(\'input[type=checkbox]\').click();" value="'.elgg_echo('messages:toggle').'" />';
-$body .= '</div>';
-
-echo elgg_view('input/form',array('body' => $body, 'action' => 'action/messages/delete', 'method' => 'post', 'internalid' => 'messages_list_form'));
\ No newline at end of file
diff --git a/mod/messages/views/default/messages/menu.php b/mod/messages/views/default/messages/menu.php
deleted file mode 100644 (file)
index 566a871..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-/**
- * Elgg hoverover extender for messages
- * 
- * @package ElggMessages
- */
-
-// login check already performed in profile/icon
-?>
-<li class="user_menu_profile">
-       <a class="send_message" href="<?php echo elgg_get_site_url(); ?>mod/messages/send.php?send_to=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("messages:sendmessage"); ?></a>        
-</li>
\ No newline at end of file
diff --git a/mod/messages/views/default/messages/messages.php b/mod/messages/views/default/messages/messages.php
deleted file mode 100644 (file)
index a1a7fd9..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-<?php
-/**
- * Elgg messages individual view
- *
- * @package ElggMessages
- *
- *
- * @uses $vars['entity'] Optionally, the message to view
- * @uses get_input('type') If the user accesses the message from their sentbox, this variable is passed
- * and used to make sure the correct icon and name is displayed
- */
-// set some variables to use below
-if(get_input("type") == "sent"){
-       // send back to the users sentbox
-       $url = elgg_get_site_url() . "mod/messages/sent.php";
-       // set up breadcrumbs context
-       elgg_push_breadcrumb(elgg_echo('messages:sent'), $url);
-       //this is used on the delete link so we know which type of message it is
-       $type = "sent";
-} else {
-       //send back to the users inbox
-       $url = elgg_get_site_url() . "pg/messages/" . get_loggedin_user()->username;
-       // set up breadcrumbs context
-       elgg_push_breadcrumb(elgg_echo('messages:inbox'), $url);
-       //this is used on the delete link so we know which type of message it is
-       $type = "inbox";
-}
-
-// fix for RE: RE: RE: that builds on replies
-$reply_title = $vars['entity']->title;
-if (strncmp($reply_title, "RE:", 3) != 0) {
-       $reply_title = "RE: " . $reply_title;
-}
-
-if (isloggedin())
-       if (isset($vars['entity'])) {
-               if ($vars['entity']->toId == get_loggedin_userid()
-                       || $vars['entity']->owner_guid == get_loggedin_userid()) {
-                       // display breadcrumbs
-                       elgg_push_breadcrumb($vars['entity']->title);
-                       echo elgg_view('navigation/breadcrumbs');
-?>
-<!-- display the content header block -->
-                       <div id="content-header" class="clearfix">
-                               <div class="content-header-title"><h2><?php echo $vars['entity']->title; ?></h2></div>
-                               <div class="content-header-options">
-                                       <a class="elgg-action-button message_reply" onclick="elgg_slide_toggle(this,'#elgg-page-contents','#message_reply_form');"><?php echo elgg_echo('messages:answer'); ?></a>
-                                       <?php echo elgg_view("output/confirmlink", array(
-                                               'href' => "action/messages/delete?message_id=" . $vars['entity']->getGUID() . "&type={$type}&submit=" . elgg_echo('delete'),
-                                               'text' => elgg_echo('delete'),
-                                               'confirm' => elgg_echo('deleteconfirm'),
-                                               'class' => "elgg-action-button disabled"
-                                               ));
-                               ?>
-                               </div>
-                       </div>
-
-                               <div class="entity-listing messages clearfix">
-                                       <?php
-                                               // we need a different user icon and name depending on whether the user is reading the message
-                                               // from their inbox or sentbox. If it is the inbox, then the icon and name will be the person who sent
-                                               // the message. If it is the sentbox, the icon and name will be the user the message was sent to
-                                               if($type == "sent"){
-                                                       //get an instance of the user who the message has been sent to so we can access the name and icon
-                                                       $user_object = get_entity($vars['entity']->toId);
-                                                       $message_icon = elgg_view("profile/icon",array('entity' => $user_object, 'size' => 'tiny'));
-                                                       $message_owner = elgg_echo('messages:to').": <a href='" . $user_object->getURL() . "'>".$user_object->name."</a>";
-                                               }else{
-                                                       $user_object = get_entity($vars['entity']->fromId);
-                                                       $message_icon = elgg_view("profile/icon",array('entity' => $user_object, 'size' => 'tiny'));
-                                                       $message_owner = elgg_echo('messages:from').": <a href='". $user_object->getURL() ."'>".get_entity($vars['entity']->fromId)->name."</a>";
-                                               }
-                                       ?>
-                                       <div class="entity-listing-icon"><?php echo $message_icon ?></div>
-                                       <div class="entity-listing-info"><p><?php echo $message_owner ?></p>
-                                               <p class="entity-subtext"><?php echo elgg_view_friendly_time($vars['entity']->time_created); ?></p>
-                                       </div>
-                               </div>
-
-                               <div class="messagebody margin-top clearfix">
-                                       <?php
-                                               // if the message is a reply, display the message the reply was for
-                                               // @todo I need to figure out how to get the description out using -> (anyone?)
-                                               if($main_message = $vars['entity']->getEntitiesFromRelationship("reply")){
-                                                       echo $main_message[0][description];
-                                               }
-                                       ?>
-                                       <!-- display the message -->
-                                       <?php echo elgg_view('output/longtext',array('value' => $vars['entity']->description)); ?>
-                               </div>
-
-                               <!-- reply form -->
-                               <div id="message_reply_form" class="hidden margin-top">
-                                       <h2><?php echo elgg_echo('messages:answer'); ?></h2>
-                                       <form action="<?php echo elgg_get_site_url(); ?>action/messages/send" method="post" name="messageForm" class="margin-top" id="messages_send_form">
-                                               <?php echo elgg_view('input/securitytoken'); ?>
-                                               <p><label><?php echo elgg_echo("messages:title"); ?>: <br /><input type='text' name='title' class="elgg-input-text" value='<?php echo $reply_title; ?>' /></label></p>
-                                               <p class="longtext_inputarea"><label><?php echo elgg_echo("messages:message"); ?>:</label>
-                                               <?php echo elgg_view("input/longtext", array(
-                                                                                       "internalname" => "message",
-                                                                                       "value" => '',
-                                                                                                                       ));
-                                               ?></p>
-
-                                       <?php
-                                               //pass across the guid of the message being replied to
-                                               echo "<input type='hidden' name='reply' value='" . $vars['entity']->getGUID() . "' />";
-                                               //pass along the owner of the message being replied to
-                                               echo "<input type='hidden' name='send_to' value='" . $vars['entity']->fromId . "' />";
-
-                                               echo elgg_view('input/submit', array('value' => elgg_echo("messages:fly")));
-                                       ?>
-                                       </form>
-                               </div>
-
-<?php
-       }
-}
\ No newline at end of file
index 9e880201f23df7720d8f5e312c831c5aca3b58e7..20c2f4396ff0bdfa84730e1b94ce5655f4a06c3b 100644 (file)
@@ -5,22 +5,22 @@
  * @package ElggMessages
  */
 
-gatekeeper();
+if (!isloggedin()) {
+       return true;
+}
+
+// get unread messages
+$num_messages = (int)messages_count_unread();
 
-//get unread messages
-$num_messages = messages_count_unread();
-if($num_messages){
-       $num = $num_messages;
-} else {
-       $num = 0;
+$class = "elgg-icon messages-icon";
+$text = "&nbsp;";
+if ($num_messages != 0) {
+       $class = "$class new";
+       $text = "<span>$num_messages</span>";
 }
 
-if($num == 0) {
-?>
-       <a href="<?php echo elgg_get_site_url(); ?>pg/messages/<?php echo get_loggedin_user()->username; ?>" class="privatemessages" >&nbsp;</a>
-<?php
-    }else{
-?>
-    <a href="<?php echo elgg_get_site_url(); ?>pg/messages/<?php echo get_loggedin_user()->username; ?>" class="privatemessages new" ><span><?php echo $num; ?></span></a>
-<?php
-    }
+echo elgg_view('output/url', array(
+       'href' => 'pg/messages/inbox/' . get_loggedin_user()->username,
+       'text' => $text,
+       'class' => $class,
+));
diff --git a/mod/messages/views/default/messages/view.php b/mod/messages/views/default/messages/view.php
deleted file mode 100644 (file)
index cc0b5ec..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-/**
- * Elgg messages view page
- *
- * @package ElggMessages
- *
- * @uses $vars['entity'] An array of messages to view
- * @uses $vars['page_view'] This is the page the messages are being accessed from; inbox or sentbox
- *
- */
-
-$limit = $vars['limit']; if (empty($limit)) $limit = 10;
-$offset = $vars['offset']; if (!isset($offset)) $offset = 0;
-
-// If there are any messages to view, view them
-if (isloggedin())
-if (is_array($vars['entity']) && sizeof($vars['entity']) > 0) {
-
-       // get the correct display for the inbox view
-       if($vars['page_view'] == "inbox") {
-
-               $counter = 0;
-
-               foreach($vars['entity'] as $message) {
-                       if ($message->owner_guid == get_loggedin_userid() || $message->toId == get_loggedin_userid()) {
-
-                               //make sure to only display the messages that have not been 'deleted' (1 = deleted)
-                               if($message->hiddenFrom != 1){
-                                       // check to see if the message has been read, if so, set the correct container class
-                                       if($message->readYet == 1){
-                               echo "<div class='message read clearfix'>";
-                           }else{
-                               echo "<div class='message notread clearfix'>";
-                           }
-                                   // get the icon of the user who owns the message
-                                   $from = get_entity($message->fromId);
-                                       echo "<div class='entity-listing-icon'>".elgg_view("profile/icon",array('entity' => $from, 'size' => 'tiny'))."</div>";
-                                       // message block (message sender, message subject, delete checkbox)
-                                       echo "<div class='entity-listing-info'><div class='message_sender'>".$from->name."<p class='entity-subtext'>".elgg_view_friendly_time($message->time_created)."</p></div>";
-                                       // display message subject
-                                       echo "<div class='message_subject'>";
-                                       // display delete button
-                                       echo "<span class='delete-button'>" . elgg_view("output/confirmlink", array(
-                                               'href' => "action/messages/delete?message_id=" . $message->getGUID() . "&type=inbox&submit=" . urlencode(elgg_echo('delete')),
-                                               'text' => elgg_echo('delete'),
-                                               'confirm' => elgg_echo('deleteconfirm'),
-                                       )) . "</span>";
-                                       echo "<p class='entity-title'><input type='checkbox' name=\"message_id[]\" value=\"{$message->guid}\" />";
-                                       echo "<a href=\"{$message->getURL()}\">" . $message->title . "</a></p>";
-                                   echo "</div></div></div>"; // close the message container
-                               }//end of hiddenFrom if statement
-                               } // end of user check
-                               $counter++;
-                               if ($counter == $limit) break;
-
-                       }//end of for each loop
-               }//end of inbox if statement
-
-               // get the correct display for the sentbox view
-               if($vars['page_view'] == "sent") {
-
-                       $counter = 0;
-
-                       foreach($vars['entity'] as $message) {
-
-                               //make sure to only display the messages that have not been 'deleted' (1 = deleted)
-                               if($message->hiddenTo != 1){
-
-                                       //get the correct user entity
-                                       $user = get_entity($message->toId);
-                                       echo "<div class='message sent clearfix'>";
-                                       //get the icon for the user the message was sent to
-                                       echo "<div class='entity-listing-icon'>".elgg_view("profile/icon",array('entity' => $user, 'size' => 'tiny'))."</div>";
-                                       echo "<div class='entity-listing-info'><div class='message_sender'>".get_loggedin_user()->name."<p class='entity-subtext'>".elgg_view_friendly_time($message->time_created)."</p></div>";
-                                       // display message subject
-                                       echo "<div class='message_subject'>";
-                                       //display the link to 'delete'
-                                       echo "<div class='delete-button'>" . elgg_view("output/confirmlink", array(
-                                               'href' => "action/messages/delete?message_id=" . $message->getGUID() . "&type=sent&submit=" . urlencode(elgg_echo('delete')),
-                                               'text' => elgg_echo('delete'),
-                                               'confirm' => elgg_echo('deleteconfirm'),
-                                       )) . "</div>";
-                                       echo "<p class='entity-title'><input type='checkbox' name=\"message_id[]\" value=\"{$message->guid}\" /> ";
-                                       echo "<a href=\"{$message->getURL()}?type=sent\">" . $message->title . "</a></p>";
-                                       echo "</div></div></div>"; // close the message container
-                               }//close hiddeTo if statement
-
-                               $counter++;
-                               if ($counter == $limit) break;
-
-                       }//close foreach
-
-               }//close page_view sent if statement
-
-               $baseurl = $_SERVER['REQUEST_URI'];
-               $nav = '';
-
-               if (sizeof($vars['entity']) > $limit) {
-                       $newoffset = $offset + $limit;
-                       $nexturl = elgg_http_add_url_query_elements($baseurl, array('offset' => $newoffset));
-
-                       $nav .= '<a class="pagination-previous" href="'.$nexturl.'">&laquo; ' . elgg_echo('previous') . '</a> ';
-               }
-
-               if ($offset > 0) {
-                       $newoffset = $offset - $limit;
-                       if ($newoffset < 0) $newoffset = 0;
-
-                       $prevurl = elgg_http_add_url_query_elements($baseurl, array('offset' => $newoffset));
-
-                       $nav .= '<a class="pagination-next" href="'.$prevurl.'">' . elgg_echo('next') . ' &raquo;</a> ';
-               }
-
-
-               if (!empty($nav)) {
-                       echo '<div class="pagination"><p>'.$nav.'</p></div>';
-               }
-
-} else {
-       echo "<p>".elgg_echo("messages:nomessages")."</p>";
-}
diff --git a/mod/messages/views/default/object/messages.php b/mod/messages/views/default/object/messages.php
new file mode 100644 (file)
index 0000000..9aae6b7
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+/**
+ * File renderer.
+ *
+ * @package ElggFile
+ */
+
+$full = elgg_get_array_value('full', $vars, false);
+$message = elgg_get_array_value('entity', $vars, false);
+
+if (!$message) {
+       return true;
+}
+
+if ($full) {
+       $message->readYet = true;
+}
+
+if ($message->toId == elgg_get_page_owner_guid()) {
+       // received
+       $user = get_entity($message->fromId);
+       $icon = elgg_view('profile/icon', array('entity' => $user, 'size' => 'tiny'));
+       $user_link = elgg_view('output/url', array(
+               'href' => "pg/messages/compose?send_to=$user->guid",
+               'text' => $user->name,
+       ));
+
+       if ($message->readYet) {
+               $class = 'message read';
+       } else {
+               $class = 'message unread';
+       }
+
+} else {
+       // sent
+       $user = get_entity($message->toId);
+       $icon = elgg_view('profile/icon', array('entity' => $user, 'size' => 'tiny'));
+       $user_link = elgg_view('output/url', array(
+               'href' => "pg/messages/compose?send_to=$user->guid",
+               'text' => elgg_echo('messages:to_user', array($user->name)),
+       ));
+
+       $class = 'message read';
+}
+
+$timestamp = elgg_view_friendly_time($message->time_created);
+
+$subject_info = '';
+if (!$full) {
+       $subject_info .= "<input type='checkbox' name=\"message_id[]\" value=\"{$message->guid}\" />";
+}
+$subject_info .= elgg_view('output/url', array(
+       'href' => $message->getURL(),
+       'text' => $message->title,
+));
+
+$delete_link = "<span class='delete-button'>" . elgg_view("output/confirmlink", array(
+                                               'href' => "action/messages/delete?guid=" . $message->getGUID(),
+                                               'text' => elgg_echo('delete'),
+                                               'confirm' => elgg_echo('deleteconfirm'),
+                                       )) . "</span>";
+
+$body = <<<HTML
+<div class="messages-owner">$user_link</div>
+<div class="messages-subject">$subject_info</div>
+<div class="messages-timestamp">$timestamp</div>
+<div class="messages-delete">$delete_link</div>
+HTML;
+
+if ($full) {
+       echo elgg_view_image_block($icon, $body, array('class' => $class));
+       echo elgg_view('output/longtext', array('value' => $message->description));
+} else {
+       echo elgg_view_image_block($icon, $body, array('class' => $class));
+}
\ No newline at end of file