From 7f9d638d2867e9da6eb2b82de051d47bff482ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E9=87=91=E5=8B=87?= Date: Wed, 5 Apr 2023 14:18:24 +0000 Subject: [PATCH] * Fix sql for dmdb. --- lib/dbh/dbh.class.php | 3 ++- module/action/model.php | 17 ++++++++++------- module/admin/model.php | 2 +- module/block/control.php | 27 ++++++++++++++++----------- module/bug/control.php | 2 +- module/common/model.php | 4 ++-- module/cron/model.php | 2 +- module/doc/model.php | 6 +++--- module/execution/model.php | 8 ++++---- module/holiday/model.php | 2 +- module/install/model.php | 2 +- module/product/control.php | 2 +- module/product/model.php | 6 +++--- module/productplan/model.php | 2 +- module/program/model.php | 7 ++++--- module/project/model.php | 10 +++++----- module/search/model.php | 2 +- module/testcase/control.php | 2 +- module/testtask/model.php | 19 +++++++++++++++++-- module/user/model.php | 2 +- 20 files changed, 76 insertions(+), 51 deletions(-) diff --git a/lib/dbh/dbh.class.php b/lib/dbh/dbh.class.php index 4449597503..28e91aca97 100644 --- a/lib/dbh/dbh.class.php +++ b/lib/dbh/dbh.class.php @@ -45,7 +45,8 @@ class dbh */ public function __construct($config, $setSchema = true) { - $dsn = "{$config->driver}:host={$config->host}:{$config->port};dbname={$config->name}"; + $dsn = "{$config->driver}:host={$config->host}:{$config->port}"; + if($setSchema) $dsn .= ";dbname={$config->name}"; $pdo = new PDO($dsn, $config->user, $config->password); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); diff --git a/module/action/model.php b/module/action/model.php index 6a346ac118..030404f784 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -939,7 +939,7 @@ class actionModel extends model else { if($actionType == 'restoredsnapshot' && in_array($action->objectType, array('vm', 'zanode')) && $value == 'defaultSnap') $value = $this->lang->$objectType->snapshot->defaultSnapName; - + $desc = str_replace('$' . $key, $value, $desc); } } @@ -1033,7 +1033,7 @@ class actionModel extends model extract($beginAndEnd); /* Build has priv condition. */ - $condition = 1; + $condition = '1=1'; $executions = array(); if(!$this->app->user->admin) { @@ -1108,6 +1108,12 @@ class actionModel extends model $noMultipleExecutions = $this->dao->select('id')->from(TABLE_PROJECT)->where('multiple')->eq(0)->andWhere('type')->in('sprint,kanban')->fetchPairs('id', 'id'); + $condition = "(`objectType` IN ('doc', 'doclib') OR ($condition)) AND `objectType` NOT IN ('program', 'effort', 'execution')"; + if($noMultipleExecutions) $condition .= " OR (`objectID` NOT " . helper::dbIN($noMultipleExecutions) . " AND `objectType` = 'execution')"; + $condition .= " OR (`objectID` in ($programCondition) AND `objectType` = 'program')"; + $condition .= " OR (`objectID` in ($efforts) AND `objectType` = 'effort')"; + $condition = "($condition)"; + /* Get actions. */ $actions = $this->dao->select('*')->from(TABLE_ACTION) ->where('objectType')->notIN($this->config->action->ignoreObjectType4Dynamic) @@ -1120,7 +1126,7 @@ class actionModel extends model ->beginIF(is_numeric($productID))->andWhere('product')->like("%,$productID,%")->fi() ->andWhere() ->markLeft(1) - ->where(1) + ->where('1=1') ->beginIF(is_numeric($projectID))->andWhere('project')->eq($projectID)->fi() ->beginIF(!empty($executions))->andWhere('execution')->in(array_keys($executions))->fi() ->beginIF(is_numeric($executionID))->andWhere('execution')->eq($executionID)->fi() @@ -1131,13 +1137,10 @@ class actionModel extends model ->beginIF($productID == 'notzero')->andWhere('product')->gt(0)->andWhere('product')->notlike('%,0,%')->fi() ->beginIF($projectID == 'notzero')->andWhere('project')->gt(0)->fi() ->beginIF($executionID == 'notzero')->andWhere('execution')->gt(0)->fi() - ->beginIF($productID == 'all' or $projectID == 'all' or $executionID == 'all')->andWhere("IF((objectType!= 'doc' && objectType!= 'doclib'), ($condition), '1=1')")->fi() - ->beginIF($noMultipleExecutions)->andWhere("IF(`objectType` = 'execution', `objectID` NOT " . helper::dbIN($noMultipleExecutions) . ", '1=1')")->fi() + ->andWhere($condition) ->beginIF($actionCondition)->andWhere("($actionCondition)")->fi() /* Filter out client login/logout actions. */ ->andWhere('action')->notin('disconnectxuanxuan,reconnectxuanxuan,loginxuanxuan,logoutxuanxuan,editmr,removemr') - ->andWhere("IF((objectType = 'program'), (objectID in ($programCondition)), '1=1')") - ->andWhere("IF((objectType = 'effort'), (objectID in ($efforts)), '1=1')") ->orderBy($orderBy) ->page($pager) ->fetchAll(); diff --git a/module/admin/model.php b/module/admin/model.php index faa37c44d4..d7d1caae04 100755 --- a/module/admin/model.php +++ b/module/admin/model.php @@ -646,7 +646,7 @@ class adminModel extends model public function genDateUsed() { $firstUseDate = $this->dao->select('date')->from(TABLE_ACTION) - ->where('date')->gt('0000-00-00') + ->where('date')->gt('1970-01-01') ->andWhere('actor')->eq($this->app->user->account) ->orderBy('date_asc') ->limit('1') diff --git a/module/block/control.php b/module/block/control.php index 3a56edbc6f..229c6fefc8 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -748,7 +748,7 @@ class block extends control if(preg_match('/[^a-zA-Z0-9_]/', $this->params->type)) return; $this->view->projects = $this->loadModel('project')->getPairsByProgram(); - $this->view->testtasks = $this->dao->select('distinct t1.*,t2.name as productName,t2.shadow,t3.name as buildName,t4.name as projectName')->from(TABLE_TESTTASK)->alias('t1') + $this->view->testtasks = $this->dao->select('t1.id,t2.name as productName,t2.shadow,t3.name as buildName,t4.name as projectName')->from(TABLE_TESTTASK)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') ->leftJoin(TABLE_BUILD)->alias('t3')->on('t1.build=t3.id') ->leftJoin(TABLE_PROJECT)->alias('t4')->on('t1.execution=t4.id') @@ -1637,12 +1637,12 @@ class block extends control $yesterday = date(DT_DATE1, strtotime('yesterday')); $testtasks = $this->dao->select('*')->from(TABLE_TESTTASK)->where('product')->in($productIdList)->andWhere('project')->ne(0)->andWhere('deleted')->eq(0)->orderBy('id')->fetchAll('product'); $bugs = $this->dao->select("product, count(id) as total, - count(assignedTo = '{$this->app->user->account}' or null) as assignedToMe, - count(status != 'closed' or null) as unclosed, - count((status != 'closed' and status != 'resolved') or null) as unresolved, - count((confirmed = '0' and toStory = '0') or null) as unconfirmed, - count((resolvedDate >= '$yesterday' and resolvedDate < '$today') or null) as yesterdayResolved, - count((closedDate >= '$yesterday' and closedDate < '$today') or null) as yesterdayClosed") + count(IF(assignedTo = '{$this->app->user->account}', 1, null)) as assignedToMe, + count(IF(status != 'closed', 1, null)) as unclosed, + count(IF(status != 'closed' and status != 'resolved', 1, null)) as unresolved, + count(IF(confirmed = '0' and toStory = '0', 1, null)) as unconfirmed, + count(IF(resolvedDate >= '$yesterday' and resolvedDate < '$today', 1, null)) as yesterdayResolved, + count(IF(closedDate >= '$yesterday' and closedDate < '$today', 1, null)) as yesterdayClosed") ->from(TABLE_BUG) ->where('product')->in($productIdList) ->andWhere('execution')->in(array_keys($executions)) @@ -1650,13 +1650,18 @@ class block extends control ->groupBy('product') ->fetchAll('product'); - $confirmedBugs = $this->dao->select('count(product) as product')->from(TABLE_ACTION) + $confirmedBugs = $this->dao->select('product')->from(TABLE_ACTION) ->where('objectType')->eq('bug') ->andWhere('action')->eq('bugconfirmed') ->andWhere('date')->ge($yesterday) ->andWhere('date')->lt($today) - ->groupBy('product') - ->fetchPairs('product', 'product'); + ->fetchAll(); + $productConfirmedBugs = array(); + foreach($confirmedBugs as $bug) + { + if(!isset($productConfirmedBugs[$bug->product])) $productConfirmedBugs[$bug->product] = 0; + $productConfirmedBugs[$bug->product]++; + } foreach($products as $productID => $product) { @@ -1668,7 +1673,7 @@ class block extends control $product->unconfirmed = empty($bug) ? 0 : $bug->unconfirmed; $product->yesterdayResolved = empty($bug) ? 0 : $bug->yesterdayResolved; $product->yesterdayClosed = empty($bug) ? 0 : $bug->yesterdayClosed; - $product->yesterdayConfirmed = empty($confirmedBugs[",$productID,"]) ? 0 : $confirmedBugs[",$productID,"]; + $product->yesterdayConfirmed = empty($productConfirmedBugs[",$productID,"]) ? 0 : $productConfirmedBugs[",$productID,"]; $product->assignedRate = $product->total ? round($product->assignedToMe / $product->total * 100, 2) : 0; $product->unresolvedRate = $product->total ? round($product->unresolved / $product->total * 100, 2) : 0; diff --git a/module/bug/control.php b/module/bug/control.php index 00574f77cf..14253a79fb 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -174,7 +174,7 @@ class bug extends control $bugs = $this->bug->getBugs($productIDList, $executions, $branch, $browseType, $moduleID, $queryID, $sort, $pager, $this->projectID); /* Process the sql, get the conditon partion, save it to session. */ - $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug', $browseType == 'needconfirm' ? false : true); + $this->loadModel('common')->saveQueryCondition($this->bug->dao->get(), 'bug', $browseType == 'needconfirm' ? false : true); /* Process bug for check story changed. */ $bugs = $this->loadModel('story')->checkNeedConfirm($bugs); diff --git a/module/common/model.php b/module/common/model.php index ed45177d33..4a31b35961 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1783,7 +1783,7 @@ EOD; global $lang, $app; - $object = $app->dbh->query('SELECT project,type FROM ' . TABLE_EXECUTION . " WHERE `id` = '$executionID'")->fetch(); + $object = $app->dbh->query('SELECT project,`type` FROM ' . TABLE_EXECUTION . " WHERE `id` = '$executionID'")->fetch(); if(empty($object)) return; $executionPairs = array(); @@ -2365,7 +2365,7 @@ EOD; */ public function checkField($table, $field) { - $fields = $this->dao->query("DESC $table")->fetchAll(); + $fields = $this->dao->descTable($table); $hasField = false; foreach($fields as $fieldObj) { diff --git a/module/cron/model.php b/module/cron/model.php index c14dc2e83d..6817305143 100644 --- a/module/cron/model.php +++ b/module/cron/model.php @@ -138,7 +138,7 @@ class cronModel extends model public function getLastTime() { $cron = $this->dao->select('*')->from(TABLE_CRON)->orderBy('lastTime desc')->limit(1)->fetch(); - return isset($cron->lastTime) ? $cron->lastTime : $cron->lasttime; + return isset($cron->lastTime) ? $cron->lastTime : '0000-00-00 00:00:00'; } /** diff --git a/module/doc/model.php b/module/doc/model.php index c0e038bf34..c4eea8d176 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2000,9 +2000,9 @@ class docModel extends model $today = date('Y-m-d'); $lately = date('Y-m-d', strtotime('-3 day')); - $statisticInfo = $this->dao->select("count(id) as totalDocs, count(editedDate like '{$today}%' or null) as todayEditedDocs, - count(editedDate > '{$lately}' or null) as lastEditedDocs, count(addedDate > '{$lately}' or null) as lastAddedDocs, - count(collector like '%,{$this->app->user->account},%' or null) as myCollection, count(addedBy = '{$this->app->user->account}' or null) as myDocs")->from(TABLE_DOC) + $statisticInfo = $this->dao->select("count(id) as totalDocs, count(IF(editedDate like '{$today}%', 1, null)) as todayEditedDocs, + count(IF(editedDate > '{$lately}', 1, null)) as lastEditedDocs, count(IF(addedDate > '{$lately}', 1, null)) as lastAddedDocs, + count(IF(collector like '%,{$this->app->user->account},%', 1, null)) as myCollection, count(IF(addedBy = '{$this->app->user->account}', 1, null)) as myDocs")->from(TABLE_DOC) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->andWhere('id')->in($docIdList) diff --git a/module/execution/model.php b/module/execution/model.php index df16b218f8..9dbfef9d6b 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1590,13 +1590,13 @@ class executionModel extends model /* Waterfall execution, when all phases are closed, in reverse order of date. */ if(in_array($executionModel, array('waterfall', 'waterfallplus'))) { - $summary = $this->dao->select('count(id) as executions, sum(IF(INSTR("closed", status) < 1, 0, 1)) as closedExecutions')->from(TABLE_EXECUTION)->where('project')->eq($projectID)->andWhere('deleted')->eq('0')->fetch(); + $summary = $this->dao->select("count(id) as executions, sum(IF(INSTR('closed', status) < 1, 0, 1)) as closedExecutions")->from(TABLE_EXECUTION)->where('project')->eq($projectID)->andWhere('deleted')->eq('0')->fetch(); if($summary->executions == $summary->closedExecutions) $orderBy = 'sortStatus_asc,begin_desc,id_asc'; } } /* Order by status's content whether or not done */ - $executions = $this->dao->select('*, IF(INSTR("done,closed", status) < 2, 0, 1) AS isDone, INSTR("doing,wait,suspended,closed", status) AS sortStatus')->from(TABLE_EXECUTION) + $executions = $this->dao->select("*, IF(INSTR('done,closed', status) < 2, 0, 1) AS isDone, INSTR('doing,wait,suspended,closed', status) AS sortStatus")->from(TABLE_EXECUTION) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->beginIF(!$this->session->multiple and $this->app->tab == 'execution')->andWhere('multiple')->eq('1')->fi() @@ -1727,7 +1727,7 @@ class executionModel extends model } else { - return $this->dao->select('*, IF(INSTR(" done,closed", status) < 2, 0, 1) AS isDone')->from(TABLE_EXECUTION) + return $this->dao->select("*, IF(INSTR(' done,closed', status) < 2, 0, 1) AS isDone")->from(TABLE_EXECUTION) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->beginIF($type == 'all')->andWhere('type')->in('sprint,stage,kanban')->fi() @@ -1777,7 +1777,7 @@ class executionModel extends model } else { - return $this->dao->select('t1.*, IF(INSTR(" done,closed", t1.status) < 2, 0, 1) AS isDone')->from(TABLE_EXECUTION)->alias('t1') + return $this->dao->select("t1.*, IF(INSTR(' done,closed', t1.status) < 2, 0, 1) AS isDone")->from(TABLE_EXECUTION)->alias('t1') ->leftJoin(TABLE_TEAM)->alias('t2')->on('t2.root=t1.id') ->where('t1.deleted')->eq(0) ->beginIF(!$this->app->user->admin)->andWhere('t1.id')->in($this->app->user->view->sprints)->fi() diff --git a/module/holiday/model.php b/module/holiday/model.php index 4206dad132..f6d4f7096f 100644 --- a/module/holiday/model.php +++ b/module/holiday/model.php @@ -34,7 +34,7 @@ class holidayModel extends model public function getList($year = '', $type = 'all') { return $this->dao->select('*')->from(TABLE_HOLIDAY) - ->where('1') + ->where('1=1') ->beginIf(!empty($year)) ->andWhere('year', true)->eq($year) ->orWhere('begin')->like("$year-%") diff --git a/module/install/model.php b/module/install/model.php index 0660545460..f23e82b155 100644 --- a/module/install/model.php +++ b/module/install/model.php @@ -480,7 +480,7 @@ class installModel extends model $admin->password = md5($this->post->password); $admin->gender = 'f'; $admin->visions = 'rnd,lite'; - $this->dao->insert(TABLE_USER)->data($admin)->exec(); + $this->dao->replace(TABLE_USER)->data($admin)->exec(); } } diff --git a/module/product/control.php b/module/product/control.php index ad41bc1d3e..a164cd6db6 100755 --- a/module/product/control.php +++ b/module/product/control.php @@ -267,7 +267,7 @@ class product extends control { $stories = $this->product->getStories($productID, $branchID, $browseType, $queryID, $moduleID, $storyType, $sort, $pager); } - $queryCondition = $this->dao->get(); + $queryCondition = $this->story->dao->get(); /* Display status of branch. */ $branchOption = array(); diff --git a/module/product/model.php b/module/product/model.php index 5494bb053d..d4d6ce58a9 100755 --- a/module/product/model.php +++ b/module/product/model.php @@ -363,7 +363,7 @@ class productModel extends model $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; $orderBy = !empty($this->config->product->orderBy) ? $this->config->product->orderBy : 'isClosed'; /* Order by program. */ - return $this->dao->select('t1.*, IF(INSTR(" closed", t1.status) < 2, 0, 1) AS isClosed')->from(TABLE_PRODUCT)->alias('t1') + return $this->dao->select("t1.*, IF(INSTR(' closed', t1.status) < 2, 0, 1) AS isClosed")->from(TABLE_PRODUCT)->alias('t1') ->leftJoin(TABLE_PROGRAM)->alias('t2')->on('t1.program = t2.id') ->where(1) ->beginIF(strpos($mode, 'all') === false)->andWhere('t1.deleted')->eq(0)->fi() @@ -1837,7 +1837,7 @@ class productModel extends model $linePairs = $this->getLinePairs(); foreach($products as $product) $product->lineName = zget($linePairs, $product->line, ''); - $stories = $this->dao->select('product, status, type, count(status) AS count') + $stories = $this->dao->select('product, status, count(status) AS count') ->from(TABLE_STORY) ->where('deleted')->eq(0) ->andWhere('type')->eq('story') @@ -1845,7 +1845,7 @@ class productModel extends model ->groupBy('product, status') ->fetchGroup('product', 'status'); - $requirements = $this->dao->select('product, status, type, count(status) AS count') + $requirements = $this->dao->select('product, status, count(status) AS count') ->from(TABLE_STORY) ->where('deleted')->eq(0) ->andWhere('type')->eq('requirement') diff --git a/module/productplan/model.php b/module/productplan/model.php index 54a8f40caf..7f8ca46b98 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -257,7 +257,7 @@ class productplanModel extends model { $this->app->loadLang('branch'); - $date = date('Y-m-d'); + $date = date('Y-m-d'); $branchQuery = ''; if($branch !== '' and $branch != 'all') diff --git a/module/program/model.php b/module/program/model.php index a604c600a4..a04e24cbfb 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -595,7 +595,7 @@ class programModel extends model } $query = str_replace('`id`','t1.id', $this->session->projectQuery); - $projectList = $this->dao->select('distinct t1.*')->from(TABLE_PROJECT)->alias('t1') + $projectList = $this->dao->select('t1.*')->from(TABLE_PROJECT)->alias('t1') ->leftJoin(TABLE_TEAM)->alias('t2')->on('t1.id=t2.root') ->leftJoin(TABLE_STAKEHOLDER)->alias('t3')->on('t1.id=t3.objectID') ->where('t1.deleted')->eq('0') @@ -744,6 +744,7 @@ class programModel extends model ->setDefault('status', 'wait') ->setDefault('openedBy', $this->app->user->account) ->setDefault('parent', 0) + ->setDefault('code', '') ->setDefault('openedDate', helper::now()) ->setIF($this->post->acl == 'open', 'whitelist', '') ->setIF($this->post->delta == 999, 'end', LONG_TIME) @@ -752,7 +753,7 @@ class programModel extends model ->add('type', 'program') ->join('whitelist', ',') ->stripTags($this->config->program->editor->create['id'], $this->config->allowedTags) - ->remove('delta,future,contactListMenu') + ->remove('delta,future,contactListMenu,uid') ->get(); /* Redefines the language entries for the fields in the project table. */ @@ -819,7 +820,7 @@ class programModel extends model ->setIF(!isset($_POST['whitelist']), 'whitelist', '') ->join('whitelist', ',') ->stripTags($this->config->program->editor->edit['id'], $this->config->allowedTags) - ->remove('uid,delta,future,syncPRJUnit,exchangeRate,contactListMenu') + ->remove('id,uid,delta,future,syncPRJUnit,exchangeRate,contactListMenu') ->get(); $program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->edit['id'], $this->post->uid); diff --git a/module/project/model.php b/module/project/model.php index ce5b643326..ba09082b90 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -318,7 +318,7 @@ class projectModel extends model ->andWhere('t2.deleted')->eq(0) ->groupBy('root')->fetchPairs(); - $hours = $this->dao->select('t2.parent as project, ROUND(SUM(t1.consumed), 1) AS consumed, ROUND(SUM(t1.estimate), 1) AS estimate')->from(TABLE_TASK)->alias('t1') + $hours = $this->dao->select('t2.project, ROUND(SUM(t1.consumed), 1) AS consumed, ROUND(SUM(t1.estimate), 1) AS estimate')->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id') ->where('t2.project')->in($projectIdList) ->andWhere('t2.deleted')->eq(0) @@ -404,7 +404,7 @@ class projectModel extends model ->where('t1.project')->in($projectIdList) ->andWhere('t1.deleted')->eq(0) ->andWhere('t2.deleted')->eq(0) - ->groupBy('project') + ->groupBy('t1.project') ->fetchAll('project'); } @@ -426,12 +426,12 @@ class projectModel extends model ->andWhere('t2.model')->eq('waterfall') ->fetchGroup('project', 'id'); - $totalHour = $this->dao->select('t1.project, t1.execution, ROUND(SUM(if(t1.status !="closed" && t1.status !="cancel", `left`, 0)), 2) AS totalLeft, ROUND(SUM(consumed), 1) AS totalConsumed')->from(TABLE_TASK)->alias('t1') + $totalHour = $this->dao->select("t1.project, t1.execution, ROUND(SUM(if(t1.status !='closed' && t1.status !='cancel', `left`, 0)), 2) AS totalLeft, ROUND(SUM(consumed), 1) AS totalConsumed")->from(TABLE_TASK)->alias('t1') ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.execution = t2.id') ->where('t2.project')->in(array_keys($projectList)) ->andWhere('t1.deleted')->eq(0) ->andWhere('t1.parent')->lt(1) - ->groupBy('t1.execution') + ->groupBy('t1.project,t1.execution') ->fetchGroup('project', 'execution'); $progressList = array(); @@ -1254,7 +1254,7 @@ class projectModel extends model ->add('type', 'project') ->join('whitelist', ',') ->stripTags($this->config->project->editor->create['id'], $this->config->allowedTags) - ->remove('products,branch,plans,delta,newProduct,productName,future,contactListMenu,teamMembers') + ->remove('uid,products,branch,plans,delta,newProduct,productName,future,contactListMenu,teamMembers') ->get(); if(!isset($this->config->setCode) or $this->config->setCode == 0) unset($project->code); diff --git a/module/search/model.php b/module/search/model.php index 69ac1589bb..777b61f5f7 100644 --- a/module/search/model.php +++ b/module/search/model.php @@ -1238,7 +1238,7 @@ class searchModel extends model if($testDeleted) $data = $this->dao->select('*')->from($table)->limit(1)->fetch(); $query = $this->dao->select('t1.*')->from($table)->alias('t1') - ->where('1') + ->where('1=1') ->beginIF($type == 'program')->andWhere('type')->eq('program')->fi() ->beginIF($type == 'project')->andWhere('type')->eq('project')->fi() ->beginIF($type == 'execution')->andWhere('type')->in('stage,sprint,kanban')->fi() diff --git a/module/testcase/control.php b/module/testcase/control.php index aeb2164d89..36bd7478ad 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -154,7 +154,7 @@ class testcase extends control } /* save session .*/ - $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false); + $this->loadModel('common')->saveQueryCondition($this->testcase->dao->get(), 'testcase', false); /* Process case for check story changed. */ $cases = $this->loadModel('story')->checkNeedConfirm($cases); diff --git a/module/testtask/model.php b/module/testtask/model.php index ca2d2ad3b4..45252a2272 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -76,8 +76,7 @@ class testtaskModel extends model $products = $scopeAndStatus[0] == 'all' ? $this->app->user->view->products : array(); $branch = $scopeAndStatus[0] == 'all' ? 'all' : $branch; - $executionNameField = "IF(t5.id IS NOT NULL && t5.multiple = '1', CONCAT(t5.name, ' / ', t3.name), IF(t5.id IS NOT NULL, t5.name, t3.name))"; - return $this->dao->select("t1.*, t5.multiple, IF(t2.shadow = 1, t5.name, t2.name) AS productName, $executionNameField AS executionName, t4.name AS buildName, t4.branch AS branch") + $tasks = $this->dao->select("t1.*, t5.multiple, IF(t2.shadow = 1, t5.name, t2.name) AS productName, t3.name as executionName, t4.name AS buildName, t4.branch AS branch, t5.name AS projectName") ->from(TABLE_TESTTASK)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id') ->leftJoin(TABLE_EXECUTION)->alias('t3')->on('t1.execution = t3.id') @@ -106,6 +105,22 @@ class testtaskModel extends model ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); + foreach($tasks as $taskID => $task) + { + if($task->multiple) + { + if($task->projectName and $task->executionName) + { + $tasks[$taskID]->executionName = $task->projectName . '/' . $task->executionName; + } + elseif(!$task->executionName) + { + $tasks[$taskID]->executionName = $task->projectName; + } + } + } + + return $tasks; } /** diff --git a/module/user/model.php b/module/user/model.php index 1074300160..93928f4cc5 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -100,7 +100,7 @@ class userModel extends model unset($this->config->user->moreLink); $users = $this->dao->select($fields)->from(TABLE_USER) - ->where('1') + ->where('1=1') ->beginIF(strpos($params, 'nodeleted') !== false or empty($this->config->user->showDeleted))->andWhere('deleted')->eq('0')->fi() ->beginIF(strpos($params, 'all') === false)->andWhere('type')->eq($type)->fi() ->beginIF($accounts)->andWhere('account')->in($accounts)->fi()