/**
  * @param Message $message
  */
 public function receivePublishedMessage(Message $message)
 {
     $topic = $message->getTopic();
     $body = $message->getBody();
     foreach ($this->subscribers[$topic] as $subscriber) {
         /** @var $subscriber Subscriber */
         $subscriber->receiveMessage($topic, $body);
     }
 }
?>
</from>
					<to><?php 
echo htmlspecialchars($message->getTo());
?>
</to>
					<cc><?php 
echo htmlspecialchars($message->getCc());
?>
</cc>
					<subject><?php 
echo htmlspecialchars($message->getSubject());
?>
</subject>
					<body><?php 
echo htmlspecialchars($message->getBody());
?>
</body>
				</data>
			</instance>
			<submission id="compose" resource="composemessage.php"
				method="urlencoded-post" />
		</model>
	</models>
	<page-header>
		<tabs ref="selected-tab">
			<tab id='read'>
				<label>Messages</label>
				<load-page event="activate" page="index.php" />
			</tab>
			<tab id='write'>
 /**
  * Tests Message->getBody()
  */
 public function testGetBody()
 {
     $this->assertEquals('BODY', $this->Message->getBody());
 }
Beispiel #4
0
 /**
  * @coroutine
  *
  * @param \Icicle\Http\Message\Message $message
  * @param float|int $timeout
  *
  * @return \Generator
  *
  * @resolve \Icicle\Http\Message\Message
  *
  * @throws \Icicle\Http\Exception\MessageException
  */
 private function buildIncomingStream(Message $message, float $timeout = 0) : \Generator
 {
     $body = $message->getBody();
     if ($body instanceof SeekableStream && $body->isOpen()) {
         yield from $body->seek(0);
     }
     if (!$body->isReadable()) {
         return $message;
     }
     if (strtolower($message->getHeader('Transfer-Encoding') === 'chunked')) {
         $stream = new ChunkedDecoder($this->hwm);
         $coroutine = new Coroutine(Stream\pipe($body, $stream, true, 0, null, $timeout));
         $coroutine->done(null, [$stream, 'close']);
         $message = $message->withBody($stream);
     } elseif ($message->hasHeader('Content-Length')) {
         $length = (int) $message->getHeader('Content-Length');
         if (0 > $length) {
             throw new MessageException(Response::BAD_REQUEST, 'Content-Length header invalid.');
         }
         $stream = new MemoryStream($this->hwm);
         if (0 === $length) {
             yield from $stream->end();
         } else {
             $coroutine = new Coroutine(Stream\pipe($body, $stream, true, $length, null, $timeout));
             $coroutine->done(null, [$stream, 'close']);
         }
         $message = $message->withBody($stream);
     } elseif ($message instanceof Request) {
         switch ($message->getMethod()) {
             case 'POST':
             case 'PUT':
                 // Post and put messages must have content length or be transfer encoded.
                 throw new MessageException(Response::LENGTH_REQUIRED, 'Content-Length header required.');
             default:
                 // Assume 0 length body.
                 $stream = new MemoryStream();
                 yield from $stream->end();
                 // Creates empty request body.
                 return $message->withBody($stream);
         }
     } elseif (strtolower($message->getHeader('Connection')) !== 'close') {
         throw new MessageException(Response::LENGTH_REQUIRED, 'Content-Length header required.');
     }
     $contentEncoding = strtolower($message->getHeader('Content-Encoding'));
     switch ($contentEncoding) {
         case 'deflate':
             $stream = new ZlibDecoder(ZlibDecoder::DEFLATE, $this->hwm);
             break;
         case 'gzip':
             $stream = new ZlibDecoder(ZlibDecoder::GZIP, $this->hwm);
             break;
         case '':
             // No content encoding.
             return $message;
         default:
             throw new MessageException(Response::BAD_REQUEST, sprintf('Unsupported content encoding received: %s', $contentEncoding));
     }
     $coroutine = new Coroutine(Stream\pipe($message->getBody(), $stream, true, 0, null, $timeout));
     $coroutine->done(null, [$stream, 'close']);
     return $message->withBody($stream);
 }
