public function executeApply() { $this->forward404Unless($this->getUser()->isAuthenticated(), 'User not logged in, unable to apply for project position'); $user = $this->getUser()->getProfile(); $position = ProjectPositionPeer::retrieveByUuid($this->getRequestParameter('position')); $this->forward404Unless($position, 'Position not found, unable to apply for position'); $projectUser = new ProjectUser(); $projectUser->setUserId($user->getUserId()); $projectUser->setPositionId($position->getId()); $projectUser->setStatus(sfConfig::get('app_project_user_status_pending')); // Status(3): pending review $projectUser->save(); // Alert the project owner of the application $profile = $position->getProject()->getSfGuardUserRelatedByOwnerId()->getProfile(); $profile->addHistoryEvent('New application for project "' . $position->getProject() . '"', $this->getUser()->getProfile() . ' has applied for a project you currently own. ' . ucfirst($profile->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'); $this->position = $position; $this->projectUser = $projectUser; }
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); }