From a9809c35aab70b089b323317c1a97b4a2920cbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Wed, 13 Apr 2022 10:01:36 +0800 Subject: [PATCH] * code for bug #20823. --- module/block/control.php | 17 +++++++++++------ module/block/model.php | 8 +++++++- module/story/model.php | 9 +++++---- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/module/block/control.php b/module/block/control.php index 849daf1d1d..5b7c6c93f0 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -1731,12 +1731,17 @@ class block extends control $table = $this->config->objectTables[$objectType]; $orderBy = $objectType == 'todo' ? "`date` desc" : 'id_desc'; $limitCount = isset($params->{$objectCount}) ? $params->{$objectCount} : 0; - $objects = $this->dao->select('*')->from($table) - ->where('deleted')->eq(0) - ->andWhere('assignedTo')->eq($this->app->user->account)->fi() - ->beginIF($objectType == 'story')->andWhere('type')->eq('story')->fi() - ->beginIF($objectType == 'todo')->andWhere('cycle')->eq(0)->andWhere('status')->eq('wait')->andWhere('vision')->eq($this->config->vision)->fi() - ->beginIF($objectType != 'todo')->andWhere('status')->ne('closed')->fi() + $objects = $this->dao->select('t1.*')->from($table)->alias('t1') + ->beginIF($objectType == 'story')->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id')->fi() + ->beginIF($objectType == 'bug')->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id')->fi() + ->beginIF($objectType == 'task')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution=t2.id')->fi() + ->where('t1.deleted')->eq(0) + ->andWhere('t1.assignedTo')->eq($this->app->user->account)->fi() + ->beginIF($objectType == 'story')->andWhere('t1.type')->eq('story')->andWhere('t2.deleted')->eq('0')->fi() + ->beginIF($objectType == 'bug')->andWhere('t2.deleted')->eq('0')->fi() + ->beginIF($objectType == 'story')->andWhere('t2.deleted')->eq('0')->fi() + ->beginIF($objectType == 'todo')->andWhere('t1.cycle')->eq(0)->andWhere('t1.status')->eq('wait')->andWhere('t1.vision')->eq($this->config->vision)->fi() + ->beginIF($objectType != 'todo')->andWhere('t1.status')->ne('closed')->fi() ->orderBy($orderBy) ->beginIF($limitCount)->limit($limitCount)->fi() ->fetchAll(); diff --git a/module/block/model.php b/module/block/model.php index 5b28ed6771..25b7e2fc0b 100644 --- a/module/block/model.php +++ b/module/block/model.php @@ -186,7 +186,13 @@ class blockModel extends model ->where('assignedTo')->eq($this->app->user->account) ->andWhere('deleted')->eq(0) ->fetch('count'); - $data['stories'] = (int)$this->dao->select('count(*) AS count')->from(TABLE_STORY)->where('assignedTo')->eq($this->app->user->account)->andWhere('deleted')->eq(0)->andWhere('type')->eq('story')->fetch('count'); + $data['stories'] = (int)$this->dao->select('count(*) AS count')->from(TABLE_STORY)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->where('t1.assignedTo')->eq($this->app->user->account) + ->andWhere('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('t1.type')->eq('story') + ->fetch('count'); $data['executions'] = (int)$this->dao->select('count(*) AS count')->from(TABLE_EXECUTION) ->where('status')->notIN('done,closed') ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi() diff --git a/module/story/model.php b/module/story/model.php index 7654e4951f..e4245ea04c 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -3007,15 +3007,16 @@ class storyModel extends model if($type == 'reviewBy') $sql = $sql->leftJoin(TABLE_STORYREVIEW)->alias('t3')->on('t1.id = t3.story and t1.version = t3.version'); $stories = $sql->where('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq('0') ->andWhere('t1.type')->eq($storyType) ->andWhere('t1.vision')->eq($this->config->vision) ->beginIF($type != 'closedBy' and $this->app->moduleName == 'block')->andWhere('t1.status')->ne('closed')->fi() ->beginIF($type != 'all') - ->beginIF($type == 'assignedTo')->andWhere('assignedTo')->eq($account)->fi() + ->beginIF($type == 'assignedTo')->andWhere('t1.assignedTo')->eq($account)->fi() ->beginIF($type == 'reviewBy')->andWhere('t3.reviewer')->eq($account)->andWhere('t3.result')->eq('')->andWhere('t1.status')->in('draft,changed')->fi() - ->beginIF($type == 'openedBy')->andWhere('openedBy')->eq($account)->fi() - ->beginIF($type == 'reviewedBy')->andWhere("CONCAT(',', reviewedBy, ',')")->like("%,$account,%")->fi() - ->beginIF($type == 'closedBy')->andWhere('closedBy')->eq($account)->fi() + ->beginIF($type == 'openedBy')->andWhere('t1.openedBy')->eq($account)->fi() + ->beginIF($type == 'reviewedBy')->andWhere("CONCAT(',', t1.reviewedBy, ',')")->like("%,$account,%")->fi() + ->beginIF($type == 'closedBy')->andWhere('t1.closedBy')->eq($account)->fi() ->fi() ->beginIF($includeLibStories == false and $this->config->edition == 'max')->andWhere('t1.lib')->eq('0')->fi() ->orderBy($orderBy)