diff --git a/bin/ztcli b/bin/ztcli index c5e19828b1..38252d263b 100755 --- a/bin/ztcli +++ b/bin/ztcli @@ -15,7 +15,7 @@ error_reporting(E_ALL ^ E_NOTICE ^ E_STRICT); define('IN_SHELL', true); /* Judge the args. */ -if($argc != 2) die('Usage: ' . basename(__FILE__) . " \n"); +if($argc < 2 or $argc > 3) die('Usage: ' . basename(__FILE__) . " \n"); /* Parse the request into params. */ $request = parse_url(trim($argv[1])); @@ -33,6 +33,13 @@ include './framework/helper.class.php'; $app = router::createApp('pms', dirname(dirname(__FILE__)), 'router'); $common = $app->loadCommon(); +/* Set the PATH_INFO request. */ +if(!empty($argv[2]) && $argv[2] == 'pathinfo') +{ + $config->requestType = 'PATH_INFO'; + $config->requestFix = '-'; +} + /* Set the PATH_INFO variable. */ if($config->requestType == 'PATH_INFO') { diff --git a/module/action/control.php b/module/action/control.php index ac9224fabe..46f6b93c3d 100755 --- a/module/action/control.php +++ b/module/action/control.php @@ -11,6 +11,30 @@ */ class action extends control { + /** + * Create a action or delete all patch actions, this method is used by the Ztools. + * + * @param string $objectType + * @param string $actionType + * @param string $objectName + * @access public + * @return void + */ + public function create($objectType, $actionType, $objectName) + { + $actionID = $this->action->create($objectType, 0, $actionType, '', $objectName); + + if($actionID) + { + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess)); + } + else + { + $this->send(array('result' => 'fail', 'message' => 'error')); + } + } + + /** * Trash. * diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 683a725743..7f67123d50 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -139,6 +139,7 @@ $lang->action->objectTypes['kanbancard'] = 'Kanban Card'; $lang->action->objectTypes['sonarqube'] = 'SonarQube Server'; $lang->action->objectTypes['sonarqubeproject'] = 'SonarQube Project'; $lang->action->objectTypes['stage'] = 'Stage'; +$lang->action->objectTypes['patch'] = 'Patch'; /* Used to describe operation history. */ $lang->action->desc = new stdclass(); @@ -232,6 +233,8 @@ $lang->action->desc->unlinkbug = '$date, 由 $actor 从计划 /* Used to display dynamic information. */ $lang->action->label = new stdclass(); +$lang->action->label->install = 'install '; +$lang->action->label->revert = 'revert '; $lang->action->label->created = 'created '; $lang->action->label->opened = 'opened '; $lang->action->label->openedbysystem = 'Opened by system '; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index d44fa78f60..953a74feb7 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -139,6 +139,7 @@ $lang->action->objectTypes['kanbancard'] = '看板卡片'; $lang->action->objectTypes['sonarqube'] = 'SonarQube服务器'; $lang->action->objectTypes['sonarqubeproject'] = 'SonarQube项目'; $lang->action->objectTypes['stage'] = '阶段'; +$lang->action->objectTypes['patch'] = '补丁'; /* 用来描述操作历史记录。*/ $lang->action->desc = new stdclass(); @@ -232,6 +233,8 @@ $lang->action->desc->unlinkbug = '$date, 由 $actor 从计划 /* 用来显示动态信息。*/ $lang->action->label = new stdclass(); +$lang->action->label->install = '安装'; +$lang->action->label->revert = '还原'; $lang->action->label->created = '创建'; $lang->action->label->opened = '创建'; $lang->action->label->openedbysystem = '系统创建'; diff --git a/module/action/model.php b/module/action/model.php index 8f6616b3f8..20eb2b8f15 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1555,6 +1555,18 @@ class actionModel extends model } } + /** + * Delete action by objectType. + * + * @param string $objectType + * @access public + * @return void + */ + public function deleteByType($objectType) + { + $this->dao->delete()->from(TABLE_ACTION)->where('objectType')->eq($objectType)->exec(); + } + /** * Undelete a record. * diff --git a/module/upgrade/control.php b/module/upgrade/control.php index c0c7c862ea..ae4b2b9de1 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -153,6 +153,10 @@ class upgrade extends control if(!$this->upgrade->isError()) { $systemMode = $this->loadModel('setting')->getItem('owner=system&module=common§ion=global&key=mode'); + + /* Delete all patch actions if upgrade success. */ + $this->loadModel('action')->deleteByType('patch'); + if((empty($systemMode) && !isset($this->config->qcVersion) && strpos($fromVersion, 'max') === false) or ($systemMode != 'new' && strpos($fromVersion, 'max') === false && strpos($this->config->version, 'max') !== false)) { diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 04d16b6094..70a4367cd1 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -1320,6 +1320,18 @@ class upgradeModel extends model } } + /* Delete all patch files when upgrade zentao. */ + $patchPath = $this->app->getTmpRoot() . 'patch'; + $isDir = is_dir($patchPath); + if(file_exists($patchPath)) + { + if(!is_writable($patchPath) or ($isDir and !$zfile->removeDir($patchPath)) or + (!$isDir and !$zfile->removeDir($patchPath))) + { + $result[] = 'rm -f ' . ($isDir ? '-r ' : '') . $patchPath; + } + } + return $result; }