1<?php 2/* 3 * 4 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures 5 * all the essential functionalities required for any enterprise. 6 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com 7 * 8 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of 9 * the GNU General Public License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 * See the GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along with this program; 17 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301, USA 19 * 20 */ 21 22class viewRecruitmentModuleAction extends sfAction { 23 24 protected $homePageService; 25 26 public function getHomePageService() { 27 28 if (!$this->homePageService instanceof HomePageService) { 29 $this->homePageService = new HomePageService($this->getUser()); 30 } 31 32 return $this->homePageService; 33 34 } 35 36 public function setHomePageService($homePageService) { 37 $this->homePageService = $homePageService; 38 } 39 40 public function execute($request) { 41 $defaultPath = $this->getHomePageService()->getRecruitmentModuleDefaultPath(); 42 if (empty($defaultPath)) { 43 $candidatesPermission = $this->getDataGroupPermissions('recruitment_candidates'); 44 if ($candidatesPermission->canRead()) { 45 $defaultPath = 'recruitment/viewCandidates'; 46 } else { 47 $vacanciesPermission = $this->getDataGroupPermissions('recruitment_vacancies'); 48 if ($vacanciesPermission->canRead()) { 49 $defaultPath = 'recruitment/viewJobVacancy'; 50 } 51 } 52 } 53 54 if (empty($defaultPath)) { 55 $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); 56 } else { 57 $this->redirect($defaultPath); 58 } 59 } 60 61 public function getDataGroupPermissions($dataGroups) { 62 return $this->getContext()->getUserRoleManager()->getDataGroupPermissions($dataGroups); 63 } 64 65} 66