/** * * @param <type> $request */ public function execute($request) { $userRoleManager = $this->getContext()->getUserRoleManager(); $requiredPermissions = array(BasicUserRoleManager::PERMISSION_TYPE_DATA_GROUP => array('recruitment_candidates' => new ResourcePermission(true, false, false, false))); $allowedVacancyList = $userRoleManager->getAccessibleEntityIds('Vacancy', null, null, array(), array(), $requiredPermissions); $usrObj = $this->getUser()->getAttribute('user'); $allowedCandidateList = $usrObj->getAllowedCandidateList(); $allowedCandidateListToDelete = $usrObj->getAllowedCandidateListToDelete(); $this->candidaatePermissions = $this->getDataGroupPermissions('recruitment_candidates'); $isAdmin = $usrObj->isAdmin(); if (!($usrObj->isAdmin() || $usrObj->isHiringManager() || $usrObj->isInterviewer() || $this->candidaatePermissions->canRead())) { $this->redirect('pim/viewPersonalDetails'); } $param = array('allowedCandidateList' => $allowedCandidateList, 'allowedVacancyList' => $allowedVacancyList, 'allowedCandidateListToDelete' => $allowedCandidateListToDelete); list($this->messageType, $this->message) = $this->getUser()->getFlash('candidateListMessageItems'); $candidateId = $request->getParameter('candidateId'); $sortField = $request->getParameter('sortField'); $sortOrder = $request->getParameter('sortOrder'); $isPaging = $request->getParameter('pageNo'); $pageNumber = $isPaging; if (!is_null($this->getUser()->getAttribute('pageNumber')) && !($pageNumber >= 1)) { $pageNumber = $this->getUser()->getAttribute('pageNumber'); } $this->getUser()->setAttribute('pageNumber', $pageNumber); $searchParam = new CandidateSearchParameters(); $searchParam->setIsAdmin($isAdmin); $searchParam->setEmpNumber($usrObj->getEmployeeNumber()); $noOfRecords = $searchParam->getLimit(); $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords; $searchParam->setAdditionalParams($request->getParameter('additionalParams', array())); $this->setForm(new viewCandidatesForm(array(), $param, true)); if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $candidateId > 0) { if ($this->getUser()->hasAttribute('searchParameters')) { $searchParam = $this->getUser()->getAttribute('searchParameters'); $this->form->setDefaultDataToWidgets($searchParam); } $searchParam->setSortField($sortField); $searchParam->setSortOrder($sortOrder); } else { $this->getUser()->setAttribute('searchParameters', $searchParam); $offset = 0; $pageNumber = 1; } $searchParam->setAllowedCandidateList($allowedCandidateList); $searchParam->setAllowedVacancyList($allowedVacancyList); $searchParam->setOffset($offset); $candidates = $this->getCandidateService()->searchCandidates($searchParam); if ($this->candidaatePermissions->canRead()) { $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber, $this->candidaatePermissions); } $params = array(); $this->parmetersForListCompoment = $params; if (empty($isPaging)) { if ($request->isMethod('post')) { $pageNumber = 1; $searchParam->setOffset(0); $this->getUser()->setAttribute('pageNumber', $pageNumber); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $srchParams = $this->form->getSearchParamsBindwithFormData($searchParam); $this->getUser()->setAttribute('searchParameters', $srchParams); $candidates = $this->getCandidateService()->searchCandidates($srchParams); $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber, $this->candidaatePermissions); } } } }
/** * Testing getCandidateList when only Hiring Manager is provided */ public function testGetCandidateListForHiringManager() { $searchParam = new CandidateSearchParameters(); $searchParam->setHiringManagerId(1); $searchParam->setIsAdmin(false); $searchParam->setAllowedCandidateList(array(1, 2, 3, 4, 5)); $searchParam->setAllowedVacancyList(array(1, 2, 3)); $searchParam->setEmpNumber(2); $candidateVacancyList = $this->candidateDao->searchCandidates($this->candidateDao->buildSearchQuery($searchParam)); $this->assertTrue($candidateVacancyList[0] instanceof CandidateSearchParameters); }
/** * * @param <type> $request */ public function execute($request) { $usrObj = $this->getUser()->getAttribute('user'); $allowedCandidateList = $usrObj->getAllowedCandidateList(); $allowedVacancyList = $usrObj->getAllowedVacancyList(); $allowedCandidateListToDelete = $usrObj->getAllowedCandidateListToDelete(); $isAdmin = $usrObj->isAdmin(); if (!($usrObj->isAdmin() || $usrObj->isHiringManager() || $usrObj->isInterviewer())) { $this->redirect('pim/viewPersonalDetails'); } $param = array('allowedCandidateList' => $allowedCandidateList, 'allowedVacancyList' => $allowedVacancyList, 'allowedCandidateListToDelete' => $allowedCandidateListToDelete); list($this->messageType, $this->message) = $this->getUser()->getFlash('candidateListMessageItems'); $candidateId = $request->getParameter('candidateId'); $sortField = $request->getParameter('sortField'); $sortOrder = $request->getParameter('sortOrder'); $isPaging = $request->getParameter('pageNo'); $pageNumber = $isPaging; if (!is_null($this->getUser()->getAttribute('pageNumber')) && !($pageNumber >= 1)) { $pageNumber = $this->getUser()->getAttribute('pageNumber'); } $this->getUser()->setAttribute('pageNumber', $pageNumber); $searchParam = new CandidateSearchParameters(); $searchParam->setIsAdmin($isAdmin); $searchParam->setEmpNumber($request->getParameter('referralId')); $searchParam->setReferralName($request->getParameter('referralName')); $noOfRecords = $searchParam->getLimit(); $offset = $pageNumber >= 1 ? ($pageNumber - 1) * $noOfRecords : ($request->getParameter('pageNo', 1) - 1) * $noOfRecords; $searchParam->setAdditionalParams($request->getParameter('additionalParams', array())); $this->setForm(new viewCandidatesForm(array(), $param, true)); if (!empty($sortField) && !empty($sortOrder) || $isPaging > 0 || $candidateId > 0) { if ($this->getUser()->hasAttribute('searchParameters')) { $searchParam = $this->getUser()->getAttribute('searchParameters'); $this->form->setDefaultDataToWidgets($searchParam); } $searchParam->setSortField($sortField); $searchParam->setSortOrder($sortOrder); } else { $this->getUser()->setAttribute('searchParameters', $searchParam); $offset = 0; $pageNumber = 1; } $searchParam->setAllowedCandidateList($allowedCandidateList); $searchParam->setAllowedVacancyList($allowedVacancyList); $searchParam->setOffset($offset); $candidates = $this->getCandidateService()->searchCandidates($searchParam); $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber); $params = array(); $this->parmetersForListCompoment = $params; if (empty($isPaging)) { if ($request->isMethod('post')) { $pageNumber = 1; $searchParam->setOffset(0); $this->getUser()->setAttribute('pageNumber', $pageNumber); $this->form->bind($request->getParameter($this->form->getName())); if ($this->form->isValid()) { $srchParams = $this->form->getSearchParamsBindwithFormData($searchParam); $this->getUser()->setAttribute('searchParameters', $srchParams); $candidates = $this->getCandidateService()->searchCandidates($srchParams); $this->_setListComponent($usrObj, $candidates, $noOfRecords, $searchParam, $pageNumber); } } } }