diff options
author | Chris Cornutt <enygma@phpdeveloper.org> | 2015-07-10 13:52:03 -0500 |
---|---|---|
committer | Chris Cornutt <enygma@phpdeveloper.org> | 2015-07-10 13:52:03 -0500 |
commit | e4f103eb782a3c439c88f5a9d02fdeda5fb125fd (patch) | |
tree | e94c020bfb970463bc6ad4362c73fe8bc59cc024 /src | |
parent | d35657b0a156a539654544b28213cea98e7435e9 (diff) | |
download | gatekeeper-e4f103eb782a3c439c88f5a9d02fdeda5fb125fd.zip gatekeeper-e4f103eb782a3c439c88f5a9d02fdeda5fb125fd.tar.gz gatekeeper-e4f103eb782a3c439c88f5a9d02fdeda5fb125fd.tar.bz2 |
adding method to get the groups a permission belongs to
Diffstat (limited to 'src')
-rw-r--r-- | src/Psecio/Gatekeeper/GroupCollection.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Psecio/Gatekeeper/GroupCollection.php b/src/Psecio/Gatekeeper/GroupCollection.php index 13c7808..90e8b07 100644 --- a/src/Psecio/Gatekeeper/GroupCollection.php +++ b/src/Psecio/Gatekeeper/GroupCollection.php @@ -24,4 +24,25 @@ class GroupCollection extends \Psecio\Gatekeeper\Collection\Mysql $this->add($group); } } + + /** + * Find the groups that a permission belongs to + * + * @param integer $permId Permission ID + */ + public function findGroupsByPermissionId($permId) + { + $prefix = $this->getPrefix(); + $data = array('permId' => $permId); + $sql = 'select g.* from '.$prefix.'groups g, '.$prefix.'group_permission gp' + .' where gp.permission_id = :permId' + .' and gp.group_id = g.id'; + + $results = $this->getDb()->fetch($sql, $data); + + foreach ($results as $result) { + $group = new GroupModel($this->getDb(), $result); + $this->add($group); + } + } }
\ No newline at end of file |