mirror of https://github.com/MISP/MISP
Reworked the server settings for boolean settings and settings that have a few options as values.
- Toggles instead of free-textpull/304/merge
parent
79127902b7
commit
2521106254
|
@ -365,10 +365,10 @@ class ServersController extends AppController {
|
|||
$this->render('ajax/server_settings_edit');
|
||||
}
|
||||
if ($this->request->is('post')) {
|
||||
if ($found['test'] == 'testBool') {
|
||||
if ($found['type'] == 'boolean') {
|
||||
$this->request->data['Server']['value'] = ($this->request->data['Server']['value'] ? true : false);
|
||||
}
|
||||
if ($found['test'] == 'testForNumeric' || $found['test'] == 'testDebug') {
|
||||
if ($found['type'] == 'numeric') {
|
||||
$this->request->data['Server']['value'] = intval($this->request->data['Server']['value']);
|
||||
}
|
||||
$testResult = $this->Server->{$found['test']}($this->request->data['Server']['value']);
|
||||
|
|
|
@ -289,7 +289,8 @@ class Server extends AppModel {
|
|||
'value' => '',
|
||||
'errorMessage' => '',
|
||||
'test' => 'testForEmpty',
|
||||
'type' => 'numeric',
|
||||
'type' => 'string',
|
||||
'options' => array('0' => 'Your organisation only', '1' => 'This community only', '2' => 'Connected communities', '3' => 'All communities'),
|
||||
),
|
||||
'default_attribute_distribution' => array(
|
||||
'level' => 0,
|
||||
|
@ -298,6 +299,7 @@ class Server extends AppModel {
|
|||
'errorMessage' => '',
|
||||
'test' => 'testForEmpty',
|
||||
'type' => 'string',
|
||||
'options' => array('0' => 'Your organisation only', '1' => 'This community only', '2' => 'Connected communities', '3' => 'All communities', 'event' => 'Inherit from event'),
|
||||
),
|
||||
'tagging' => array(
|
||||
'level' => 1,
|
||||
|
@ -389,6 +391,7 @@ class Server extends AppModel {
|
|||
'errorMessage' => '',
|
||||
'test' => 'testDebug',
|
||||
'type' => 'numeric',
|
||||
'options' => array(0 => 'Debug off', 1 => 'Debug on', 2 => 'Debug + SQL dump'),
|
||||
),
|
||||
);
|
||||
|
||||
|
|
|
@ -15,19 +15,20 @@
|
|||
if ($setting['level'] == 0 || $setting['level'] == 2) $bgColour .= 'color:white;';
|
||||
}
|
||||
if ($setting['level'] == 3) $bgColour = 'background-color:gray;color:white;';
|
||||
if ($setting['test'] == 'testBool') $setting['value'] = ($setting['value'] === true ? 'true' : 'false');
|
||||
if ($setting['type'] == 'boolean') $setting['value'] = ($setting['value'] === true ? 'true' : 'false');
|
||||
if (isset($setting['options'])) $setting['value'] = ($setting['options'][$setting['value']]);
|
||||
?>
|
||||
<tr>
|
||||
<td class="short" style="<?php echo $bgColour; ?>"><?php echo h($priorities[$setting['level']]);?></td>
|
||||
<td class="short" style="<?php echo $bgColour; ?>"><?php echo h($setting['setting']);?></td>
|
||||
<?php if (isset($setting['editable']) && !$setting['editable']): ?>
|
||||
<?php if ((isset($setting['editable']) && !$setting['editable']) || $setting['level'] == 3): ?>
|
||||
<td id="setting_<?php echo $k; ?>_passive" class="short inline-field-solid" style="<?php echo $bgColour; ?>width:300px;"><?php echo h($setting['value']);?></td>
|
||||
<?php else: ?>
|
||||
<td id="setting_<?php echo $k; ?>_solid" class="short inline-field-solid" onClick="serverSettingsActivateField('<?php echo $setting['setting'];?>', '<?php echo $k;?>')" style="<?php echo $bgColour; ?>width:300px;"><?php echo h($setting['value']);?></td>
|
||||
<td id="setting_<?php echo $k; ?>_placeholder" class="short hidden inline-field-placeholder" style="<?php echo $bgColour; ?>width:300px;"></td>
|
||||
<?php endif; ?>
|
||||
<td style="<?php echo $bgColour; ?>"><?php echo h($setting['description']);?></td>
|
||||
<td class="short" style="<?php echo $bgColour; ?>"><?php if (isset($setting['error']) && $setting['level'] != 3) echo h($setting['errorMessage']); ?></td>
|
||||
<td style="<?php echo $bgColour; ?>"><?php if (isset($setting['error']) && $setting['level'] != 3) echo h($setting['errorMessage']); ?></td>
|
||||
<td class="short" style="<?php echo $bgColour; ?>"></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
|
@ -5,21 +5,31 @@
|
|||
<div class="inline-input-accept inline-input-button inline-input-passive"><span class = "icon-ok"></span></div>
|
||||
<div class="inline-input-decline inline-input-button inline-input-passive"><span class = "icon-remove"></span></div>
|
||||
<?php
|
||||
if ($setting['test'] != 'testBool') {
|
||||
if (isset($setting['options'])) {
|
||||
echo $this->Form->input('value', array(
|
||||
'label' => false,
|
||||
'options' => $setting['options'],
|
||||
'value' => $setting['value'],
|
||||
'class' => 'inline-input',
|
||||
'id' => 'setting_' . $id . '_field',
|
||||
'div' => false
|
||||
));
|
||||
|
||||
} else if ($setting['type'] == 'boolean') {
|
||||
echo $this->Form->input('value', array(
|
||||
'type' => 'text',
|
||||
'label' => false,
|
||||
'options' => array(false => 'false', true => 'true'),
|
||||
'value' => $setting['value'],
|
||||
'error' => array('escape' => false),
|
||||
'class' => 'inline-input',
|
||||
'id' => 'setting_' . $id . '_field',
|
||||
'div' => false
|
||||
));
|
||||
} else {
|
||||
echo $this->Form->input('value', array(
|
||||
'type' => 'text',
|
||||
'label' => false,
|
||||
'options' => array(false => 'false', true => 'true'),
|
||||
'value' => $setting['value'],
|
||||
'error' => array('escape' => false),
|
||||
'class' => 'inline-input',
|
||||
'id' => 'setting_' . $id . '_field',
|
||||
'div' => false
|
||||
|
|
Loading…
Reference in New Issue