Skip to content

Commit

Permalink
Adjust conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
jrauh01 committed Nov 20, 2024
1 parent 538122d commit b7d2590
Showing 1 changed file with 42 additions and 42 deletions.
84 changes: 42 additions & 42 deletions application/controllers/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,52 +220,52 @@ public function prometheusAction()
$data[$pair->key] = ['value' => $pair->value, 'locked' => $pair->locked];
}

if ($data[self::PROMETHEUS_URL]['locked'] !== 'y') {
if (isset($data[self::PROMETHEUS_URL])) {
$db->update('config',
['value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_URL))],
[$db->quoteIdentifier('key') . ' = ?' => self::PROMETHEUS_URL]
);
} else {
$db->insert('config',
[
$db->quoteIdentifier('key') => self::PROMETHEUS_URL,
'value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_URL))
]
);
}
if (isset($data[self::PROMETHEUS_URL]) && $data[self::PROMETHEUS_URL]['locked'] !== 'y') {
$db->update(
'config',
['value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_URL))],
[$db->quoteIdentifier('key') . ' = ?' => self::PROMETHEUS_URL]
);
} else if (! isset($data[self::PROMETHEUS_URL])) {
$db->insert(
'config',
[
$db->quoteIdentifier('key') => self::PROMETHEUS_URL,
'value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_URL))
]
);
}

if ($data[self::PROMETHEUS_USERNAME]['locked'] !== 'y') {
if (isset($data[self::PROMETHEUS_USERNAME])) {
$db->update('config',
['value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_USERNAME))],
[$db->quoteIdentifier('key') . ' = ?' => self::PROMETHEUS_USERNAME]
);
} else {
$db->insert('config',
[
$db->quoteIdentifier('key') => self::PROMETHEUS_USERNAME,
'value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_USERNAME))
]
);
}
if (isset($data[self::PROMETHEUS_USERNAME]) && $data[self::PROMETHEUS_USERNAME]['locked'] !== 'y') {
$db->update(
'config',
['value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_USERNAME))],
[$db->quoteIdentifier('key') . ' = ?' => self::PROMETHEUS_USERNAME]
);
} else if (! isset($data[self::PROMETHEUS_USERNAME])) {
$db->insert(
'config',
[
$db->quoteIdentifier('key') => self::PROMETHEUS_USERNAME,
'value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_USERNAME))
]
);
}

if ($data[self::PROMETHEUS_PASSWORD]['locked'] !== 'y') {
if (isset($data[self::PROMETHEUS_PASSWORD])) {
$db->update('config',
['value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_PASSWORD))],
[$db->quoteIdentifier('key') . ' = ?' => self::PROMETHEUS_PASSWORD]
);
} else {
$db->insert('config',
[
$db->quoteIdentifier('key') => self::PROMETHEUS_PASSWORD,
'value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_PASSWORD))
]
);
}
if (isset($data[self::PROMETHEUS_PASSWORD]) && $data[self::PROMETHEUS_PASSWORD]['locked'] !== 'y') {
$db->update(
'config',
['value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_PASSWORD))],
[$db->quoteIdentifier('key') . ' = ?' => self::PROMETHEUS_PASSWORD]
);
} else if (! isset($data[self::PROMETHEUS_PASSWORD])) {
$db->insert(
'config',
[
$db->quoteIdentifier('key') => self::PROMETHEUS_PASSWORD,
'value' => $form->getValue($this->fieldForForm(self::PROMETHEUS_PASSWORD))
]
);
}

$db->commitTransaction();
Expand Down

0 comments on commit b7d2590

Please sign in to comment.