summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Cornutt <enygma@phpdeveloper.org>2014-12-13 20:37:05 -0600
committerChris Cornutt <enygma@phpdeveloper.org>2014-12-13 20:37:05 -0600
commitfcdf87be662e620d8177b81f68d975ab93e736d4 (patch)
tree35e33cdbaf75a73c6c7eb5d965a773ad16ef338a
parent335f5875a87d2eca55dbafeb9c8f42f3eaac41c9 (diff)
downloadgatekeeper-fcdf87be662e620d8177b81f68d975ab93e736d4.zip
gatekeeper-fcdf87be662e620d8177b81f68d975ab93e736d4.tar.gz
gatekeeper-fcdf87be662e620d8177b81f68d975ab93e736d4.tar.bz2
adding permission collection
-rw-r--r--src/Psecio/Gatekeeper/PermissionCollection.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Psecio/Gatekeeper/PermissionCollection.php b/src/Psecio/Gatekeeper/PermissionCollection.php
new file mode 100644
index 0000000..414e670
--- /dev/null
+++ b/src/Psecio/Gatekeeper/PermissionCollection.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Psecio\Gatekeeper;
+
+class PermissionCollection extends \Psecio\Gatekeeper\Collection\Mysql
+{
+ public function findByUserId($userId)
+ {
+ $data = array('userId' => $userId);
+ $sql = 'select p.* from permissions p, user_permission up'
+ .' where p.id = up.permission_id'
+ .' and up.userId = :userId';
+
+ $results = $this->fetch($sql, $data);
+
+ foreach ($results as $result) {
+ $perm = new PermissionModel($this->getDb(), $result);
+ $this->add($perm);
+ }
+ }
+} \ No newline at end of file