<?php use hypeJunction\Access\EntitySet; use hypeJunction\Inbox\Message; $original_msg_guid = get_input('original_guid'); $original_message = get_entity($original_msg_guid); $sender_guid = elgg_get_logged_in_user_guid(); $recipient_guids = EntitySet::create(get_input('recipients', []))->guids(); $subject = htmlspecialchars(get_input('subject', ''), ENT_QUOTES, 'UTF-8'); $body = get_input('body'); if (empty($recipient_guids)) { register_error(elgg_echo('inbox:send:error:no_recipients')); forward(REFERRER); } if (empty(elgg_strip_tags($body))) { register_error(elgg_echo('inbox:send:error:no_body')); forward(REFERRER); } $enable_html = elgg_get_plugin_setting('enable_html', 'hypeInbox'); if (!$enable_html) { $body = elgg_strip_tags($body); } $message_hash = ''; $message_type = get_input('message_type', Message::TYPE_PRIVATE); if ($original_message instanceof Message) { $message_hash = $original_message->getHash(); $message_type = $original_message->getMessageType(); } $message = Message::factory(array('sender' => $sender_guid, 'recipients' => $recipient_guids, 'subject' => $subject, 'body' => $body, 'hash' => $message_hash, 'message_type' => $message_type)); $guid = $message->send(); if (!$guid) {
/** * Prepare compose form variables * * @param integer $recipient_guids GUIDs of recipients if any * @param string $message_type Type of the message being composed * @param ElggObject $entity Message to which the reply is to be sent * @return array An array of form variables */ public function prepareFormValues($recipient_guids = null, $message_type = null, $entity = null) { if (!$message_type) { $message_type = Message::TYPE_PRIVATE; } $recipient_guids = EntitySet::create($recipient_guids)->guids(); $ruleset = hypeInbox()->config->getRuleset($message_type); $values = array('entity' => $entity, 'multiple' => $ruleset->allowsMultipleRecipients(), 'has_subject' => $ruleset->hasSubject(), 'allows_attachments' => $ruleset->allowsAttachments(), 'subject' => $entity ? "Re: {$entity->title}" : '', 'body' => '', 'recipient_guids' => $recipient_guids, 'message_type' => $message_type); if (elgg_is_sticky_form('messages')) { $sticky = elgg_get_sticky_values('messages'); foreach ($sticky as $field => $value) { if ($field == 'recipients' && is_string($value)) { $value = string_to_tag_array($value); $values['recipient_guids'] = $value; } } } elgg_clear_sticky_form('messages'); return $values; }