Integraatiot: checkboxit vain päälle/pois Yrityksissä, kaikki asetukset API-tabissa
- Yritykset-tab: integraatio-checkboxit tallentavat vain enabled-tilan - API-tab: Zammad/Saatavuus/Telegram kortit näkyvät kun integraatio päällä - Zammad-asetukset (URL, token, ryhmät, synkronointi) kokonaan API-tabissa - integration_save: tyhjä config ei ylikirjoita olemassaolevia asetuksia Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
17
api.php
17
api.php
@@ -4990,14 +4990,19 @@ switch ($action) {
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$type = $input['type'] ?? '';
|
||||
$enabled = (bool)($input['enabled'] ?? false);
|
||||
$config = $input['config'] ?? [];
|
||||
$config = $input['config'] ?? null;
|
||||
if (!$type) { http_response_code(400); echo json_encode(['error' => 'Tyyppi puuttuu']); break; }
|
||||
|
||||
// Jos token on maskattua (********), säilytä vanha
|
||||
if (isset($config['token']) && preg_match('/^\*+$/', $config['token'])) {
|
||||
$old = dbGetIntegration($companyId, $type);
|
||||
if ($old && isset($old['config']['token'])) {
|
||||
$config['token'] = $old['config']['token'];
|
||||
// Jos config ei lähetetty tai on tyhjä, säilytä vanha config (toggle ei ylikirjoita asetuksia)
|
||||
$old = dbGetIntegration($companyId, $type);
|
||||
if ($config === null || (is_array($config) && empty($config))) {
|
||||
$config = ($old && isset($old['config'])) ? (is_string($old['config']) ? json_decode($old['config'], true) : $old['config']) : [];
|
||||
} else {
|
||||
// Jos token on maskattua (********), säilytä vanha
|
||||
if (isset($config['token']) && preg_match('/^\*+$/', $config['token'])) {
|
||||
if ($old && isset($old['config']['token'])) {
|
||||
$config['token'] = is_string($old['config']) ? json_decode($old['config'], true)['token'] : $old['config']['token'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user