diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-04-21 21:10:04 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-04-21 21:10:04 -0400 |
commit | 60e0753b90838120510861ebc674f826140b31de (patch) | |
tree | f85b81e439adad8b3011c3127442c822740b02d0 /app/Model/GroupMember.php | |
parent | b0e41bc81b40cfdc5e067bf1eb4d05e3aa438c7d (diff) |
Added API procedure "getMemberGroups"
Diffstat (limited to 'app/Model/GroupMember.php')
-rw-r--r-- | app/Model/GroupMember.php | 17 |
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(); + } } |