Permalink
Browse files

feature(messages): recipient selection by userpicker

The messages recipient selection give better visual feedback of who will
be the recipient
  • Loading branch information...
jeabakker committed Apr 29, 2015
1 parent 38b7010 commit 932e974cdf7c41b40f213f8dec4dd0972a550123
@@ -1,28 +1,29 @@
<?php
/**
* Ssend a message action
*
*
* @package ElggMessages
*/
$subject = strip_tags(get_input('subject'));
$body = get_input('body');
$recipient_username = get_input('recipient_username');
$recipients = (array) get_input('recipients');
$original_msg_guid = (int)get_input('original_guid');
elgg_make_sticky_form('messages');
if (!$recipient_username) {
if (empty($recipients)) {
register_error(elgg_echo("messages:user:blank"));
forward("messages/compose");
}
if ($recipient_username == elgg_get_logged_in_user_entity()->username) {
$recipient = (int) elgg_extract(0, $recipients);
if ($recipient == elgg_get_logged_in_user_guid()) {
register_error(elgg_echo("messages:user:self"));
forward("messages/compose");
forward("messages/compose");
}
$user = get_user_by_username($recipient_username);
$user = get_user($recipient);
if (!$user) {
register_error(elgg_echo("messages:user:nonexist"));
forward("messages/compose");
@@ -34,7 +35,7 @@
forward("messages/compose");
}
// Otherwise, 'send' the message
// Otherwise, 'send' the message
$result = messages_send($subject, $body, $user->guid, 0, $original_msg_guid);
// Save 'send' the message
@@ -12,17 +12,17 @@
*/
function messages_prepare_form_vars($recipient_guid = 0) {
$recipient_username = '';
$recipient = get_entity($recipient_guid);
if (elgg_instanceof($recipient, 'user')) {
$recipient_username = $recipient->username;
$recipients = array();
$recipient = get_user($recipient_guid);
if (!empty($recipient)) {
$recipients[] = $recipient->getGUID();
}
// input names => defaults
$values = array(
'subject' => '',
'body' => '',
'recipient_username' => $recipient_username,
'recipients' => $recipients,
);
if (elgg_is_sticky_form('messages')) {
@@ -8,14 +8,14 @@
* @uses $vars['body']
*/
$recipient_username = elgg_extract('recipient_username', $vars, '');
$recipients = elgg_extract('recipients', $vars);
$subject = elgg_extract('subject', $vars, '');
$body = elgg_extract('body', $vars, '');
$recipient_autocomplete = elgg_view('input/autocomplete', array(
'name' => 'recipient_username',
'value' => $recipient_username,
'match_on' => array('friends'),
$recipient_autocomplete = elgg_view('input/userpicker', array(
'name' => 'recipients',
'values' => $recipients,
'limit' => 1,
));
?>

0 comments on commit 932e974

Please sign in to comment.