Beispiel #5
0
 /**
  * Tests Message->setBody()
  */
 public function testSetBody()
 {
     $this->message->setBody('body');
     $this->assertEquals('body', $this->message->getBody());
 }
Beispiel #6
0
 /** @override */
 public function send(Message $email)
 {
     return $this->send_($email->getFrom(), $email->getTo(), $email->getSubject(), $email->getBody());
 }
Beispiel #7
0
 /**
  * function sendSimpleMessage
  * primary function for sending messages via array
  *
  * @return void
  * @author Sean Grove
  **/
 public static function sendSimpleMessage($messageArray, $options = null)
 {
     // TODO: allow an email copy of the message to be sent out
     sfContext::getInstance()->getLogger()->log("message:" . print_r($messageArray, true));
     sfContext::getInstance()->getLogger()->log("options:" . print_r($options, true));
     if (!isset($messageArray["message_type"])) {
         $messageArray["message_type"] = 1;
     }
     sfContext::getInstance()->getLogger()->log('sending Message, owner sender');
     $message = new Message();
     $message->setSenderId($messageArray["from"]);
     sfContext::getInstance()->getLogger()->log('set from: ' . $messageArray["from"]);
     $message->setOwnerId($messageArray["owner"]);
     $message->setRecipientId($messageArray["to"]);
     $message->setParentId($messageArray["parent"]);
     $message->setSubject($messageArray["subject"]);
     $message->setBody($messageArray["text"]);
     $message->setHtmlBody('me');
     $message->setFolder($messageArray["folder"]);
     $message->setMessageType($messageArray["message_type"]);
     $message->save();
     if ($message->getMessageType() == 21) {
         EventUserPeer::addUser($message->getUuid(), $options["event_id"], $messageArray["from"], $options["points"], $options["comment"], $options["status"]);
     }
     if (isset($options["copyTo"]) && $options["copyTo"] == "sent") {
         sfContext::getInstance()->getLogger()->log('sending Message, owner recipient');
         $message2 = array();
         $message2["from"] = $messageArray["from"];
         $message2["owner"] = $messageArray["from"];
         $message2["to"] = $messageArray["to"];
         $message2["parent"] = $messageArray["parent"];
         $message2["subject"] = $messageArray["subject"];
         $message2["text"] = $messageArray["text"];
         $message2["folder"] = "sent";
         self::sendSimpleMessage($message2);
     }
     if (!isset($options["notify"]) || $options["notify"] == true) {
         $sender = $message->getsfGuardUserRelatedBySenderId()->getProfile();
         $recipient = $message->getsfGuardUserRelatedByRecipientId()->getProfile();
         $text = '"' . $message->getSubject() . ' :: ' . $message->getBody() . '"';
         $notification = 'New message from ' . $sender->getFullName() . ' on Cothink! ';
         $notification .= $text;
         $recipient->notify($notification);
     }
     sfContext::getInstance()->getLogger()->log('message sent');
 }
 /**
  * Tests the setters and getters.
  */
 public function testSettersAndGetters()
 {
     // create a message with minimum constructor args
     $message = new Message(Message::NORMAL);
     // Set remainder via setters
     $message->setHeader((object) array('testProp' => 'testval'));
     $message->setBody(simplexml_load_string('<testMessage testAtt="Hello" testAtt2="world"/>'));
     $message->setPriority(Message::PRIORITY_LOW);
     // test assertions
     $this->assertTrue($message instanceof Message, "Expecting \$message is Message");
     $this->assertTrue($message->getType() == Message::NORMAL, "Expecting \$message->getType() == Message::NORMAL");
     $this->assertTrue($message->getHeader()->testProp == 'testval', "Expecting \$message->getHeader()->testProp == 'testval'");
     $this->assertTrue($message->getBody()->attributes()->testAtt == 'Hello', "Expecting \$message->getBody()->attributes()->testAtt == 'Hello'");
     $this->assertTrue($message->getPriority() == Message::PRIORITY_LOW, "Expecting \$message->getPriority() == Message::PRIORITY_LOW");
 }