From 3874a3e22b84a902ba0d4e975a402012da38d69e Mon Sep 17 00:00:00 2001 From: wangyuting2 <851424971@qq.com> Date: Tue, 27 Sep 2022 03:07:47 +0000 Subject: [PATCH] * Do task #70850. --- module/custom/control.php | 4 +++- module/custom/model.php | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/module/custom/control.php b/module/custom/control.php index e383c0c981..7c73f6196b 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -635,11 +635,13 @@ class custom extends control if($mode == 'lean' and empty($program)) return $this->send(array('result' => 'fail', 'message' => array('program' => $this->lang->custom->switchModeHelper))); $this->loadModel('setting')->setItem('system.common.global.mode', $mode); - $this->loadModel('setting')->setItem('system.common.global.defaultProgram', $program); + $this->setting->setItem('system.common.global.defaultProgram', $program); /* 只有没有关联项目集的产品和项目关联到默认项目集下. */ $this->loadModel('upgrade')->relationDefaultProgram($program); + $this->custom->disableFeaturesByMode($mode); + if($mode == 'lean') $this->custom->processProjectAcl(); 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 32b1b8d510..227e1e4e0a 100644 --- a/module/custom/model.php +++ b/module/custom/model.php @@ -890,4 +890,44 @@ class customModel extends model } } } + + /** + * Set features to disable. + * + * @param int $mode + * @access public + * @return void + */ + public function disableFeaturesByMode($mode) + { + $disabledFeatures = ''; + if($mode == 'lean') + { + $features = array('opportunity'); + foreach($features as $feature) + { + $function = 'has' . ucfirst($feature) . 'Data'; + if(!$this->$function()) $disabledFeatures .= "$feature,"; + } + } + $this->loadModel('setting')->setItem('system.common.disabledFeatures', rtrim($disabledFeatures, ',')); + } + + /** + * Verify whether there is opportunity data + * + * @access public + * @return bool + */ + public function hasOpportunityData() + { + if($this->config->edition == 'max') + { + return $this->dao->select('id')->from(TABLE_OPPORTUNITY)->count(); + } + else + { + return false; + } + } }