From 58159b3d42a8dc6a02eb95345e9ef2a025025449 Mon Sep 17 00:00:00 2001 From: wumo Date: Wed, 4 Apr 2018 13:13:09 +0800 Subject: [PATCH 1/2] * Adjust the style of the prompt in multi-user task * Add unique key to team table. --- db/update9.8.2.sql | 2 +- module/task/lang/zh-cn.php | 2 +- module/upgrade/model.php | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/db/update9.8.2.sql b/db/update9.8.2.sql index 6017a40b69..a989df34fd 100644 --- a/db/update9.8.2.sql +++ b/db/update9.8.2.sql @@ -1,3 +1,3 @@ ALTER TABLE `zt_team` DROP PRIMARY KEY; -ALTER TABLE `zt_team` ADD PRIMARY KEY (`root`, `type`, `account`); +ALTER TABLE `zt_team` ADD `id` mediumint(8) unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT FIRST; ALTER TABLE `zt_project` CHANGE `team` `team` varchar(90) NOT NULL; diff --git a/module/task/lang/zh-cn.php b/module/task/lang/zh-cn.php index abc4a8526c..14b60cddd5 100644 --- a/module/task/lang/zh-cn.php +++ b/module/task/lang/zh-cn.php @@ -108,7 +108,7 @@ $lang->task->parent = '父任务'; $lang->task->parentAB = '父'; $lang->task->lblPri = 'P'; $lang->task->lblHour = '(h)'; -$lang->task->deniedNotice = '当前任务只有%s才可以%s'; +$lang->task->deniedNotice = '当前任务只有%s才可以%s。'; $lang->task->ditto = '同上'; $lang->task->dittoNotice = "该任务与上一任务不属于同一项目!"; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 5ef63f22c4..65dfe7a300 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -214,6 +214,7 @@ class upgradeModel extends model $this->resetProductLine(); case '9_8_2': $this->execSQL($this->getUpgradeFile('9.8.2')); + $this->addUniqueKeyToTeam(); } $this->deletePatch(); @@ -2244,4 +2245,33 @@ class upgradeModel extends model $this->dao->update(TABLE_PRODUCT)->set('line')->eq(0)->where('line')->in($deletedLines)->exec(); return !dao::isError(); } + + /** + * Add unique key to team table. + * + * @access public + * @return bool + */ + public function addUniqueKeyToTeam() + { + $members = $this->dao->select('root, type, account')->from(TABLE_TEAM)->groupBy('root, type, account')->having('count(*)')->gt(1)->fetchAll(); + + foreach($members as $member) + { + $maxID = $this->dao->select('MAX(id) id') + ->from(TABLE_TEAM) + ->where('root')->eq($member->root) + ->andWhere('`type`')->eq($member->type) + ->andWhere('account')->eq($member->account) + ->fetch('id'); + $this->dao->delete()->from(TABLE_TEAM) + ->where('root')->eq($member->root) + ->andWhere('`type`')->eq($member->type) + ->andWhere('account')->eq($member->account) + ->andWhere('id')->ne($maxID) + ->exec(); + } + $this->dao->exec("ALTER TABLE `zt_team` ADD UNIQUE `team` (`root`, `type`, `account`)"); + return !dao::isError(); + } } From 69e065a8030ae9809ae6cb6c3924fb5cfa7804ed Mon Sep 17 00:00:00 2001 From: wumo Date: Wed, 4 Apr 2018 13:23:03 +0800 Subject: [PATCH 2/2] * Add the unique key to team table. --- db/zentao.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/zentao.sql b/db/zentao.sql index 1c6dbc5d9d..6a8be26f11 100644 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -644,6 +644,7 @@ CREATE TABLE IF NOT EXISTS `zt_taskestimate` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- DROP TABLE IF EXISTS `zt_team`; CREATE TABLE IF NOT EXISTS `zt_team` ( + `id` mediumint(8) unsigned NOT NULL auto_increment, `root` mediumint(8) unsigned NOT NULL default '0', `type` enum('project','task') NOT NULL DEFAULT 'project', `account` char(30) NOT NULL default '', @@ -656,7 +657,8 @@ CREATE TABLE IF NOT EXISTS `zt_team` ( `consumed` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0', `left` DECIMAL(12,2) UNSIGNED NOT NULL DEFAULT '0', `order` TINYINT(3) NOT NULL DEFAULT '0', - PRIMARY KEY (`root`,`type`,`account`) + PRIMARY KEY (`id`), + UNIQUE KEY `team` (`root`,`type`,`account`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- DROP TABLE IF EXISTS `zt_testreport`; CREATE TABLE IF NOT EXISTS `zt_testreport` (