diff --git a/db/update4.0.beta2.sql b/db/update4.0.beta2.sql index 29a9e7497e..be99172707 100644 --- a/db/update4.0.beta2.sql +++ b/db/update4.0.beta2.sql @@ -34,8 +34,6 @@ INSERT INTO `zt_groupPriv` (`company` , `group` , `module` , `method` ) VALUES ('1', '10', 'webapp', 'index'), ('1', '11', 'webapp', 'index'); -DELETE FROM `zt_config` where `company` = '0' and `section` = 'global' and `key` = 'flow'; -UPDATE `zt_config` SET `company` = '0', `section` = 'global' WHERE `key` = 'flow'; ALTER TABLE `zt_webapp` ADD `abstract` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `size` ; ALTER TABLE `zt_webapp` CHANGE `url` `url` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 5fa680e0d7..aed827ca19 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -74,7 +74,6 @@ class upgradeModel extends model case '3_3': $this->execSQL($this->getUpgradeFile('3.3')); $this->updateTaskAssignedTo(); - $this->loadModel('setting')->setItem('system.common.global.flow', 'full'); case '4_0_beta1': $this->execSQL($this->getUpgradeFile('4.0.beta1')); case '4_0_beta2': $this->execSQL($this->getUpgradeFile('4.0.beta2')); @@ -611,6 +610,41 @@ class upgradeModel extends model } } + /** + * Process flow. + * + * @access public + * @return void + */ + public function processFlow() + { + $flows = $this->dao->select('*')->from(TABLE_CONFIG)->where('`owner`')->eq('system')->andWhere('`module`')->eq('common')->andWhere('`key`')->eq('flow')->fatchAll('company', false); + if($flows) + { + /* Set company to 0 and section to global. */ + if(!isset($flows[0])) + { + $flow = array_shift($flows); + $this->dao->update(TABLE_CONFIG)->set('company')->eq(0)->set('section')->eq('global')->where('id')->eq($flow->id)->exec(false) + } + else + { + $this->dao->update(TABLE_CONFIG)->set('section')->eq('global')->where('id')->eq($flows[0]->id)->exec(false) + } + + /* Delete other flow data. */ + foreach($flows as $company => $flow) + { + if($company != 0) $this->dao->delete()->from(TABLE_CONFIG)->where('id')->eq($flow->id)->exec(false); + } + } + else + { + /* Add flow to zentao.*/ + $this->loadModel('setting')->setItem('system.common.global.flow', 'full', 0); + } + } + /** * Judge any error occers. *