public function get($itemsToGet = 0, $offset = 0)
 {
     $r = parent::get($itemsToGet, $offset);
     foreach ($r as $row) {
         $messages[] = UserPrivateMessage::getByID($row['msgID'], $this->mailbox);
     }
     return $messages;
 }
 public static function getByID($msgID, $mailbox = false)
 {
     $db = Loader::db();
     $row = $db->GetRow('select uAuthorID, msgDateCreated, msgID, msgSubject, msgBody, uToID from UserPrivateMessages where msgID = ?', array($msgID));
     if (!isset($row['msgID'])) {
         return false;
     }
     $upm = new UserPrivateMessage();
     $upm->setPropertiesFromArray($row);
     if ($mailbox) {
         // we add in some mailbox-specific attributes
         $row = $db->GetRow('select msgID, msgIsNew, msgIsUnread, msgMailboxID, msgIsReplied, uID from UserPrivateMessagesTo where msgID = ? and uID = ?', array($msgID, $mailbox->getMailboxUserID()));
         if (isset($row['msgID'])) {
             $upm->setPropertiesFromArray($row);
         }
         $upm->mailbox = $mailbox;
     }
     return $upm;
 }
Esempio n. 3
0
	public function process($mail) {
		// now that we're here, we know that we're validated and that this is an email
		// coming from someone proper.
		
		// We need to know what to do with it, now. We check the "data" column, which stores
		// a serialized PHP object that contains relevant information about what this item needs to respond to, post to, etc...
		$do = $mail->getDataObject();
		Loader::model('user_private_message');
		if ($do->msgID > 0) {
			$upm = UserPrivateMessage::getByID($do->msgID);
			if (is_object($upm)) {
				$originalTo = UserInfo::getByID($do->toUID);
				$originalFrom = UserInfo::getByID($do->fromUID);
				if (is_object($originalTo) && is_object($originalFrom)) {
					$originalTo->sendPrivateMessage($originalFrom, $mail->getSubject(), $mail->getProcessedBody(), $upm);
				}
			}			
		}
	}
Esempio n. 4
0
	public function reply($boxID, $msgID) {
		$msg = UserPrivateMessage::getByID($msgID);
		$uID = $msg->getMessageRelevantUserID();
		$this->validateUser($uID);
		$this->set('backURL', View::url('/profile/messages', 'view_message', $boxID, $msgID));
		$this->set('msgID', $msgID);
		$this->set('box', $boxID);
		$this->set('msg', $msg);
		
		$this->set('msgSubject', $msg->getFormattedMessageSubject());
		
		$body = "\n\n\n" . $msg->getMessageDelimiter() . "\n";
		$body .= t("From: %s\nDate Sent: %s\nSubject: %s", $msg->getMessageAuthorName(), $msg->getMessageDateAdded('user', t('F d, Y \a\t g:i A')), $msg->getFormattedMessageSubject());
		$body .= "\n\n" . $msg->getMessageBody();
		$this->set('msgBody', $body);
	}