From 1f79e9e7dd40437dde8654edc30b16cb2e86380c Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Sat, 22 Jan 2022 22:24:49 +0800 Subject: [PATCH] * Code for task#47995. --- module/action/lang/en.php | 4 +-- module/action/lang/zh-cn.php | 4 +-- module/action/model.php | 5 ++++ module/kanban/control.php | 31 ++++++----------------- module/kanban/model.php | 49 +++++++++++++++++++++++++++--------- 5 files changed, 54 insertions(+), 39 deletions(-) diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 3223822140..bfceb68ea2 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -193,7 +193,7 @@ $lang->action->desc->syncexecution = '$date, starting the task sets the e $lang->action->desc->importfromgitlab = '$date, Issue associate created from gitlab by $actor.' . "\n"; $lang->action->desc->archived = '$date, archived by $actor.' . "\n"; $lang->action->desc->restore = '$date, restore by $actor.' . "\n"; -$lang->action->desc->imported = '$date, imported by $actor .' . "\n"; +$lang->action->desc->importedcard = '$date, imported to $extra by $actor.' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor created a child task $extra。' . "\n"; @@ -333,7 +333,7 @@ $lang->action->label->closedbychild = 'closed'; $lang->action->label->activatedbychild = 'activated'; $lang->action->label->createchild = 'activated'; $lang->action->label->executed = 'executed'; -$lang->action->label->imported = 'imported'; +$lang->action->label->importedcard = 'imported'; /* Dynamic information is grouped by object. */ $lang->action->dynamicAction = new stdclass; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 819b0b99a2..292ebca4b3 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -193,7 +193,7 @@ $lang->action->desc->syncexecution = '$date, 系统判断由于任务开 $lang->action->desc->importfromgitlab = '$date, 由 $actor 从Gitlab的Issue关联创建。' . "\n"; $lang->action->desc->archived = '$date, 由 $actor 归档。' . "\n"; $lang->action->desc->restore = '$date, 由 $actor 还原。' . "\n"; -$lang->action->desc->imported = '$date, 由 $actor 导入。' . "\n"; +$lang->action->desc->importedcard = '$date, 由 $actor 从看板 $extra 导入。' . "\n"; /* 用来描述和父子任务相关的操作历史记录。*/ $lang->action->desc->createchildren = '$date, 由 $actor 创建子任务 $extra。' . "\n"; @@ -333,7 +333,7 @@ $lang->action->label->closedbychild = '关闭了'; $lang->action->label->activatedbychild = '激活了'; $lang->action->label->createchild = '激活了'; $lang->action->label->executed = '执行了'; -$lang->action->label->imported = '导入了'; +$lang->action->label->importedcard = '导入了'; /* 动态信息按照对象分组 */ $lang->action->dynamicAction = new stdclass(); diff --git a/module/action/model.php b/module/action/model.php index 5aaabd6619..a03924531c 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -435,6 +435,11 @@ class actionModel extends model $title = $this->dao->select('title')->from(TABLE_STORY)->where('id')->eq($action->extra)->fetch('title'); if($title) $action->extra = common::hasPriv('story', 'view') ? html::a(helper::createLink('story', 'view', "storyID=$action->extra"), "#$action->extra " . $title) : "#$action->extra " . $title; } + elseif($actionName == 'importedcard') + { + $title = $this->dao->select('name')->from(TABLE_KANBAN)->where('id')->eq($action->extra)->fetch('name'); + if($title) $action->extra = common::hasPriv('kanban', 'view') ? html::a(helper::createLink('kanban', 'view', "kanbanID=$action->extra"), "#$action->extra " . $title) : "#$action->extra " . $title; + } elseif($actionName == 'createchildren') { $names = $this->dao->select('id,name')->from(TABLE_TASK)->where('id')->in($action->extra)->fetchPairs('id', 'name'); diff --git a/module/kanban/control.php b/module/kanban/control.php index 141eb657f3..6011c72983 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -792,6 +792,12 @@ class kanban extends control */ public function importCard($kanbanID = 0, $regionID = 0, $groupID = 0, $columnID = 0, $selectedKanbanID = 0, $recTotal = 0, $recPerPage = 30, $pageID = 1) { + /* Load pager. */ + $this->app->loadClass('pager', $static = true); + $pager = new pager($recTotal, $recPerPage, $pageID); + + $cards2Imported = $this->kanban->getImportedCards($selectedKanbanID, $kanbanID, $pager); + if($_POST) { $importedIDList = $this->kanban->importCard($kanbanID, $regionID, $groupID, $columnID); @@ -799,38 +805,17 @@ class kanban extends control foreach($importedIDList as $cardID) { - $this->loadModel('action')->create('kanbancard', $cardID, 'imported'); + $this->loadModel('action')->create('kanbancard', $cardID, 'importedcard', '', $cards2Imported[$cardID]->kanban); } return print(js::locate($this->createLink('kanban', 'view', "kanbanID=$kanbanID"), 'parent.parent')); } - /* Get cards to imported. */ - $cards2Imported = array(); - if($selectedKanbanID) - { - $cards2Imported = $this->kanban->getCardsByObject('kanban', $selectedKanbanID); - } - else - { - $allKanbanCards = $this->kanban->getCardsByObject(); - foreach($allKanbanCards as $card) - { - if($card->kanban != $kanbanID) $cards2Imported[$card->id] = $card; - } - } - - /* Pager. */ - $this->app->loadClass('pager', $static = true); - $recTotal = count($cards2Imported); - $pager = new pager($recTotal, $recPerPage, $pageID); - $cards2Imported = array_chunk($cards2Imported, $pager->recPerPage); - /* Find Kanban other than this kanban. */ $kanbanPairs = $this->kanban->getKanbanPairs(); unset($kanbanPairs[$kanbanID]); - $this->view->cards2Imported = empty($cards2Imported) ? $cards2Imported : $cards2Imported[$pageID - 1]; + $this->view->cards2Imported = $cards2Imported; $this->view->kanbanPairs = array($this->lang->kanban->all) + $kanbanPairs; $this->view->lanePairs = $this->kanban->getLanePairsByGroup($groupID); $this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted'); diff --git a/module/kanban/model.php b/module/kanban/model.php index 2b743f3869..d5f1714419 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -484,6 +484,8 @@ class kanbanModel extends model $importIDList = $data->cards; $targetLaneID = $data->targetLane; + $oldCardsKanban = $this->dao->select('id,kanban')->from(TABLE_KANBANCARD)->where('id')->in($importIDList)->fetchPairs(); + $updateData = new stdClass(); $updateData->kanban = $kanbanID; $updateData->region = $regionID; @@ -492,7 +494,7 @@ class kanbanModel extends model if(!dao::isError()) { - $this->removeKanbanCell('common', $importIDList); + $this->removeKanbanCell('common', $importIDList, $oldCardsKanban); $cards = implode(',', $importIDList); $this->addKanbanCell($kanbanID, $targetLaneID, $columnID, 'common', $cards); @@ -2004,25 +2006,27 @@ class kanbanModel extends model /** * Remove kanban cell. * + * @param string $type * @param int|array $removeCardID + * @param array $cardsKanban * @access public * @return void */ - public function removeKanbanCell($type, $removeCardID = 0) + public function removeKanbanCell($type, $removeCardID, $cardsKanban) { - if(is_array($removeCardID)) + $removeIDList = is_array($removeCardID) ? $removeCardID : array($removeCardID); + foreach($removeIDList as $cardID) { - foreach($removeCardID as $cardID) - { - $this->dbh->query("UPDATE " . TABLE_KANBANCELL. " SET cards = REPLACE(cards, ',{$cardID},', ',') WHERE type = '$type'"); - } - } - else - { - $this->dbh->query("UPDATE " . TABLE_KANBANCELL. " SET cards = REPLACE(cards, ',{$removeCardID},', ',') WHERE type = '$type'"); + if(empty($cardID)) continue; + + $this->dbh->query("UPDATE " . TABLE_KANBANCELL. " SET `cards` = REPLACE(cards, ',$cardID,', ',') WHERE `type` = '$type' AND `kanban` = {$cardsKanban[$cardID]}"); } - $this->dao->update(TABLE_KANBANCELL)->set('cards')->eq('')->where('cards')->eq(',')->andWhere('type')->eq($type)->exec(); + $this->dao->update(TABLE_KANBANCELL) + ->set('cards')->eq('') + ->where('cards')->eq(',') + ->andWhere('type')->eq($type) + ->exec(); } /** @@ -3019,6 +3023,27 @@ class kanbanModel extends model ->fetchAll('id'); } + /** + * Get imported cards. + * + * @param int $objectID + * @param int $excluded + * @param obj $pager + * @access public + * @return array + */ + public function getImportedCards($kanbanID = 0, $excluded = 0, $pager = null) + { + return $this->dao->select('*')->from(TABLE_KANBANCARD) + ->where('deleted')->eq(0) + ->andWhere('archived')->eq(0) + ->beginIF($kanbanID)->andWhere('kanban')->eq($kanbanID)->fi() + ->beginIF($excluded)->andWhere('kanban')->ne($excluded)->fi() + ->orderBy('order') + ->page($pager) + ->fetchAll('id'); + } + /** * Get Kanban cards menus by execution id. *