summaryrefslogtreecommitdiff
path: root/app/Model/GroupMember.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-04-21 21:10:04 -0400
committerFrederic Guillot <fred@kanboard.net>2016-04-21 21:10:04 -0400
commit60e0753b90838120510861ebc674f826140b31de (patch)
treef85b81e439adad8b3011c3127442c822740b02d0 /app/Model/GroupMember.php
parentb0e41bc81b40cfdc5e067bf1eb4d05e3aa438c7d (diff)
Added API procedure "getMemberGroups"
Diffstat (limited to 'app/Model/GroupMember.php')
-rw-r--r--app/Model/GroupMember.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/Model/GroupMember.php b/app/Model/GroupMember.php
index 7ed5f733..14041704 100644
--- a/app/Model/GroupMember.php
+++ b/app/Model/GroupMember.php
@@ -108,4 +108,21 @@ class GroupMember extends Base
->eq('user_id', $user_id)
->exists();
}
+
+ /**
+ * Get all groups for a given user
+ *
+ * @access public
+ * @param integer $user_id
+ * @return array
+ */
+ public function getGroups($user_id)
+ {
+ return $this->db->table(self::TABLE)
+ ->columns(Group::TABLE.'.id', Group::TABLE.'.name')
+ ->join(Group::TABLE, 'id', 'group_id')
+ ->eq(self::TABLE.'.user_id', $user_id)
+ ->asc(Group::TABLE.'.name')
+ ->findAll();
+ }
}