public function executeApplicationBrowser() { $this->forward404Unless($this->getRequest()->isXMLHttpRequest(), 'Not an XMLHttp request, not authorized'); $this->forward404Unless($this->position = ProjectPositionPeer::retrieveByUuid($this->getRequestParameter('position')), 'Position not found'); $this->project = $this->position->getProject(); $this->forward404Unless($this->getUser()->isAuthenticated() && $this->project->isAuthorized('handle-applications', $this->getUser()->getId()), 'User not logged in or does not have permission to handle applications'); }
/** * Executes handleErrorUpdateMilestone action * */ public function handleErrorUpdateMilestone() { $this->forward404Unless($this->project = ProjectPeer::retrieveBySlug($this->getRequestParameter('project')), 'Project does not exist, using slug [' . $this->getRequestParameter('project') . ']'); $this->tab = sfConfig::get('app_tab_project_team'); $this->position = ProjectPositionPeer::retrieveByUuid($this->getRequestParameter('position')); if ($this->position == null) { $this->position = new ProjectPosition(); } $this->setTemplate('updateMilestone'); return sfView::SUCCESS; }
public function clonePositionAcceptApplicant($position_uuid, $user_uuid) { // retrieve desired position $position_old = ProjectPositionPeer::retrieveByUuid($position_uuid); // clone position $position = $position_old->copy(); // clear uuid so it will regenerate a unique one, save $position->setUuid(NULL); $position->setFilled(true); $position->save(); // grab desired user $user = sfGuardUserProfilePeer::retrieveByUuid($user_uuid); // remove applicant from old position $positionUser = ProjectUserPeer::retrieveByPositionIdUserId($position_old->getId(), $user->getUserId()); if ($positionUser == null) { sfContext::getInstance()->getLogger()->info('Old PositionUser not found, unable to clone and accept applicant'); return false; } $positionUser->delete(); // build a new positionUser object $positionUser = new ProjectUser(); $positionUser->setPositionId($position->getId()); $positionUser->setUserId($user->getUserId()); $positionUser->setStatus(1); // Status(1): Accepted $positionUser->save(); if ($position == null || $user == null || $positionUser == null) { sfContext::getInstance()->getLogger()->info('Position, user, or PositionUser not found, unable to accept applicant'); return false; } // Assign user to members group $user = $user->getSfGuardUser(); $this->addUserToGroup($user, 'members'); return true; }