+ Delete project relation when user deleting a repo.

This commit is contained in:
dingguodong
2021-07-13 11:06:13 +08:00
parent 9ae5f3e8fe
commit 1d0f19caaa
2 changed files with 34 additions and 0 deletions
+31
View File
@@ -863,6 +863,37 @@ class gitlabModel extends model
return true;
}
/**
* Delete project relation.
*
* condition: when user deleting a repo.
*
* @param int $repoID
* @access public
* @return void
*/
public function deleteProjectRelation($repoID)
{
$repo = $this->dao->select('product,path as gitlabProjectID,client as gitlabID')->from(TABLE_REPO)
->where('id')->eq($repoID)
->andWhere('deleted')->eq(0)
->fetch();
if(empty($repo)) return false;
$productIDList = explode(',', $repo->product);
foreach($productIDList as $product)
{
$this->dao->delete()->from(TABLE_RELATION)
->where('product')->eq($product)
->andWhere('AType')->eq('gitlab')
->andWhere('BType')->eq('gitlabProject')
->andWhere('relation')->eq('interrated')
->andWhere('AID')->eq($repo->gitlabID)
->andWhere('BID')->eq($repo->gitlabProjectID)
->exec();
}
}
/**
* Create webhook for zentao.
*
+3
View File
@@ -209,6 +209,9 @@ class repo extends control
die(js::confirm($this->lang->repo->notice->delete, $this->repo->createLink('delete', "repoID=$repoID&objectID=$objectID&confirm=yes")));
}
/* Delete project relation for gitlab type. */
$this->loadModel('gitlab')->deleteProjectRelation($repoID);
$relationID = $this->dao->select('id')->from(TABLE_RELATION)->where('extra')->eq($repoID)->fetch();
if($relationID)
{