mirror of https://github.com/MISP/MISP
Merge pull request #7366 from righel/allow-cake-cli-set-null-settings
fix: allow setting org_id=0 via cake console, add --force optionpull/7374/head
commit
6734e9d30e
|
@ -346,7 +346,7 @@ class AdminShell extends AppShell
|
|||
echo 'Invalid setting "' . $setting_name . '". Please make sure that the setting that you are attempting to change exists and if a module parameter, the modules are running.' . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
$result = $this->Server->serverSettingsEditValue($cli_user, $setting, $value);
|
||||
$result = $this->Server->serverSettingsEditValue($cli_user, $setting, $value, $this->params['force']);
|
||||
if ($result === true) {
|
||||
echo 'Setting "' . $setting_name . '" changed to ' . $value . PHP_EOL;
|
||||
} else {
|
||||
|
@ -490,6 +490,7 @@ class AdminShell extends AppShell
|
|||
{
|
||||
$this->ConfigLoad->execute();
|
||||
$parser = parent::getOptionParser();
|
||||
|
||||
$parser->addSubcommand('updateJSON', array(
|
||||
'help' => __('Update the JSON definitions of MISP.'),
|
||||
'parser' => array(
|
||||
|
@ -498,6 +499,14 @@ class AdminShell extends AppShell
|
|||
)
|
||||
)
|
||||
));
|
||||
|
||||
$parser->addOption('force', array(
|
||||
'short' => 'f',
|
||||
'help' => 'Force the command.',
|
||||
'default' => false,
|
||||
'boolean' => true
|
||||
));
|
||||
|
||||
return $parser;
|
||||
}
|
||||
|
||||
|
|
|
@ -1450,14 +1450,19 @@ class Server extends AppModel
|
|||
return $options;
|
||||
}
|
||||
|
||||
private function loadLocalOrganisations()
|
||||
private function loadLocalOrganisations($strict = false)
|
||||
{
|
||||
$localOrgs = $this->Organisation->find('list', array(
|
||||
'conditions' => array('local' => 1),
|
||||
'recursive' => -1,
|
||||
'fields' => array('Organisation.id', 'Organisation.name')
|
||||
));
|
||||
return array_replace(array(0 => __('No organisation selected.')), $localOrgs);
|
||||
|
||||
if(!$strict){
|
||||
return array_replace(array(0 => __('No organisation selected.')), $localOrgs);
|
||||
}
|
||||
|
||||
return $localOrgs;
|
||||
}
|
||||
|
||||
public function testTagCollections($value)
|
||||
|
@ -1515,6 +1520,15 @@ class Server extends AppModel
|
|||
}
|
||||
|
||||
public function testLocalOrg($value)
|
||||
{
|
||||
if ($value == 0) {
|
||||
return true; // `No organisation selected` option
|
||||
}
|
||||
|
||||
return $this->testLocalOrgStrict($value);
|
||||
}
|
||||
|
||||
public function testLocalOrgStrict($value)
|
||||
{
|
||||
$this->Organisation = ClassRegistry::init('Organisation');
|
||||
if ($value == 0) {
|
||||
|
@ -4752,10 +4766,10 @@ class Server extends AppModel
|
|||
'description' => __('The hosting organisation of this instance. If this is not selected then replication instances cannot be added.'),
|
||||
'value' => '0',
|
||||
'errorMessage' => '',
|
||||
'test' => 'testLocalOrg',
|
||||
'test' => 'testLocalOrgStrict',
|
||||
'type' => 'numeric',
|
||||
'optionsSource' => function () {
|
||||
return $this->loadLocalOrganisations();
|
||||
return $this->loadLocalOrganisations(true);
|
||||
},
|
||||
),
|
||||
'uuid' => array(
|
||||
|
|
Loading…
Reference in New Issue