diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Api/GroupMember.php | 5 | ||||
-rw-r--r-- | app/Model/GroupMember.php | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/app/Api/GroupMember.php b/app/Api/GroupMember.php index de62f0c6..9d2a4796 100644 --- a/app/Api/GroupMember.php +++ b/app/Api/GroupMember.php @@ -10,6 +10,11 @@ namespace Kanboard\Api; */ class GroupMember extends \Kanboard\Core\Base { + public function getMemberGroups($user_id) + { + return $this->groupMember->getGroups($user_id); + } + public function getGroupMembers($group_id) { return $this->groupMember->getMembers($group_id); 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(); + } } |