public function executeSend() { // TODO: decide how things can be done as far as sending messages without usernames. Use the prototype.js implementation of facebook's method $this->forward404Unless($this->getRequestParameter('user_recipient'), 'no recipient'); $parent = $this->getRequestParameter('parent_id'); if ($parent != null) { $parent_message = MessagePeer::retrieveByUUID($parent); $recipient = sfGuardUserPeer::retrieveByPk($parent_message->getSenderId()); $this->forward404Unless($recipient, 'recipient not found'); $to = $parent_message->getSenderId(); } else { $recipient = sfGuardUserProfilePeer::retrieveByFullName(trim($this->getRequestParameter('user_recipient'))); $this->forward404Unless($recipient, 'recipient not found'); $to = $recipient->getUserId(); $parent = null; } $this->forward404Unless($to, 'recipient not found'); $message = array(); $message["from"] = $this->getUser()->getProfile()->getUserId(); $message["to"] = $to; $message["owner"] = $to; $message["parent"] = $parent; $message["folder"] = "inbox"; $message["subject"] = strip_tags($this->getRequestParameter('subject')); $message["text"] = strip_tags($this->getRequestParameter('body')); $options = array(); $options["copyTo"] = "sent"; MessagePeer::sendSimpleMessage($message, $options); return $this->redirect('messages/showUserMailbox'); }
public function execute(&$value, &$error) { if (sfGuardUserProfilePeer::retrieveByFullName($value) == null) { $error = $this->getParameter('user_error'); $error = "*Sorry, we can't seem to find this user. Maybe you meant someone else?"; return false; } return true; }