public function handleNewApplicant($position_id, $user_id) { $position = ProjectPositionPeer::retrieveByPK($position_id); $user = sfGuardUserPeer::retrieveByPK($user_id); // Alert the project owner of the application $profile = $this->getSfGuardUserRelatedByOwnerId()->getProfile(); $profile->addHistoryEvent('New application for project "' . $this->getTitle() . '"', $user->getProfile()->getFullName() . ' has applied for a project you currently own. ' . ucfirst($user->getProfile()->getGenderSubject()) . ' would like to join your project as "' . $position->getTitle() . '". Please review the application using the applicaiton manager found on the project\'s page.', 'projects'); $message = array(); $message["from"] = $user->getId(); $message["to"] = $this->getOwnerId(); $message["owner"] = $this->getOwnerId(); $message["folder"] = "inbox"; $message["parent"] = null; $message["subject"] = 'New application for project "' . $this . '"'; $message["text"] = $user->getProfile()->getFullName() . ' has applied for a project you currently own. ' . ucfirst($user->getProfile()->getGenderSubject()) . ' would like to join your project as "' . $position->getTitle() . '". Please review the application using the applicaiton manager found on the project\'s page.'; $options = array(); $options["copyTo"] = "none"; $projectUser = new ProjectUser(); $projectUser->setUserId($user->getId()); $projectUser->setPositionId($position->getId()); $projectUser->setStatus(sfConfig::get('app_project_user_status_pending')); // Status(3): pending review $projectUser->save(); MessagePeer::sendSimpleMessage($message, $options); }
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 executeRemoveConnection() { $socon = SocialConnectionPeer::retrieveByUuid($this->getRequestParameter('socon')); $this->forward404Unless($socon, "Socon not found, unable to remove"); $socon->setStatus(sfConfig::get('app_socon_status_declined')); $socon->save(); $other = $socon->getOtherUser($this->getUser()->getId()); $message = array(); $message["from"] = $this->getUser()->getId(); $message["to"] = $this->getUser()->getId(); $message["owner"] = $this->getUser()->getId(); $message["parent"] = null; $message["folder"] = "inbox"; $message["subject"] = "You have removed a social connection"; $message["text"] = 'You have removed your connection with ' . $other->getProfile() . '.'; $options = array(); MessagePeer::sendSimpleMessage($message, $options); $this->redirect('networks/index?tab=main'); }