Skip to content

Commit

Permalink
Merge pull request #163 from HavrilaJ/updateDaoManagers
Browse files Browse the repository at this point in the history
Adding new functions to DAO and Managers
  • Loading branch information
kouril authored Sep 20, 2019
2 parents 3cda491 + 03f0552 commit 8e711f1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/dao/HostGroupDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 6 additions & 0 deletions src/dao/UserDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
10 changes: 10 additions & 0 deletions src/managers/HostGroupsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
7 changes: 7 additions & 0 deletions src/managers/UsersManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 8e711f1

Please sign in to comment.