diff options
Diffstat (limited to 'mod/messages')
| -rw-r--r-- | mod/messages/actions/messages/send.php | 10 | ||||
| -rw-r--r-- | mod/messages/languages/en.php | 8 | ||||
| -rw-r--r-- | mod/messages/manifest.xml | 12 | ||||
| -rw-r--r-- | mod/messages/pages/messages/inbox.php (renamed from mod/messages/inbox.php) | 11 | ||||
| -rw-r--r-- | mod/messages/pages/messages/read.php (renamed from mod/messages/read.php) | 30 | ||||
| -rw-r--r-- | mod/messages/pages/messages/send.php (renamed from mod/messages/send.php) | 7 | ||||
| -rw-r--r-- | mod/messages/pages/messages/sent.php (renamed from mod/messages/sent.php) | 11 | ||||
| -rw-r--r-- | mod/messages/readme.txt | 23 | ||||
| -rw-r--r-- | mod/messages/start.php | 223 | ||||
| -rw-r--r-- | mod/messages/views/default/forms/messages/process.php | 25 | ||||
| -rw-r--r-- | mod/messages/views/default/forms/messages/reply.php | 13 | ||||
| -rw-r--r-- | mod/messages/views/default/forms/messages/send.php | 4 | ||||
| -rw-r--r-- | mod/messages/views/default/messages/css.php | 30 | ||||
| -rw-r--r-- | mod/messages/views/default/messages/js.php | 7 | ||||
| -rw-r--r-- | mod/messages/views/default/object/messages.php | 47 |
15 files changed, 278 insertions, 183 deletions
diff --git a/mod/messages/actions/messages/send.php b/mod/messages/actions/messages/send.php index a643b44b4..9d9f6c8b7 100644 --- a/mod/messages/actions/messages/send.php +++ b/mod/messages/actions/messages/send.php @@ -15,19 +15,19 @@ elgg_make_sticky_form('messages'); if (!$recipient_guid) { register_error(elgg_echo("messages:user:blank")); - forward("pg/messages/compose"); + forward("messages/compose"); } $user = get_user($recipient_guid); if (!$user) { register_error(elgg_echo("messages:user:nonexist")); - forward("pg/messages/compose"); + forward("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"); + forward("messages/compose"); } // Otherwise, 'send' the message @@ -36,11 +36,11 @@ $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"); + forward("messages/compose"); } elgg_clear_sticky_form('messages'); system_message(elgg_echo("messages:posted")); -forward('pg/messages/inbox/' . elgg_get_logged_in_user_entity()->username); +forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username); diff --git a/mod/messages/languages/en.php b/mod/messages/languages/en.php index 4ad6b7617..7732a9dce 100644 --- a/mod/messages/languages/en.php +++ b/mod/messages/languages/en.php @@ -11,6 +11,7 @@ $english = array( */ 'messages' => "Messages", + 'messages:unreadcount' => "%s unread", 'messages:back' => "back to messages", 'messages:user' => "%s's inbox", 'messages:posttitle' => "%s's messages: %s", @@ -39,7 +40,7 @@ $english = array( 'messages:new' => 'New message', - 'notification:method:site' => 'Messages', + 'notification:method:site' => 'Site', 'messages:error' => 'There was a problem saving your message. Please try again.', @@ -85,9 +86,12 @@ $english = array( 'messages:notfound' => "Sorry; we could not find the specified message.", 'messages:notdeleted' => "Sorry; we could not delete this message.", 'messages:nopermission' => "You do not have permission to alter that message.", - 'messages:nomessages' => "There are no messages to display.", + 'messages:nomessages' => "There are no messages.", 'messages:user:nonexist' => "We could not find the recipient in the user database.", 'messages:user:blank' => "You did not select someone to send this to.", + + 'messages:deleted_sender' => 'Deleted user', + ); add_translation("en", $english);
\ No newline at end of file diff --git a/mod/messages/manifest.xml b/mod/messages/manifest.xml index 359ba526d..6e3462901 100644 --- a/mod/messages/manifest.xml +++ b/mod/messages/manifest.xml @@ -3,13 +3,15 @@ <name>Messages</name> <author>Core developers</author> <version>1.8</version> + <category>bundled</category> + <category>communication</category> <description>Elgg internal messages plugin. This plugin lets user send each other messages.</description> - <copyright>See COPYRIGHT.txt</copyright> <website>http://www.elgg.org/</website> - <license>GNU Public License version 2</license> + <copyright>See COPYRIGHT.txt</copyright> + <license>GNU General Public License version 2</license> <requires> - <type>elgg_version</type> - <version>2010030101</version> + <type>elgg_release</type> + <version>1.8</version> </requires> - <admin_interface>simple</admin_interface> + <activate_on_install>true</activate_on_install> </plugin_manifest> diff --git a/mod/messages/inbox.php b/mod/messages/pages/messages/inbox.php index 4b2d11bbf..de5b8b231 100644 --- a/mod/messages/inbox.php +++ b/mod/messages/pages/messages/inbox.php @@ -8,13 +8,20 @@ gatekeeper(); $page_owner = elgg_get_page_owner_entity(); -if (!$page_owner) { - register_error(elgg_echo()); + +if (!$page_owner || !$page_owner->canEdit()) { + $guid = 0; + if($page_owner){ + $guid = $page_owner->getGUID(); + } + register_error(elgg_echo("pageownerunavailable", array($guid))); forward(); } elgg_push_breadcrumb(elgg_echo('messages:inbox')); +elgg_register_title_button(); + $title = elgg_echo('messages:user', array($page_owner->name)); $list = elgg_list_entities_from_metadata(array( diff --git a/mod/messages/read.php b/mod/messages/pages/messages/read.php index b830aa51c..4223c6bac 100644 --- a/mod/messages/read.php +++ b/mod/messages/pages/messages/read.php @@ -8,10 +8,13 @@ gatekeeper(); $message = get_entity(get_input('guid')); -if (!$message) { - forward(); +if (!$message || !elgg_instanceof($message, "object", "messages")) { + forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username); } +// mark the message as read +$message->readYet = true; + elgg_set_page_owner_guid($message->getOwnerGUID()); $page_owner = elgg_get_page_owner_entity(); @@ -20,28 +23,30 @@ $title = $message->title; $inbox = false; if ($page_owner->getGUID() == $message->toId) { $inbox = true; - elgg_push_breadcrumb(elgg_echo('messages:inbox'), 'pg/messages/inbox/' . $page_owner->username); + elgg_push_breadcrumb(elgg_echo('messages:inbox'), 'messages/inbox/' . $page_owner->username); } else { - elgg_push_breadcrumb(elgg_echo('messages:sent'), 'pg/messages/sent/' . $page_owner->username); + elgg_push_breadcrumb(elgg_echo('messages:sent'), 'messages/sent/' . $page_owner->username); } elgg_push_breadcrumb($title); -$buttons = ''; -$content = elgg_view_entity($message, true); +$content = elgg_view_entity($message, array('full_view' => true)); if ($inbox) { $form_params = array( 'id' => 'messages-reply-form', - 'class' => 'hidden', + 'class' => 'hidden mtl', 'action' => 'action/messages/send', ); $body_params = array('message' => $message); $content .= elgg_view_form('messages/reply', $form_params, $body_params); - - if (elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) { - $buttons = elgg_view('output/url', array( + $from_user = get_user($message->fromId); + + if ((elgg_get_logged_in_user_guid() == elgg_get_page_owner_guid()) && $from_user) { + elgg_register_menu_item('title', array( + 'name' => 'reply', + 'href' => '#messages-reply-form', 'text' => elgg_echo('messages:answer'), - 'class' => 'elgg-button elgg-button-action', - 'id' => 'messages-show-reply', + 'link_class' => 'elgg-button elgg-button-action', + 'rel' => 'toggle', )); } } @@ -50,7 +55,6 @@ $body = elgg_view_layout('content', array( 'content' => $content, 'title' => $title, 'filter' => '', - 'buttons' => $buttons, )); echo elgg_view_page($title, $body); diff --git a/mod/messages/send.php b/mod/messages/pages/messages/send.php index 884c20cca..b46d0ba52 100644 --- a/mod/messages/send.php +++ b/mod/messages/pages/messages/send.php @@ -8,21 +8,20 @@ gatekeeper(); $page_owner = elgg_get_logged_in_user_entity(); -set_page_owner($page_owner->getGUID()); +elgg_set_page_owner_guid($page_owner->getGUID()); $title = elgg_echo('messages:add'); elgg_push_breadcrumb($title); -$params = messages_prepare_form_vars(get_input('send_to')); -$params['friends'] = $page_owner->getFriends(); +$params = messages_prepare_form_vars((int)get_input('send_to')); +$params['friends'] = $page_owner->getFriends('', 50); $content = elgg_view_form('messages/send', array(), $params); $body = elgg_view_layout('content', array( 'content' => $content, 'title' => $title, 'filter' => '', - 'buttons' => '', )); echo elgg_view_page($title, $body); diff --git a/mod/messages/sent.php b/mod/messages/pages/messages/sent.php index f884643e0..3d08cd5ee 100644 --- a/mod/messages/sent.php +++ b/mod/messages/pages/messages/sent.php @@ -8,13 +8,20 @@ gatekeeper(); $page_owner = elgg_get_page_owner_entity(); -if (!$page_owner) { - register_error(elgg_echo()); + +if (!$page_owner || !$page_owner->canEdit()) { + $guid = 0; + if($page_owner){ + $guid = $page_owner->getGUID(); + } + register_error(elgg_echo("pageownerunavailable", array($guid))); forward(); } elgg_push_breadcrumb(elgg_echo('messages:sent')); +elgg_register_title_button(); + $title = elgg_echo('messages:sentmessages', array($page_owner->name)); $list = elgg_list_entities_from_metadata(array( diff --git a/mod/messages/readme.txt b/mod/messages/readme.txt deleted file mode 100644 index 9d267f3fb..000000000 --- a/mod/messages/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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.org> - * @link http://elgg.org/ - */ - -Install: drop the plugin into your mod folder, that is it. - -Notes: - -Each message has a series of metadata which is used to control how the message displays. - -The metadata toggles are: - -hiddenFrom - used to 'delete' from the sentbox -hiddenTo - used to 'delete' from the inbox -readYet - 0 means no, 1 means yes it has been read - -This is actually a tricky little plugin as there is only ever one instance of a message, how it is viewed -depends on who is looked at and in what context.
\ No newline at end of file diff --git a/mod/messages/start.php b/mod/messages/start.php index 27b6252eb..6d0e82744 100644 --- a/mod/messages/start.php +++ b/mod/messages/start.php @@ -19,39 +19,24 @@ function messages_init() { elgg_register_menu_item('page', array( 'name' => 'messages:inbox', 'text' => elgg_echo('messages:inbox'), - 'href' => "pg/messages/inbox/" . elgg_get_logged_in_user_entity()->username, + 'href' => "messages/inbox/" . elgg_get_logged_in_user_entity()->username, 'context' => 'messages', )); elgg_register_menu_item('page', array( 'name' => 'messages:sentmessages', 'text' => elgg_echo('messages:sentmessages'), - 'href' => "pg/messages/sent/" . elgg_get_logged_in_user_entity()->username, + 'href' => "messages/sent/" . elgg_get_logged_in_user_entity()->username, 'context' => 'messages', - )); - - $class = "elgg-icon messages-icon"; - $text = " "; - - // get unread messages - $num_messages = (int)messages_count_unread(); - if ($num_messages != 0) { - $class .= " new"; - $text = $num_messages; - } - $text = "<span class='$class'>$text</span>"; - - elgg_register_menu_item('topbar', array( - 'name' => 'messages', - 'href' => 'pg/messages/inbox/' . elgg_get_logged_in_user_entity()->username, - 'text' => $text, - 'priority' => 600, - )); + )); } + elgg_register_event_handler('pagesetup', 'system', 'messages_notifier'); + // Extend system CSS with our own styles, which are defined in the messages/css view elgg_extend_view('css/elgg', 'messages/css'); - + elgg_extend_view('js/elgg', 'messages/js'); + // Register a page handler, so we can have nice URLs elgg_register_page_handler('messages', 'messages_page_handler'); @@ -66,6 +51,9 @@ function messages_init() { elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'messages_notification_msg'); register_notification_object('object', 'messages', elgg_echo('messages:new')); + // delete messages sent by a user when user is deleted + elgg_register_event_handler('delete', 'user', 'messages_purge'); + // ecml elgg_register_plugin_hook_handler('get_views', 'ecml', 'messages_ecml_views_hook'); @@ -89,26 +77,33 @@ function messages_init() { */ function messages_page_handler($page) { + $current_user = elgg_get_logged_in_user_entity(); + if (!$current_user) { + register_error(elgg_echo('noaccess')); + $_SESSION['last_forward_from'] = current_page_url(); + forward(''); + } + elgg_load_library('elgg:messages'); - elgg_push_breadcrumb(elgg_echo('messages'), 'pg/messages/inbox/' . elgg_get_logged_in_user_entity()->username); + elgg_push_breadcrumb(elgg_echo('messages'), 'messages/inbox/' . $current_user->username); if (!isset($page[0])) { $page[0] = 'inbox'; } - // supporting the old inbox url /pg/messages/<username> - $user = get_user_by_username($page[0]); - if ($user) { + // Support the old inbox url /messages/<username>, but only if it matches the logged in user. + // Otherwise having a username like "read" on the system could confuse this function. + if ($current_user->username === $page[0]) { $page[1] = $page[0]; $page[0] = 'inbox'; } if (!isset($page[1])) { - $page[1] = elgg_get_logged_in_user_entity()->username; + $page[1] = $current_user->username; } - $base_dir = elgg_get_plugins_path() . 'messages'; + $base_dir = elgg_get_plugins_path() . 'messages/pages/messages'; switch ($page[0]) { case 'inbox': @@ -130,11 +125,36 @@ function messages_page_handler($page) { default: return false; } - return true; } /** + * Display notification of new messages in topbar + */ +function messages_notifier() { + if (elgg_is_logged_in()) { + $class = "elgg-icon elgg-icon-mail"; + $text = "<span class='$class'></span>"; + $tooltip = elgg_echo("messages"); + + // get unread messages + $num_messages = (int)messages_count_unread(); + if ($num_messages != 0) { + $text .= "<span class=\"messages-new\">$num_messages</span>"; + $tooltip .= " (" . elgg_echo("messages:unreadcount", array($num_messages)) . ")"; + } + + elgg_register_menu_item('topbar', array( + 'name' => 'messages', + 'href' => 'messages/inbox/' . elgg_get_logged_in_user_entity()->username, + 'text' => $text, + 'priority' => 600, + 'title' => $tooltip, + )); + } +} + +/** * Override the canEditMetadata function to return true for messages * */ @@ -202,18 +222,20 @@ function messages_can_edit_container($hook_name, $entity_type, $return_value, $p * * @param string $subject The subject line of the message * @param string $body The body of the mesage - * @param int $send_to The GUID of the user to send to - * @param int $from Optionally, the GUID of the user to send from - * @param int $reply The GUID of the message to reply from (default: none) - * @param true|false $notify Send a notification (default: true) - * @param true|false $add_to_sent If true (default), will add a message to the sender's 'sent' tray + * @param int $recipient_guid The GUID of the user to send to + * @param int $sender_guid Optionally, the GUID of the user to send from + * @param int $original_msg_guid The GUID of the message to reply from (default: none) + * @param bool $notify Send a notification (default: true) + * @param bool $add_to_sent If true (default), will add a message to the sender's 'sent' tray * @return bool */ -function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify = true, $add_to_sent = true) { +function messages_send($subject, $body, $recipient_guid, $sender_guid = 0, $original_msg_guid = 0, $notify = true, $add_to_sent = true) { + // @todo remove globals global $messagesendflag; $messagesendflag = 1; + // @todo remove globals global $messages_pm; if ($notify) { $messages_pm = 1; @@ -221,33 +243,40 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify $messages_pm = 0; } - // If $from == 0, set to current user - if ($from == 0) { - $from = (int) elgg_get_logged_in_user_guid(); + // If $sender_guid == 0, set to current user + if ($sender_guid == 0) { + $sender_guid = (int) elgg_get_logged_in_user_guid(); } // Initialise 2 new ElggObject $message_to = new ElggObject(); $message_sent = new ElggObject(); + $message_to->subtype = "messages"; $message_sent->subtype = "messages"; - $message_to->owner_guid = $send_to; - $message_to->container_guid = $send_to; - $message_sent->owner_guid = $from; - $message_sent->container_guid = $from; + + $message_to->owner_guid = $recipient_guid; + $message_to->container_guid = $recipient_guid; + $message_sent->owner_guid = $sender_guid; + $message_sent->container_guid = $sender_guid; + $message_to->access_id = ACCESS_PUBLIC; $message_sent->access_id = ACCESS_PUBLIC; + $message_to->title = $subject; $message_to->description = $body; + $message_sent->title = $subject; $message_sent->description = $body; - $message_to->toId = $send_to; // the user receiving the message - $message_to->fromId = $from; // the user receiving the message + + $message_to->toId = $recipient_guid; // the user receiving the message + $message_to->fromId = $sender_guid; // the user receiving the message $message_to->readYet = 0; // this is a toggle between 0 / 1 (1 = read) $message_to->hiddenFrom = 0; // this is used when a user deletes a message in their sentbox, it is a flag $message_to->hiddenTo = 0; // this is used when a user deletes a message in their inbox - $message_sent->toId = $send_to; // the user receiving the message - $message_sent->fromId = $from; // the user receiving the message + + $message_sent->toId = $recipient_guid; // the user receiving the message + $message_sent->fromId = $sender_guid; // the user receiving the message $message_sent->readYet = 0; // this is a toggle between 0 / 1 (1 = read) $message_sent->hiddenFrom = 0; // this is used when a user deletes a message in their sentbox, it is a flag $message_sent->hiddenTo = 0; // this is used when a user deletes a message in their inbox @@ -260,7 +289,7 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify // Save the copy of the message that goes to the sender if ($add_to_sent) { - $success2 = $message_sent->save(); + $message_sent->save(); } $message_to->access_id = ACCESS_PRIVATE; @@ -273,22 +302,25 @@ function messages_send($subject, $body, $send_to, $from = 0, $reply = 0, $notify // if the new message is a reply then create a relationship link between the new message // and the message it is in reply to - if ($reply && $success){ - $create_relationship = add_entity_relationship($message_sent->guid, "reply", $reply); + if ($original_msg_guid && $success) { + add_entity_relationship($message_sent->guid, "reply", $original_msg_guid); } $message_contents = strip_tags($body); - if ($send_to != elgg_get_logged_in_user_entity() && $notify) { + if (($recipient_guid != elgg_get_logged_in_user_guid()) && $notify) { + $recipient = get_user($recipient_guid); + $sender = get_user($sender_guid); + $subject = elgg_echo('messages:email:subject'); $body = elgg_echo('messages:email:body', array( - elgg_get_logged_in_user_entity()->name, + $sender->name, $message_contents, - elgg_get_site_url() . "pg/messages/inbox/" . $user->username, - elgg_get_logged_in_user_entity()->name, - elgg_get_site_url() . "pg/messages/compose?send_to=" . elgg_get_logged_in_user_guid() + elgg_get_site_url() . "messages/inbox/" . $recipient->username, + $sender->name, + elgg_get_site_url() . "messages/compose?send_to=" . $sender_guid )); - notify_user($send_to, elgg_get_logged_in_user_guid(), $subject, $body); + notify_user($recipient_guid, $sender_guid, $subject, $body); } $messagesendflag = 0; @@ -302,32 +334,54 @@ 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/read/' . $message->getGUID(); + $url = elgg_get_site_url() . 'messages/read/' . $message->getGUID(); return $url; } +function count_unread_messages() { + elgg_deprecated_notice('Your theme is using count_unread_messages which has been deprecated for messages_count_unread()', 1.8); + return messages_count_unread(); +} + /** * Count the unread messages in a user's inbox * * @return int */ function messages_count_unread() { + $user_guid = elgg_get_logged_in_user_guid(); + $db_prefix = elgg_get_config('dbprefix'); + + // denormalize the md to speed things up. + // seriously, 10 joins if you don't. + $strings = array('toId', $user_guid, 'readYet', 0, 'msg', 1); + $map = array(); + foreach ($strings as $string) { + $id = get_metastring_id($string); + $map[$string] = $id; + } $options = array( - 'metadata_name_value_pairs' => array( - 'toId' => elgg_get_logged_in_user_guid(), - 'readYet' => 0, - 'msg' => 1 +// 'metadata_name_value_pairs' => array( +// 'toId' => elgg_get_logged_in_user_guid(), +// 'readYet' => 0, +// 'msg' => 1 +// ), + 'joins' => array( + "JOIN {$db_prefix}metadata msg_toId on e.guid = msg_toId.entity_guid", + "JOIN {$db_prefix}metadata msg_readYet on e.guid = msg_readYet.entity_guid", + "JOIN {$db_prefix}metadata msg_msg on e.guid = msg_msg.entity_guid", ), - 'owner_guid' => elgg_get_logged_in_user_guid() + 'wheres' => array( + "msg_toId.name_id='{$map['toId']}' AND msg_toId.value_id='{$map[$user_guid]}'", + "msg_readYet.name_id='{$map['readYet']}' AND msg_readYet.value_id='{$map[0]}'", + "msg_msg.name_id='{$map['msg']}' AND msg_msg.value_id='{$map[1]}'", + ), + 'owner_guid' => $user_guid, + 'count' => true, ); - $num_messages = elgg_get_entities_from_metadata($options); - - if (is_array($num_messages)) { - return sizeof($num_messages); - } - return 0; + return elgg_get_entities_from_metadata($options); } /** @@ -365,7 +419,7 @@ function messages_user_hover_menu($hook, $type, $return, $params) { $user = $params['entity']; if (elgg_is_logged_in() && elgg_get_logged_in_user_guid() != $user->guid) { - $url = "pg/messages/compose?send_to={$user->guid}"; + $url = "messages/compose?send_to={$user->guid}"; $item = new ElggMenuItem('send', elgg_echo('messages:sendmessage'), $url); $item->setSection('action'); $return[] = $item; @@ -374,6 +428,39 @@ function messages_user_hover_menu($hook, $type, $return, $params) { return $return; } +/** + * Delete messages from a user who is being deleted + * + * @param string $event Event name + * @param string $type Event type + * @param ElggUser $user User being deleted + */ +function messages_purge($event, $type, $user) { + + if (!$user->getGUID()) { + return; + } + + // make sure we delete them all + $entity_disable_override = access_get_show_hidden_status(); + access_show_hidden_entities(true); + $ia = elgg_set_ignore_access(true); + + $options = array( + 'type' => 'object', + 'subtype' => 'messages', + 'metadata_name' => 'fromId', + 'metadata_value' => $user->getGUID(), + 'limit' => 0, + ); + $batch = new ElggBatch('elgg_get_entities_from_metadata', $options); + foreach ($batch as $e) { + $e->delete(); + } + + elgg_set_ignore_access($ia); + access_show_hidden_entities($entity_disable_override); +} /** * Register messages with ECML. diff --git a/mod/messages/views/default/forms/messages/process.php b/mod/messages/views/default/forms/messages/process.php index 5cdd01c1f..cb30792e9 100644 --- a/mod/messages/views/default/forms/messages/process.php +++ b/mod/messages/views/default/forms/messages/process.php @@ -8,12 +8,23 @@ * */ -echo $vars['list']; +$messages = $vars['list']; +if (!$messages) { + echo elgg_echo('messages:nomessages'); + return true; +} + +echo '<div class="messages-container">'; +echo $messages; +echo '</div>'; + +echo '<div class="elgg-foot messages-buttonbank">'; -echo '<div class="messages-buttonbank">'; echo elgg_view('input/submit', array( 'value' => elgg_echo('delete'), 'name' => 'delete', + 'class' => 'elgg-button-delete elgg-requires-confirmation', + 'title' => elgg_echo('deleteconfirm:plural'), )); if ($vars['folder'] == "inbox") { @@ -30,13 +41,3 @@ echo elgg_view('input/button', array( )); echo '</div>'; - -?> -<?php //@todo JS 1.8: no ?> -<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 index 2288f25f4..9f3f4b57e 100644 --- a/mod/messages/views/default/forms/messages/reply.php +++ b/mod/messages/views/default/forms/messages/reply.php @@ -33,15 +33,6 @@ echo elgg_view('input/hidden', array( )); ?> </div> -<div> +<div class="elgg-foot"> <?php echo elgg_view('input/submit', array('value' => elgg_echo('messages:send'))); ?> -</div> - -<script type="text/javascript"> -$(document).ready(function() { - $("#messages-show-reply").click(function() { - $('#messages-reply-form').slideToggle('medium'); - }); -}); - -</script>
\ No newline at end of file +</div>
\ 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 index c0a095993..5b7e7830e 100644 --- a/mod/messages/views/default/forms/messages/send.php +++ b/mod/messages/views/default/forms/messages/send.php @@ -1,6 +1,6 @@ <?php /** - * Compse message form + * Compose message form * * @package ElggMessages * @uses $vars['friends'] @@ -49,6 +49,6 @@ $recipient_drop_down = elgg_view('input/dropdown', array( )); ?> </div> -<div> +<div class="elgg-foot"> <?php echo elgg_view('input/submit', array('value' => elgg_echo('messages:send'))); ?> </div> diff --git a/mod/messages/views/default/messages/css.php b/mod/messages/views/default/messages/css.php index ba8444f03..f304e0f15 100644 --- a/mod/messages/views/default/messages/css.php +++ b/mod/messages/views/default/messages/css.php @@ -6,7 +6,9 @@ */ ?> - +.messages-container { + min-height: 200px; +} .message.unread a { color: #d40005; } @@ -37,27 +39,23 @@ float: left; width: 5%; } - -/*** 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-icon:hover { - text-decoration: none; - background-position: left -36px; -} -.messages-icon.new span { +/*** topbar icon ***/ +.messages-new { 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+ */ + border-radius: 10px; + + -webkit-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.50); + -moz-box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.50); + box-shadow: -2px 2px 4px rgba(0, 0, 0, 0.50); + position: absolute; text-align: center; - top: -2px; - left: 10px; + top: 0px; + left: 26px; min-width: 16px; height: 16px; font-size: 10px; diff --git a/mod/messages/views/default/messages/js.php b/mod/messages/views/default/messages/js.php new file mode 100644 index 000000000..60cf36b92 --- /dev/null +++ b/mod/messages/views/default/messages/js.php @@ -0,0 +1,7 @@ + +// messages plugin toggle +elgg.register_hook_handler('init', 'system', function() { + $("#messages-toggle").click(function() { + $('input[type=checkbox]').click(); + }); +}); diff --git a/mod/messages/views/default/object/messages.php b/mod/messages/views/default/object/messages.php index 70a51bf57..b12f98522 100644 --- a/mod/messages/views/default/object/messages.php +++ b/mod/messages/views/default/object/messages.php @@ -5,25 +5,27 @@ * @package ElggFile */ -$full = elgg_extract('full', $vars, false); +$full = elgg_extract('full_view', $vars, false); $message = elgg_extract('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_entity_icon($user, 'tiny'); - $user_link = elgg_view('output/url', array( - 'href' => "pg/messages/compose?send_to=$user->guid", - 'text' => $user->name, - )); + if ($user) { + $icon = elgg_view_entity_icon($user, 'tiny'); + $user_link = elgg_view('output/url', array( + 'href' => "messages/compose?send_to=$user->guid", + 'text' => $user->name, + 'is_trusted' => true, + )); + } else { + $icon = ''; + $user_link = elgg_echo('messages:deleted_sender'); + } if ($message->readYet) { $class = 'message read'; @@ -34,11 +36,18 @@ if ($message->toId == elgg_get_page_owner_guid()) { } else { // sent $user = get_entity($message->toId); - $icon = elgg_view_entity_icon($user, '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)), - )); + + if ($user) { + $icon = elgg_view_entity_icon($user, 'tiny'); + $user_link = elgg_view('output/url', array( + 'href' => "messages/compose?send_to=$user->guid", + 'text' => elgg_echo('messages:to_user', array($user->name)), + 'is_trusted' => true, + )); + } else { + $icon = ''; + $user_link = elgg_echo('messages:deleted_sender'); + } $class = 'message read'; } @@ -52,13 +61,15 @@ if (!$full) { $subject_info .= elgg_view('output/url', array( 'href' => $message->getURL(), 'text' => $message->title, + 'is_trusted' => true, )); -$delete_link = "<span class='elgg-button elgg-button-delete'>" . elgg_view("output/confirmlink", array( +$delete_link = elgg_view("output/confirmlink", array( 'href' => "action/messages/delete?guid=" . $message->getGUID(), - 'text' => elgg_echo('delete'), + 'text' => "<span class=\"elgg-icon elgg-icon-delete float-alt\"></span>", 'confirm' => elgg_echo('deleteconfirm'), - )) . "</span>"; + 'encode_text' => false, + )); $body = <<<HTML <div class="messages-owner">$user_link</div> |
