+ Delete project relation when user deleting a repo.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user