From 82b7246b8d6ebc5ffc8b88e0c99d676bb8b37e33 Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Sun, 9 Oct 2022 07:44:39 +0000 Subject: [PATCH 1/2] * Finish task #71648. --- module/custom/control.php | 2 ++ module/custom/model.php | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/module/custom/control.php b/module/custom/control.php index 9afe6c757e..8532402f2d 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -645,6 +645,8 @@ class custom extends control if($mode == 'lean') $this->custom->processProjectAcl(); + $this->custom->processMeasrecordCron(); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'top')); } diff --git a/module/custom/model.php b/module/custom/model.php index 9302ab26f1..26db867b7f 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -917,6 +917,7 @@ class customModel extends model $function = 'has' . ucfirst($feature) . 'Data'; if(!$this->$function()) $disabledFeatures .= "$feature,"; } + $disabledFeatures .= 'scrumMeasrecord,'; } $this->loadModel('setting')->setItem('system.common.disabledFeatures', rtrim($disabledFeatures, ',')); } @@ -1064,4 +1065,23 @@ class customModel extends model } return false; } + + /** + * Process measrecord cron. + * + * @access public + * @return void + */ + public function processMeasrecordCron() + { + $disabledFeatures = $this->loadModel('setting')->getItem('owner=system&module=common§ion=&key=disabledFeatures'); + + $cronStatus = 'normal'; + if(strpos(",$disabledFeatures,", ',waterfall,') !== false and strpos(",$disabledFeatures,", ',scrumMeasrecord,') !== false) $cronStatus = 'stop'; + + $cronID = $this->dao->select('id')->from(TABLE_CRON)->where('command')->like('%methodName=initCrontabQueue')->fetch('id'); + if($cronID) $this->loadModel('cron')->changeStatus($cronID, $cronStatus); + $cronID = $this->dao->select('id')->from(TABLE_CRON)->where('command')->like('%methodName=execCrontabQueue')->fetch('id'); + if($cronID) $this->cron->changeStatus($cronID, $cronStatus); + } } From 4fcf7ae1bd1362f2be357a95ddd62ecc75cb8636 Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Sun, 9 Oct 2022 08:14:10 +0000 Subject: [PATCH 2/2] * Optimize code. --- module/custom/control.php | 2 -- module/custom/model.php | 20 ++++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/module/custom/control.php b/module/custom/control.php index 8532402f2d..9afe6c757e 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -645,8 +645,6 @@ class custom extends control if($mode == 'lean') $this->custom->processProjectAcl(); - $this->custom->processMeasrecordCron(); - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'top')); } diff --git a/module/custom/model.php b/module/custom/model.php index 26db867b7f..e70064bf55 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -919,7 +919,11 @@ class customModel extends model } $disabledFeatures .= 'scrumMeasrecord,'; } - $this->loadModel('setting')->setItem('system.common.disabledFeatures', rtrim($disabledFeatures, ',')); + + $disabledFeatures = rtrim($disabledFeatures, ','); + $this->loadModel('setting')->setItem('system.common.disabledFeatures', $disabledFeatures); + + $this->processMeasrecordCron($disabledFeatures); } /** @@ -1069,19 +1073,19 @@ class customModel extends model /** * Process measrecord cron. * + * @param string $disabledFeatures * @access public * @return void */ - public function processMeasrecordCron() + public function processMeasrecordCron($disabledFeatures) { - $disabledFeatures = $this->loadModel('setting')->getItem('owner=system&module=common§ion=&key=disabledFeatures'); - $cronStatus = 'normal'; if(strpos(",$disabledFeatures,", ',waterfall,') !== false and strpos(",$disabledFeatures,", ',scrumMeasrecord,') !== false) $cronStatus = 'stop'; - $cronID = $this->dao->select('id')->from(TABLE_CRON)->where('command')->like('%methodName=initCrontabQueue')->fetch('id'); - if($cronID) $this->loadModel('cron')->changeStatus($cronID, $cronStatus); - $cronID = $this->dao->select('id')->from(TABLE_CRON)->where('command')->like('%methodName=execCrontabQueue')->fetch('id'); - if($cronID) $this->cron->changeStatus($cronID, $cronStatus); + $this->loadModel('cron'); + $cron = $this->dao->select('id,status')->from(TABLE_CRON)->where('command')->like('%methodName=initCrontabQueue')->fetch(); + if($cron and $cron->status != $cronStatus) $this->cron->changeStatus($cron->id, $cronStatus); + $cron = $this->dao->select('id,status')->from(TABLE_CRON)->where('command')->like('%methodName=execCrontabQueue')->fetch(); + if($cron and $cron->status != $cronStatus) $this->cron->changeStatus($cron->id, $cronStatus); } }