diff --git a/src/dao/HostGroupDao.php b/src/dao/HostGroupDao.php index 850d6a18..273b7ef1 100644 --- a/src/dao/HostGroupDao.php +++ b/src/dao/HostGroupDao.php @@ -110,4 +110,10 @@ public function removeHostFromHostGroups($hostId) $sql = "delete from HostHostGroup where hostId = '".$this->db->escape($hostId)."'"; $this->db->query($sql); } + + public function getUsersAssignedToHostGroup($hostGroupId) + { + $sql = "select userId from UserHostGroup where hostGroupId = '".$this->db->escape($hostGroupId)."'"; + return $this->db->queryToSingleValueMultiRow($sql); + } } diff --git a/src/dao/UserDao.php b/src/dao/UserDao.php index 63ce09fc..4f94e8d4 100644 --- a/src/dao/UserDao.php +++ b/src/dao/UserDao.php @@ -104,4 +104,10 @@ public function unassignHostGroupToUser($userId, $hostGroupId) $this->db->query($sql); return $this->db->getNumberOfAffectedRows(); } + + public function getHostGroupsAssignedToUser($userId) + { + $sql = "select hostGroupId from UserHostGroup where userId = '".$this->db->escape($userId)."'"; + return $this->db->queryToSingleValueMultiRow($sql); + } } diff --git a/src/managers/HostGroupsManager.php b/src/managers/HostGroupsManager.php index fff4bfd7..ccd6c235 100644 --- a/src/managers/HostGroupsManager.php +++ b/src/managers/HostGroupsManager.php @@ -87,6 +87,16 @@ public function getHostGroupsCount($userId = -1) return sizeof($this->getPakiti()->getDao("HostGroup")->getHostGroupsIds(null, -1, -1, $userId)); } + /** + * Get Users Assigned to particular HostGroup + */ + public function getUsersAssignedToHostGroup($hostGroupId) + { + Utils::log(LOG_DEBUG, "Getting all Users assigned to host group[$hostGroupId]", __FILE__, __LINE__); + $dao = $this->getPakiti()->getDao("HostGroup"); + return $dao->getUsersAssignedToHostGroup($hostGroupId); + } + /** * Create association between host and hostGroup */ diff --git a/src/managers/UsersManager.php b/src/managers/UsersManager.php index f99e9385..66aa5ae3 100644 --- a/src/managers/UsersManager.php +++ b/src/managers/UsersManager.php @@ -106,4 +106,11 @@ public function unassignHostGroupToUser($userId, $hostGroupId) $dao = $this->getPakiti()->getDao("User"); return $dao->unassignHostGroupToUser($userId, $hostGroupId); } + + public function getHostGroupsAssignedToUser($userId) + { + Utils::log(LOG_DEBUG, "Get host groups assigned to user[$userId]", __FILE__, __LINE__); + $dao = $this->getPakiti()->getDao("User"); + return $dao->getHostGroupsAssignedToUser($userId); + } }