diff --git a/admin/pages/settings.php b/admin/pages/settings.php index 53e5779e..e5eae974 100644 --- a/admin/pages/settings.php +++ b/admin/pages/settings.php @@ -11,14 +11,20 @@ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Settings'; require_once SYSTEM . 'clients.conf.php'; -if (!isset($_GET['plugin']) || empty($_GET['plugin'])) { - error('Please select plugin name from left Panel.'); +if (empty($_GET['plugin'])) { + error('Please select plugin from left Panel.'); return; } $plugin = $_GET['plugin']; if($plugin != 'core') { + $pluginSettings = Plugins::getPluginSettings($plugin); + if (!$pluginSettings) { + error('This plugin does not exist or does not have options defined.'); + return; + } + $settingsFilePath = PLUGINS . $plugin . '/settings.php'; } else { @@ -58,7 +64,7 @@ if (isset($_POST['save'])) { success('Saved at ' . date('H:i')); } -$title = ($plugin == 'core' ? 'MyAAC Settings' : 'Plugin Settings - ' . $plugin); +$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $plugin); $query = 'SELECT `key`, `value` FROM `' . TABLE_PREFIX . 'settings` WHERE `plugin_name` = ' . $db->quote($plugin) . ';'; $query = $db->query($query); @@ -79,16 +85,43 @@ if($query->rowCount() > 0) {
- + +
+ ' . ($type ? 'Yes' : 'No') . ' '; }; $i = 0; + $j = 0; foreach($settingsFile as $key => $setting) { - if($setting['type'] === 'section') { - if($i++ !== 0) { + if ($setting['type'] === 'category') { + if ($j++ !== 0) { + echo '
'; + } + ?> +
+ '; } ?> @@ -120,7 +153,7 @@ if($query->rowCount() > 0) { } } else { - $value = (isset($setting['default']) ? $setting['default'] : false); + $value = ($setting['default'] ?? false); } $checkbox($key, true, $value); @@ -128,11 +161,11 @@ if($query->rowCount() > 0) { } else if (in_array($setting['type'], ['text', 'number', 'email', 'password'])) { - echo ''; + echo ''; } else if($setting['type'] === 'textarea') { - echo ''; + echo ''; } if ($setting['type'] === 'options') { @@ -159,6 +192,15 @@ if($query->rowCount() > 0) { $setting['options'] = $clients; } + else { + if (is_string($setting['options'])) { + $setting['options'] = explode(',', $setting['options']); + foreach ($setting['options'] as &$option) { + $option = trim($option); + } + } + } + echo '