From 49af2b3bb1837de98f3c728cca356ada86143fee Mon Sep 17 00:00:00 2001 From: dingguodong Date: Thu, 24 Jun 2021 13:15:55 +0800 Subject: [PATCH] + Add func to find the issue by object type and id. --- module/gitlab/model.php | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 5fb82be978..00716526d5 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -56,7 +56,7 @@ class gitlabModel extends model */ public function getUserIdAccountPairs($gitlab) { - return $this->dao->select('openID,account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andwhere('providerID')->eq($gitlab)->fetchPairs(); + return $this->dao->select('openID,account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlab)->fetchPairs(); } /** @@ -68,7 +68,7 @@ class gitlabModel extends model */ public function getUserAccountIdPairs($gitlab) { - return $this->dao->select('account,openID')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andwhere('providerID')->eq($gitlab)->fetchPairs(); + return $this->dao->select('account,openID')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlab)->fetchPairs(); } /** @@ -772,11 +772,27 @@ class gitlabModel extends model */ public function getAccount($gitlabID, $userID) { - return $this->dao->select('account') - ->from(TABLE_OAUTH) - ->where('providerType')->eq('gitlab') - ->andwhere('providerID')->eq($gitlabID) - ->andwhere('openID')->eq($userID) - ->fetch('account'); + return $this->dao->select('account')->from(TABLE_OAUTH) + ->where('providerType')->eq('gitlab') + ->andWhere('providerID')->eq($gitlabID) + ->andWhere('openID')->eq($userID) + ->fetch('account'); + } + + /** + * Get gitlab issue from relation by object type and id. + * + * @param string $objectType + * @param int $objectID + * @access public + * @return object + */ + public function getGitlabIssueFromRelation($objectType,$objectID) + { + return $this->dao->select('extra as gitlabID,BVersion as projectID,BID as issueID,AType,AID')->from(TABLE_RELATION) + ->where('relation')->eq('gitlab') + ->andWhere('AType')->eq($objectType) + ->andWhere('AID')->eq($objectID) + ->fetch(); } }