* Finish task #83205, and fix bug of task #83206.

This commit is contained in:
hufangzhou
2023-01-31 10:35:06 +08:00
parent 92bc334cdc
commit 73df98376a
4 changed files with 25 additions and 9 deletions
+1 -2
View File
@@ -170,14 +170,13 @@ class blockModel extends model
->leftJoin(TABLE_PROJECT)->alias('t2')->on("t1.project = t2.id")
->leftJoin(TABLE_EXECUTION)->alias('t3')->on("t1.execution = t3.id")
->leftJoin(TABLE_TASKTEAM)->alias('t4')->on("t4.task = t1.id and t4.account = '{$this->app->user->account}'")
->where("(t1.assignedTo = '{$this->app->user->account}' or (t1.mode = 'multi' and t4.`account` = '{$this->app->user->account}') )")
->where("(t1.assignedTo = '{$this->app->user->account}' or (t1.mode = 'multi' and t4.`account` = '{$this->app->user->account}' and t1.status != 'closed' and t4.status != 'done') )")
->andWhere('(t2.status')->ne('suspended')
->orWhere('t3.status')->ne('suspended')
->markRight(1)
->andWhere('t1.deleted')->eq('0')
->andWhere('t3.deleted')->eq('0')
->andWhere('t1.status')->notin('closed,cancel,pause')
->andWhere("(t1.assignedTo = '{$this->app->user->account}' or (t1.mode = 'multi' and t4.`account` = '{$this->app->user->account}' and t1.status != 'closed' and t4.status != 'done') )")
->beginIF(!$this->app->user->admin)->andWhere('t1.execution')->in($this->app->user->view->sprints)->fi()
->beginIF($this->config->vision)->andWhere('t1.vision')->eq($this->config->vision)->fi()
->beginIF($this->config->vision)->andWhere('t3.vision')->eq($this->config->vision)->fi()
+15 -4
View File
@@ -3774,12 +3774,23 @@ class executionModel extends model
*/
public function getSearchTasks($condition, $pager, $orderBy)
{
$taskIdList = $this->dao->select('id')
->from(TABLE_TASK)
->where($condition)
if(strpos($condition, '`assignedTo`') !== false)
{
preg_match("/`assignedTo`\s+(([^']*) ('([^']*)'))/", $condition, $matches);
$condition = preg_replace('/`(\w+)`/', 't1.`$1`', $condition);
$condition = str_replace("t1.$matches[0]", "(t1.$matches[0] or (t1.mode = 'multi' and t2.`account` $matches[1] and t1.status != 'closed' and t2.status != 'done') )", $condition);
}
$sql = $this->dao->select('t1.id')->from(TABLE_TASK)->alias('t1');
if(strpos($condition, '`assignedTo`') !== false) $sql = $sql->leftJoin(TABLE_TASKTEAM)->alias('t2')->on("t2.task = t1.id and t2.account $matches[1]");
$orderBy = array_map(function($value){return 't1.' . $value;}, explode(',', $orderBy));
$orderBy = implode(',', $orderBy);
$taskIdList = $sql->where($condition)
->andWhere('deleted')->eq(0)
->orderBy($orderBy)
->page($pager)
->page($pager, 't1.id')
->fetchAll('id');
$orderBy = str_replace('pri_', 'priOrder_', $orderBy);
+8 -2
View File
@@ -571,6 +571,12 @@ class myModel extends model
$query = preg_replace('/`(\w+)`/', 't1.`$1`', $query);
$query = str_replace('t1.`project`', 't2.`project`', $query);
if(strpos($query, '`assignedTo`') !== false)
{
preg_match("/`assignedTo`\s+(([^']*) ('([^']*)'))/", $query, $matches);
$query = str_replace("t1.$matches[0]", "(t1.$matches[0] or (t1.mode = 'multi' and t5.`account` $matches[1] and t1.status != 'closed' and t5.status != 'done') )", $query);
}
$orderBy = str_replace('pri_', 'priOrder_', $orderBy);
$tasks = $this->dao->select("t1.*, t4.id as project, t2.id as executionID, t2.name as executionName, t2.multiple as executionMultiple, t4.name as projectName, t2.type as executionType, t3.id as storyID, t3.title as storyTitle, t3.status AS storyStatus, t3.version AS latestStoryVersion, IF(t1.`pri` = 0, {$this->config->maxPriValue}, t1.`pri`) as priOrder")
->from(TABLE_TASK)->alias('t1')
@@ -582,7 +588,7 @@ class myModel extends model
->andWhere('t1.deleted')->eq(0)
->andWhere('t2.deleted')->eq(0)
->andWhere('(t2.status')->ne('suspended')->orWhere('t4.status')->ne('suspended')->markRight(1)
->beginIF($moduleName == 'workTask')->andWhere("t1.assignedTo")->eq($account)
->beginIF($moduleName == 'workTask')->andWhere("(t1.$matches[0] or (t1.mode = 'multi' and t5.`account` $matches[1] and t1.status != 'closed' and t5.status != 'done') )")->fi()
->beginIF($moduleName == 'contributeTask')
->andWhere('t1.openedBy', 1)->eq($account)
->orWhere('t1.closedBy')->eq($account)
@@ -597,7 +603,7 @@ class myModel extends model
->beginIF(!$this->app->user->admin)->andWhere('t1.execution')->in($this->app->user->view->sprints)->fi()
->orderBy($orderBy)
->beginIF($limit > 0)->limit($limit)->fi()
->page($pager)
->page($pager, 't1.id')
->fetchAll('id');
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'task', false);
+1 -1
View File
@@ -2640,7 +2640,7 @@ class taskModel extends model
->fi()
->beginIF($type == 'assignedTo' and ($this->app->rawModule == 'my' or $this->app->rawModule == 'block'))->andWhere('t2.status', true)->ne('suspended')->orWhere('t4.status')->ne('suspended')->markRight(1)->fi()
->beginIF($type != 'all' and $type != 'finishedBy' and $type != 'assignedTo')->andWhere("t1.`$type`")->eq($account)->fi()
->beginIF($type == 'assignedTo')->andWhere("(t1.assignedTo = '{$account}' or (t1.mode = 'multi' and t5.`account` = '{$account}' and t1.status != 'closed' and t4.status != 'done') )")->fi()
->beginIF($type == 'assignedTo')->andWhere("(t1.assignedTo = '{$account}' or (t1.mode = 'multi' and t5.`account` = '{$account}' and t1.status != 'closed' and t5.status != 'done') )")->fi()
->beginIF($type == 'assignedTo' and $this->app->rawModule == 'my' and $this->app->rawMethod == 'work')->andWhere('t1.status')->notin('closed,cancel,pause')->fi()
->orderBy($orderBy)
->beginIF($limit > 0)->limit($limit)->fi()