From 7995d3486e9e31e75e245daf3352f0da404236ef Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Tue, 24 Nov 2020 11:08:16 +0800 Subject: [PATCH] * Finish task#8483.#8484.#8485.#8486.#8487. --- module/action/model.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/module/action/model.php b/module/action/model.php index c9d82d2385..680723c61e 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -804,9 +804,34 @@ class actionModel extends model $objectIds = array_unique($objectIds); $table = $this->config->objectTables[$objectType]; $field = $this->config->action->objectNameFields[$objectType]; + $objectNames[$objectType] = array(); + $objectPRJs[$objectType] = array(); if($table != TABLE_TODO) { - $objectNames[$objectType] = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetchPairs(); + $specialTables = "task,bug,build,issue"; + foreach(explode(',', $specialTables) as $specialTable) + { + if(strpos($table, $specialTable) !== false) + { + $objectInfo = $this->dao->select("id, PRJ, $field AS name")->from($table)->where('id')->in($objectIds)->fetch(); + $objectName = array($objectInfo->id => $objectInfo->name); + $objectPRJ = array($objectInfo->id => $objectInfo->PRJ); + } + } + if(strpos($table, 'project') !== false) + { + $objectInfo = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetch(); + $objectName = array($objectInfo->id => $objectInfo->name); + $objectPRJ = array($objectInfo->id => $objectInfo->id); + } + else + { + $objectName = $this->dao->select("id, $field AS name")->from($table)->where('id')->in($objectIds)->fetchPairs(); + $objectPRJ = array(); + } + + $objectNames[$objectType] = $objectName; + $objectPRJs[$objectType] = $objectPRJ; } else { @@ -833,6 +858,8 @@ class actionModel extends model /* Add name field to the actions. */ $action->objectName = isset($objectNames[$action->objectType][$action->objectID]) ? $objectNames[$action->objectType][$action->objectID] : ''; + $objectPRJ = isset($objectPRJs[$action->objectType][$action->objectID]) ? $objectPRJs[$action->objectType][$action->objectID] : 0; + $actionType = strtolower($action->action); $objectType = strtolower($action->objectType); $action->originalDate = $action->date; @@ -867,7 +894,7 @@ class actionModel extends model continue; } - $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID)); + $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID), '', '', $objectPRJ); if($action->objectType == 'user') $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectName)); $action->objectLabel = $objectLabel; }