From c2d8b383c3c215f79c54bfaaaf90be46864fce7a Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 2 Apr 2025 08:04:56 +0200 Subject: [PATCH] support saving via ajax --- op/op.Settings.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/op/op.Settings.php b/op/op.Settings.php index db2432ad6..c72aaa84b 100644 --- a/op/op.Settings.php +++ b/op/op.Settings.php @@ -321,15 +321,21 @@ if ($action == "saveSettings") // ------------------------------------------------------------------------- // save // ------------------------------------------------------------------------- - if (!$settings->save()) - UI::exitError(getMLText("admin_tools"),getMLText("settings_SaveError")); + if (!$settings->save()) { + if(isAjax()) { + echo json_encode(array('success'=>false, 'msg'=>getMLText('settings_SaveError'))); + exit; + } else { + UI::exitError(getMLText("admin_tools"),getMLText("settings_SaveError")); + } + } add_log_line(".php&action=savesettings"); } -$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_settings_saved'))); - - -header("Location:../out/out.Settings.php?currenttab=".$_POST['currenttab']); - -?> +if(isAjax()) { + echo json_encode(array('success'=>true, 'msg'=>getMLText('splash_settings_saved'))); +} else { + $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_settings_saved'))); + header("Location:../out/out.Settings.php?currenttab=".$_POST['currenttab']); +}