diff --git a/db/update17.6.2.sql b/db/update17.6.2.sql index 601887adc3..575e6ecbe7 100644 --- a/db/update17.6.2.sql +++ b/db/update17.6.2.sql @@ -4,3 +4,4 @@ ALTER TABLE `zt_kanban` ADD `maxColWidth` smallint(4) NOT NULL DEFAULT '384' AFT ALTER TABLE `zt_project` ADD `colWidth` smallint(4) NOT NULL DEFAULT '264' AFTER `fluidBoard`; ALTER TABLE `zt_project` ADD `minColWidth` smallint(4) NOT NULL DEFAULT '180' AFTER `colWidth`; ALTER TABLE `zt_project` ADD `maxColWidth` smallint(4) NOT NULL DEFAULT '384' AFTER `minColWidth`; +REPLACE INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'common', 'global', 'syncProductFeedback', '{}'); diff --git a/db/update17.6.sql b/db/update17.6.sql index d8545cd6e1..5f0cbf39ea 100644 --- a/db/update17.6.sql +++ b/db/update17.6.sql @@ -13,7 +13,5 @@ CREATE TABLE `zt_taskteam` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ALTER TABLE `zt_taskestimate` ADD `order` tinyint unsigned NOT NULL DEFAULT '0'; ALTER TABLE `zt_effort` ADD `order` tinyint unsigned NOT NULL DEFAULT '0' AFTER `end`; - -REPLACE INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'common', 'global', 'syncProductFeedback', '0'); ALTER TABLE `zt_storyspec` ADD `files` text NOT NULL AFTER `verify`; ALTER TABLE `zt_block` CHANGE `block` `block` varchar(30) COLLATE 'utf8_general_ci' NOT NULL AFTER `source`; diff --git a/db/zentao.sql b/db/zentao.sql index 4e57f6efd3..043b03f457 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -6309,7 +6309,7 @@ INSERT INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES (' INSERT INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'project', '', 'unitList', 'CNY,USD'); INSERT INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'project', '', 'defaultCurrency', 'CNY'); INSERT INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'story', '', 'reviewRules', 'allpass'); -INSERT INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'common', 'global', 'syncProductFeedback', '0'); +INSERT INTO `zt_config` (`owner`, `module`, `section`, `key`, `value`) VALUES ('system', 'common', 'global', 'syncProductFeedback', '{}'); -- DROP TABLE IF EXISTS `zt_im_chat`; CREATE TABLE IF NOT EXISTS `zt_im_chat` ( `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, diff --git a/module/product/model.php b/module/product/model.php index 33d81fcbb8..bac3985956 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -2313,7 +2313,7 @@ class productModel extends model } elseif($module == 'feedback') { - return helper::createLink($module, $method, "browseType=byProduct&productID=%s"); + return helper::createLink('feedback', 'admin', "browseType=byProduct&productID=%s"); } return $link; diff --git a/module/product/view/ajaxgetdropmenu.html.php b/module/product/view/ajaxgetdropmenu.html.php index 4147879cbe..eeddfd93c2 100644 --- a/module/product/view/ajaxgetdropmenu.html.php +++ b/module/product/view/ajaxgetdropmenu.html.php @@ -139,7 +139,7 @@ $closedProductsHtml .= ''; product->closed?> app->tab == 'feedback'):?> - product->all, '', "class='not-list-item pull-left toggle-left-col $selected'"); ?> + product->all, '', "class='not-list-item pull-left toggle-left-col $selected'"); ?> diff --git a/module/tree/control.php b/module/tree/control.php index fd5cd84e2a..5d468bde1e 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -143,7 +143,6 @@ class tree extends control $this->view->root = $root; $title = $this->lang->tree->manageFeedback; - $this->lang->feedback->menu->browse['subMenu'] = new stdclass(); $position[] = html::a($this->createLink('feedback', 'admin'), $this->lang->tree->manageFeedback); } elseif($viewType == 'case') diff --git a/module/tree/model.php b/module/tree/model.php index ca55b7d513..bb8c400352 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -80,7 +80,10 @@ class treeModel extends model $startModule = $this->getById($startModule); if($startModule) $startModulePath = $startModule->path . '%'; } - if($type == 'feedback' and strpos($param, 'noproduct') === false) $type = 'story,' . $type; + + /* If feedback module is merge add story module.*/ + $syncConfig = json_decode($this->config->global->syncProductFeedback, true); + if($type == 'feedback' and strpos($param, 'noproduct') === false and isset($syncConfig[$rootID])) $type = 'story,' . $type; if($this->isMergeModule($rootID, $type)) { return $this->dao->select('*')->from(TABLE_MODULE) @@ -1378,10 +1381,13 @@ class treeModel extends model { if($type == 'line') $rootID = 0; + $syncConfig = json_decode($this->config->global->syncProductFeedback, true); + if($type == 'feedback' and isset($syncConfig[$rootID])) $type = "$type,story"; + /* if createVersion <= 4.1 or type == 'story', only get modules of its type. */ if(!$this->isMergeModule($rootID, $type) or $type == 'story') { - if($type == 'feedback') $type = "$type,story"; + return $this->dao->select('*')->from(TABLE_MODULE) ->where('root')->eq((int)$rootID) ->andWhere('parent')->eq((int)$moduleID) @@ -1397,7 +1403,7 @@ class treeModel extends model } /* else get modules of its type and story type. */ - if(strpos('task|case|bug|feedback', $type) !== false) $type = "$type,story"; + if(strpos('task|case|bug', $type) !== false) $type = "$type,story"; return $this->dao->select('*')->from(TABLE_MODULE) ->where('root')->eq((int)$rootID) diff --git a/module/upgrade/model.php b/module/upgrade/model.php index cf32236c89..5027bce860 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -713,6 +713,9 @@ class upgradeModel extends model $this->addFlowActions('biz7.4'); $this->addFlowFields('biz7.4'); break; + case 'biz7_6_2': + $this->processFeedbackModule(); + } } @@ -7508,4 +7511,56 @@ class upgradeModel extends model } return true; } + + /** + * Process feedback module + * + * @access public + * @return void + */ + public function processFeedbackModule() + { + $products = $this->dao->select('id, name')->from(TABLE_PRODUCT)->fetchAll(); + $modules = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('feedback')->andWhere('root')->eq(0)->fetchAll('id'); + $feedbacks = $this->dao->select('*')->from(TABLE_FEEDBACK)->fetchAll(); + + $allProductRelation = array(); + foreach($products as $product) + { + $productID = $product->id; + $relation = array(); + foreach($modules as $moduleID => $module) + { + unset($module->id); + $module->root = $productID; + $this->dao->insert(TABLE_MODULE)->data($module)->exec(); + $newModuleID = $this->dao->lastInsertID(); + $relation[$moduleID] = $newModuleID; + $allProductRelation[$productID][$moduleID] = $newModuleID; + $newPaths = array(); + foreach(explode(',', trim($module->path, ',')) as $path) + { + if(isset($relation[$path])) $newPaths[] = $relation[$path]; + } + $newPaths = join(',', $newPaths); + $parent = !empty($module->parent) ? $relation[$module->parent] : 0; + $this->dao->update(TABLE_MODULE)->set('path')->eq($newPaths)->set('parent')->eq($parent)->where('id')->eq($newModuleID)->exec(); + } + } + + /* Update feedback module */ + foreach($feedbacks as $feedback) + { + $moduleID = $feedback->module; + $product = $feedback->product; + if(empty($moduleID)) continue; + $newModuleID = isset($allProductRelation[$product][$moduleID]) ? $allProductRelation[$product][$moduleID] : 0; + if(empty($newModuleID)) continue; + + $this->dao->update(TABLE_FEEDBACK)->set('module')->eq($newModuleID)->where('id')->eq($feedback->id)->exec(); + } + + /* Delete history module */ + $this->dao->delete()->from(TABLE_MODULE)->where('type')->eq('feedback')->andWhere('root')->eq(0)->exec(); + } }