diff --git a/config/config.php b/config/config.php index c10eac66a..21b2032c6 100644 --- a/config/config.php +++ b/config/config.php @@ -166,6 +166,12 @@ functionality to PhpReport */ define('ALL_USERS_GROUP', 'staff'); +/** + * @name EMPLOYEES_GROUP + * @global string users group used for retrieving all active employees + */ +define('EMPLOYEES_GROUP', 'staff'); + /** * @name USER_GROUPS * @global string all user groups for displaying on the interfaces as diff --git a/docs/admin/ldap.rst b/docs/admin/ldap.rst index a89f5d228..007b5b96d 100644 --- a/docs/admin/ldap.rst +++ b/docs/admin/ldap.rst @@ -68,6 +68,16 @@ PhpReport:: */ define('ALL_USERS_GROUP', 'staff'); +You can also define a group to display only active employees based on +its respective LDAP group: + + /** + * @name EMPLOYEES_GROUP + * @global string users group used for retrieving all active employees + */ + define('EMPLOYEES_GROUP', 'employees'); + + And in this line you must indicate a list with the names of the user groups that will have some meaning for PhpReport:: diff --git a/model/facade/UsersFacade.php b/model/facade/UsersFacade.php index 89a8ba941..4aaab392a 100644 --- a/model/facade/UsersFacade.php +++ b/model/facade/UsersFacade.php @@ -158,8 +158,8 @@ static function GetAllUsers() { } - static function GetAllActiveUsers() { - $action = new GetAllActiveUsersAction(); + static function GetAllActiveUsers($filterEmployees = false) { + $action = new GetAllActiveUsersAction($filterEmployees); return $action->execute(); } diff --git a/model/facade/action/GetAllActiveUsersAction.php b/model/facade/action/GetAllActiveUsersAction.php index ca554a153..99766d22c 100644 --- a/model/facade/action/GetAllActiveUsersAction.php +++ b/model/facade/action/GetAllActiveUsersAction.php @@ -22,14 +22,21 @@ include_once(PHPREPORT_ROOT . '/model/dao/DAOFactory.php'); include_once(PHPREPORT_ROOT . '/util/ConfigurationParametersManager.php'); -class GetAllActiveUsersAction extends Action{ - public function __construct() { - $this->preActionParameter="GET_ALL_ACTIVE_USERS_PREACTION"; - $this->postActionParameter="GET_ALL_ACTIVE_USERS_POSTACTION"; +class GetAllActiveUsersAction extends Action +{ + public function __construct($filterEmployees = false) + { + $this->preActionParameter = "GET_ALL_ACTIVE_USERS_PREACTION"; + $this->postActionParameter = "GET_ALL_ACTIVE_USERS_POSTACTION"; + $this->filterEmployees = $filterEmployees; } - protected function doExecute() { + protected function doExecute() + { $groupDAO = DAOFactory::getUserGroupDAO(); - return $groupDAO->getUsersByUserGroupName(ConfigurationParametersManager::getParameter("ALL_USERS_GROUP")); + $group = $this->filterEmployees ? + ConfigurationParametersManager::getParameter("EMPLOYEES_GROUP") : + ConfigurationParametersManager::getParameter("ALL_USERS_GROUP"); + return $groupDAO->getUsersByUserGroupName($group); } } diff --git a/web/js/holidayManagement.js b/web/js/holidayManagement.js index 062c36a46..6c329e83a 100644 --- a/web/js/holidayManagement.js +++ b/web/js/holidayManagement.js @@ -200,7 +200,7 @@ var app = new Vue({ } }, async fetchUsers() { - const url = `services/getAllUsersService.php?active=true`; + const url = `services/getAllUsersService.php?active=true&filterEmployees=true`; const res = await fetch(url, { method: 'GET', mode: 'same-origin', diff --git a/web/services/getAllUsersService.php b/web/services/getAllUsersService.php index e48d1b813..128aa5ebf 100644 --- a/web/services/getAllUsersService.php +++ b/web/services/getAllUsersService.php @@ -34,6 +34,7 @@ $sid = $_GET['sid'] ?? NULL; $active = $_GET['active'] ?? NULL; + $filterEmployees = $_GET['filterEmployees'] ?? false; do { /* We check authentication and authorization */ @@ -53,7 +54,7 @@ if ($active == "true") { - $users = UsersFacade::GetAllActiveUsers(); + $users = UsersFacade::GetAllActiveUsers($filterEmployees); } else {