This commit is contained in:
wangyuting2
2022-09-27 03:07:47 +00:00
parent b43b1c844a
commit 3874a3e22b
2 changed files with 43 additions and 1 deletions
+3 -1
View File
@@ -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'));
+40
View File
@@ -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;
}
}
}