* Adjust code.

This commit is contained in:
leiyong
2021-03-08 09:15:42 +08:00
parent 951c76cd85
commit 2cedf63ee2
2 changed files with 14 additions and 29 deletions
+13 -28
View File
@@ -1032,24 +1032,13 @@ class actionModel extends model
if($action->objectType == 'product')
{
$product = $this->dao->select('id,name,code,acl')->from(TABLE_PRODUCT)->where('id')->eq($action->objectID)->fetch();
$count = $this->dao->select('COUNT(*) AS count')->from(TABLE_PRODUCT)->where('deleted')->eq('0')->andWhere("(`name`='{$product->name}'" . ($product->code ? " OR `code`='{$product->code}'" : '') . ")")->fetch('count');
if($count > 0)
{
echo js::alert(sprintf($this->lang->action->needEdit, $this->lang->action->objectTypes['product']));
die(js::locate(helper::createLink('product', 'edit', "productID=$action->objectID&action=undelete&extra=$actionID"), 'parent'));
}
if($product->acl != 'open') $this->loadModel('user')->updateUserView($product->id, 'product');
}
elseif($action->objectType == 'project')
elseif(in_array($action->objectType, array('program', 'project', 'execution')))
{
$project = $this->dao->select('id,name,code,acl')->from(TABLE_PROJECT)->where('id')->eq($action->objectID)->fetch();
$count = $this->dao->select('COUNT(*) AS count')->from(TABLE_PROJECT)->where('deleted')->eq('0')->andWhere("(`name`='{$project->name}'" . ($project->code ? " OR `code`='{$project->code}'" : '') . ")")->fetch('count');
if($count > 0)
{
echo js::alert(sprintf($this->lang->action->needEdit, $this->lang->action->objectTypes['project']));
die(js::locate(helper::createLink('project', 'edit', "projectID=$action->objectID&action=undelete&extra=$actionID"), 'parent'));
}
if($project->acl != 'open') $this->loadModel('user')->updateUserView($project->id, 'project');
$project = $this->dao->select('id,acl')->from(TABLE_PROJECT)->where('id')->eq($action->objectID)->fetch();
$objecttype = $action->objectType == 'execution' ? 'sprint' : $action->objectType;
if($project->acl != 'open') $this->loadModel('user')->updateUserView($project->id, $objecttype);
}
elseif($action->objectType == 'module')
{
@@ -1069,8 +1058,15 @@ class actionModel extends model
if(!empty($products)) $this->loadModel('user')->updateUserView(array_keys($products), 'product');
}
/* Revert userView products when undelete execution. */
if($action->objectType == 'execution')
{
$products = $this->loadModel('execution')->getProducts($project->id, $withBranch = false);
if(!empty($products)) $this->loadModel('user')->updateUserView(array_keys($products), 'product');
}
/* Revert doclib when undelete product or project. */
if($action->objectType == 'project' or $action->objectType == 'product')
if($action->objectType == 'execution' or $action->objectType == 'product')
{
$this->dao->update(TABLE_DOCLIB)->set('deleted')->eq(0)->where($action->objectType)->eq($action->objectID)->exec();
}
@@ -1086,18 +1082,6 @@ class actionModel extends model
$this->create($action->objectType, $action->objectID, 'undeleted');
}
public function updateUserView($objectType = '')
{
$project = $this->dao->select('id,name,code,acl')->from(TABLE_PROJECT)->where('id')->eq($action->objectID)->fetch();
$count = $this->dao->select('COUNT(*) AS count')->from(TABLE_PROJECT)->where('deleted')->eq('0')->andWhere("(`name`='{$project->name}'" . ($project->code ? " OR `code`='{$project->code}'" : '') . ")")->fetch('count');
if($count > 0 && $objectType == 'execution')
{
echo js::alert(sprintf($this->lang->action->needEdit, $this->lang->action->objectTypes['project']));
die(js::locate(helper::createLink('project', 'edit', "projectID=$action->objectID&action=undelete&extra=$actionID"), 'parent'));
}
if($project->acl != 'open') $this->loadModel('user')->updateUserView($project->id, 'project');
}
/**
* Hide an object.
*
@@ -1204,6 +1188,7 @@ class actionModel extends model
public function hasPreOrNext($date, $direction = 'next')
{
$condition = $this->session->actionQueryCondition;
/* Remove date condition for direction. */
$condition = preg_replace("/AND +date[\<\>]'\d{4}\-\d{2}\-\d{2}'/", '', $condition);
$count = $this->dao->select('count(*) as count')->from(TABLE_ACTION)->where($condition)
+1 -1
View File
@@ -1625,7 +1625,7 @@ class executionModel extends model
$query = $this->dao->select('t2.id, t2.name, t2.type, t1.branch, t1.plan')->from(TABLE_PROJECTPRODUCT)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')
->on('t1.product = t2.id')
->where('t1.execution')->eq((int)$executionID)
->where('t1.project')->eq((int)$executionID)
->andWhere('t2.deleted')->eq(0);
if(!$withBranch) return $query->fetchPairs('id', 'name');
return $query->fetchAll('id');