/**
 * Notification handler
 *
 * @param ElggEntity $from
 * @param ElggUser   $to
 * @param string     $subject
 * @param string     $message
 * @param array      $params
 * @return bool
 */
function hj_inbox_site_notify_handler(ElggEntity $from, ElggUser $to, $subject, $message, array $params = array())
{
    if (!$from) {
        throw new NotificationException(elgg_echo('NotificationException:MissingParameter', array('from')));
    }
    if (!$to) {
        throw new NotificationException(elgg_echo('NotificationException:MissingParameter', array('to')));
    }
    return hj_inbox_send_message($from->guid, $to->guid, $subject, $message, HYPEINBOX_NOTIFICATION, $params);
}
Exemple #2
0
<?php

elgg_make_sticky_form('messages');
$subject = strip_tags(get_input('subject', elgg_echo('hj:inbox:untitled')));
$message = get_input('body', '');
$message_type = get_input('message_type', HYPEINBOX_PRIVATE);
$message_hash = get_input('message_hash', null);
$sender_guid = elgg_get_logged_in_user_guid();
$recipient_guids = get_input('recipient_guids');
if (!$recipient_guids) {
    register_error(elgg_echo("messages:user:blank"));
    forward("messages/compose");
} else {
    if (!is_array($recipient_guids)) {
        $recipient_guids = array($recipient_guids);
    }
}
$result = hj_inbox_send_message($sender_guid, $recipient_guids, $subject, $message, $message_type, array('message_hash' => $message_hash, 'attachments' => $_FILES['attachments']));
if (!$result) {
    register_error(elgg_echo("messages:error"));
    forward("messages/compose");
}
elgg_clear_sticky_form('messages');
system_message(elgg_echo("messages:posted"));
forward('messages/inbox/' . elgg_get_logged_in_user_entity()->username . '?message_type=' . $message_type);