fix: allow setting org_id=0 via cake console, add --force option to force settings.

pull/7366/head
Luciano Righetti 2021-04-23 12:01:07 +02:00
parent 7275ac97ad
commit da0f9c4148
2 changed files with 12 additions and 3 deletions

View File

@ -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;
}

View File

@ -1516,10 +1516,10 @@ class Server extends AppModel
public function testLocalOrg($value)
{
$this->Organisation = ClassRegistry::init('Organisation');
if ($value == 0) {
return 'No organisation selected';
return true; // `No organisation selected` option
}
$this->Organisation = ClassRegistry::init('Organisation');
$local_orgs = $this->Organisation->find('list', array(
'conditions' => array('local' => 1),
'recursive' => -1,