diff options
Diffstat (limited to 'src/Psecio/Gatekeeper/UserCollection.php')
-rw-r--r-- | src/Psecio/Gatekeeper/UserCollection.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Psecio/Gatekeeper/UserCollection.php b/src/Psecio/Gatekeeper/UserCollection.php index 805ad52..ba9f9df 100644 --- a/src/Psecio/Gatekeeper/UserCollection.php +++ b/src/Psecio/Gatekeeper/UserCollection.php @@ -24,4 +24,26 @@ class UserCollection extends \Psecio\Gatekeeper\Collection\Mysql $this->add($user); } } + + /** + * Find the users that have a permission defined by the + * given ID + * + * @param integer $permId Permission ID + */ + public function findUsersByPermissionId($permId) + { + $prefix = $this->getPrefix(); + $data = array('permId' => $permId); + $sql = 'select u.* from '.$prefix.'users u, '.$prefix.'user_permission up' + .' where up.permission_id = :permId' + .' and up.user_id = u.id'; + + $results = $this->getDb()->fetch($sql, $data); + + foreach ($results as $result) { + $user = new UserModel($this->getDb(), $result); + $this->add($user); + } + } }
\ No newline at end of file |