summaryrefslogtreecommitdiffstats
path: root/modules-available/baseconfig
diff options
context:
space:
mode:
authorSimon Rettberg2016-05-17 18:14:13 +0200
committerSimon Rettberg2016-05-17 18:14:13 +0200
commit8e729913a8f6258762f4e8049caebc9dbb42a71e (patch)
tree48b1d27787847c012994248e32f5a79695221218 /modules-available/baseconfig
parentGet baseconfig ready for modularization (diff)
downloadslx-admin-8e729913a8f6258762f4e8049caebc9dbb42a71e.tar.gz
slx-admin-8e729913a8f6258762f4e8049caebc9dbb42a71e.tar.xz
slx-admin-8e729913a8f6258762f4e8049caebc9dbb42a71e.zip
Modularized baseconfig fetching (api)
Diffstat (limited to 'modules-available/baseconfig')
-rw-r--r--modules-available/baseconfig/api.inc.php69
-rw-r--r--modules-available/baseconfig/inc/baseconfigutil.inc.php18
-rw-r--r--modules-available/baseconfig/lang/de/config-variable-categories.json9
-rw-r--r--modules-available/baseconfig/lang/de/config-variables.json23
-rw-r--r--modules-available/baseconfig/lang/en/config-variable-categories.json8
-rw-r--r--modules-available/baseconfig/lang/en/config-variables.json23
-rw-r--r--modules-available/baseconfig/lang/pt/config-variable-categories.json7
-rw-r--r--modules-available/baseconfig/lang/pt/config-variables.json16
-rw-r--r--modules-available/baseconfig/page.inc.php27
9 files changed, 97 insertions, 103 deletions
diff --git a/modules-available/baseconfig/api.inc.php b/modules-available/baseconfig/api.inc.php
new file mode 100644
index 00000000..c692a0b2
--- /dev/null
+++ b/modules-available/baseconfig/api.inc.php
@@ -0,0 +1,69 @@
+<?php
+
+$ip = $_SERVER['REMOTE_ADDR'];
+if (substr($ip, 0, 7) === '::ffff:') {
+ $ip = substr($ip, 7);
+}
+
+// TODO: Handle UUID in appropriate modules (optional)
+$uuid = Request::post('uuid', '', 'string');
+if (strlen($uuid) !== 36) {
+ // Probably invalid UUID. What to do? Set empty or ignore?
+}
+
+/**
+ * Escape given string so it is a valid string in sh that can be surrounded
+ * by single quotes ('). This basically turns _'_ into _'"'"'_
+ *
+ * @param string $string input
+ * @return string escaped sh string
+ */
+function escape($string)
+{
+ return str_replace("'", "'\"'\"'", $string);
+}
+
+/*
+ * We gather all config variables here. First, let other modules generate
+ * their desired config vars. Afterwards, add the global config vars from
+ * db. If a variable is already set, it will not be overridden by the
+ * global setting.
+ */
+
+$configVars = array();
+
+// Handle any hooks by other modules first
+// other modules should generally only populate $configVars
+foreach (glob('modules/*/baseconfig/getconfig.inc.php') as $file) {
+ preg_match('#^modules/([^/]+)/#', $file, $out);
+ if (!Module::isAvailable($out[1]))
+ continue;
+ include $file;
+}
+
+// Rest is handled by module
+$defaults = BaseConfigUtil::getVariables();
+
+// Dump global config from DB
+$res = Database::simpleQuery('SELECT setting, value FROM setting_global'); // TODO: Add setting groups and sort order
+while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ if (isset($configVars[$row['setting']]) || !isset($defaults[$row['setting']]))
+ continue;
+ $configVars[$row['setting']] = $row['value'];
+}
+
+// Fallback to default values from json files
+foreach ($defaults as $setting => $value) {
+ if (isset($configVars[$setting]))
+ continue;
+ $configVars[$setting] = $value;
+}
+
+// Finally, output what we gathered
+foreach ($configVars as $setting => $value) {
+ echo $setting, "='", escape($value), "'\n";
+}
+
+// For quick testing or custom extensions: Include external file that should do nothing
+// more than outputting more key-value-pairs. It's expected in the webroot of slxadmin
+if (file_exists('client_config_additional.php')) @include('client_config_additional.php');
diff --git a/modules-available/baseconfig/inc/baseconfigutil.inc.php b/modules-available/baseconfig/inc/baseconfigutil.inc.php
index 33875156..ebaefbcf 100644
--- a/modules-available/baseconfig/inc/baseconfigutil.inc.php
+++ b/modules-available/baseconfig/inc/baseconfigutil.inc.php
@@ -20,9 +20,13 @@ class BaseConfigUtil
$settings = array();
foreach (glob('modules/*/baseconfig/settings.json', GLOB_NOSORT) as $file) {
$data = json_decode(file_get_contents($file), true);
- if (is_array($data)) {
- $settings += $data;
+ if (!is_array($data))
+ continue;
+ preg_match('#^modules/([^/]+)/#', $file, $out);
+ foreach ($data as &$entry) {
+ $entry['module'] = $out[1];
}
+ $settings += $data;
}
return $settings;
}
@@ -32,11 +36,15 @@ class BaseConfigUtil
$categories = array();
foreach (glob('modules/*/baseconfig/categories.json', GLOB_NOSORT) as $file) {
$data = json_decode(file_get_contents($file), true);
- if (is_array($data)) {
- $categories += $data;
+ if (!is_array($data))
+ continue;
+ preg_match('#^modules/([^/]+)/#', $file, $out);
+ foreach ($data as &$entry) {
+ $entry = array('module' => $out[1], 'sortpos' => $entry);
}
+ $categories += $data;
}
return $categories;
}
-} \ No newline at end of file
+}
diff --git a/modules-available/baseconfig/lang/de/config-variable-categories.json b/modules-available/baseconfig/lang/de/config-variable-categories.json
deleted file mode 100644
index d8d7e91f..00000000
--- a/modules-available/baseconfig/lang/de/config-variable-categories.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "cat_5": "Gemeinsames Netzlaufwerk",
- "networking": "Netzwerk-\/Internetzugriff",
- "other": "Unkategorisiert",
- "power": "Inaktivit\u00e4t und Abschaltung",
- "sysconfig": "Grundsystem",
- "timesync": "Zeitsynchronisation",
- "vmchooser": "vmChooser"
-} \ No newline at end of file
diff --git a/modules-available/baseconfig/lang/de/config-variables.json b/modules-available/baseconfig/lang/de/config-variables.json
deleted file mode 100644
index af1007be..00000000
--- a/modules-available/baseconfig/lang/de/config-variables.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "SLX_ADDONS": "Zu ladende Addons. Zur Zeit steht nur *vmware* zur Verf\u00fcgung.",
- "SLX_BENCHMARK_VM": "Tragen Sie hier den exakten Namen einer Veranstaltung, wie sie im *vmchooser* auftaucht ein, um diese VM nach dem Booten automatisch zu starten. Dies ist n\u00fctzlich f\u00fcr Bootzeitmessungen. Feld leer lassen, um Funktion zu deaktivieren.",
- "SLX_BIOS_CLOCK": "Legt fest, ob und wie die interne Uhr des Rechners im Bezug auf die Systemzeit des \/MiniLinux\/ gesetzt werden soll.\r\n*off* = Die interne Uhr des Rechners wird nicht ver\u00e4ndert.\r\n*local* = Die interne Uhr wird auf die Lokalzeit gesetzt. Bevorzugt wenn z.B. noch eine native Windows-Installation auf dem PC vorhanden ist.\r\n*utc* = Die interne Uhr wird auf die \/Koordinierte Weltzeit\/ gesetzt. Dies ist die g\u00e4ngige Einstellung in einem reinen Linux-Umfeld.",
- "SLX_COMMON_SHARE_AUTH": "Authentifizierungsmethode f\u00fcr das gemeinsame Netzlaufwerk. *guest* bedeutet, dass keine Authentifizierung notwendig ist, *user* bedeutet, dass die Credentials des angemeldeten Benutzers verwendet werden.",
- "SLX_COMMON_SHARE_PATH": "Netzwerkpfad des gemeinsamen Netzlaufwerks. Es werden NFS (keine Authentifizierung) und CIFS\/SMB (mit und ohne Authentifizierung) unterst\u00fctzt.",
- "SLX_DEMO_PASS": "Passwort f\u00fcr den eingebauten *demo*-Account. Leer lassen, um das Einloggen zu verbieten.\r\nDas Passwort wird wie das root-Passwort nur gehasht an den Client \u00fcbertragen.",
- "SLX_LOGOUT_TIMEOUT": "Zeit \/in Sekunden\/, die eine Benutzersitzung ohne Aktion sein darf, bevor sie beendet wird.Feld leer lassen, um die Funktion zu deaktivieren.",
- "SLX_NET_DOMAIN": "DNS-Dom\u00e4ne, in die sich die Clients eingliedern, sofern der DHCP Server keine solche vorgibt.",
- "SLX_NTP_SERVER": "Adresse des NTP-Zeitservers. Es k\u00f6nnen mehrere Server mit Leerzeichen getrennt angegeben werden.Die Server werden der Reihe nach angefragt, bis ein antwortender Server gefunden wird.",
- "SLX_PROXY_BLACKLIST": "Adressen bzw. Adressbereiche, f\u00fcr die der Proxyserver nicht verwendet werden soll (z.B. der Adressbereich der Einrichtung). G\u00fcltige Angaben sind einzelne IP-Adressen, sowie IP-Bereiche in CIDR-Notation (z.B. 1.2.0.0\/16). Mehrere Angaben k\u00f6nnen durch Leerzeichen getrennt werden.",
- "SLX_PROXY_IP": "Die Adresse des zu verwendenden Proxy Servers.",
- "SLX_PROXY_MODE": "Legt fest, ob zum Zugriff aufs Internet ein Proxy-Server ben\u00f6tigt wird.\r\n*off* = keinen Proxy benutzen.\r\n*on* = Proxy immer benutzen.\r\n*auto* = Proxy nur benutzen, wenn sich der Client-PC in einem privaten Adressbereich befindet.",
- "SLX_PROXY_PORT": "Der Port des zu verwendenden Proxy Servers.",
- "SLX_PROXY_TYPE": "Art des Proxys: *socks4*, *socks5*, *http-connect* (HTTP Proxy mit Unterst\u00fctzung der CONNECT-Methode), *http-relay* (Klassischer HTTP Proxy)",
- "SLX_REMOTE_LOG_SESSIONS": "Legt fest, ob Logins und Logouts der Benutzer an den Satelliten gemeldet werden sollen.\r\n*yes* = Mit Benutzerkennung loggen\r\n*anonymous* = Anonym loggen\r\n*no* = Nicht loggen",
- "SLX_ROOT_PASS": "Das root-Passwort des Grundsystems. Wird nur f\u00fcr Diagnosezwecke am Client ben\u00f6tigt.\r\nFeld leer lassen, um root-Logins zu verbieten.\r\n\/Hinweis\/: Das Passwort wird im Klartext in der lokalen Datenbank hinterlegt, jedoch immer gehasht an die Clients \u00fcbermittelt (SHA-512 mit Salt). Wenn Sie das Passwort auch im Satelliten nicht im Klartext speichern wollen, k\u00f6nnen Sie hier auch ein vorgehashtes Passwort eintragen (im *$6$....*-Format).",
- "SLX_SHUTDOWN_SCHEDULE": "Feste Uhrzeit, zu der sich die Rechner ausschalten, auch wenn noch ein Benutzer aktiv ist.Mehrere Zeitpunkte k\u00f6nnen durch Leerzeichen getrennt angegeben werden.",
- "SLX_SHUTDOWN_TIMEOUT": "Zeit in Sekunden, nach dem ein Rechner abgeschaltet wird, sofern kein Benutzer angemeldet ist.Feld leer lassen, um die Funktion zu deaktivieren.",
- "SLX_VMCHOOSER_FORLOCATION": "Legt das Verhalten fest, wenn es Veranstaltungen gibt, die an einen bestimmten Ort\/Raum gebunden sind.\r\n*IGNORE*: Mit den restlichen, globalen Veranstaltungen alphabetisch sortiert auflisten.\r\n*BUMP*: Die spezifischen Veranstaltungen oben auflisten, die globalen darunter.\r\n*EXCLUSIVE*: Spezifische Veranstaltungen oben auflisten, globale Veranstaltungen zun\u00e4chst ausblenden. Die globalen Veranstaltungen befinden sich unter einem eingeklappten Listenknoten.",
- "SLX_VMCHOOSER_TAB": "Bestimmt, welcher Karteireiter im vmchooser standardm\u00e4\u00dfig ausgew\u00e4hlt wird.\r\n*0*: Native Linux-Sessions\r\n*1*: Nutzerspezifische Kurse\r\n*2*: Alle Kurse\r\n*AUTO*: Hat der Rechner beschr\u00e4nkte Ressourcen, werden die Linux-Sitzungen angezeigt, sonst alle Kurse\r\n\r\nHat der Benutzer ein persistentes Home-Verzeichnis, wirkt sich diese Einstellung nur beim ersten Anmelden aus. Bei sp\u00e4teren Sitzungen markiert der vmchooser die zuletzt gestartete Sitzung und wechselt zum entsprechenden Karteireiter.",
- "SLX_VMCHOOSER_TEMPLATES": "Legt fest, wie Veranstaltungen in der Sortierung behandelt werden, welche auf eine VM linken, die eine Vorlage ist.\r\n*IGNORE*: Wie regul\u00e4re Veranstaltungen behandeln\r\n*BUMP*: Weiter oben in der Liste einsortieren"
-} \ No newline at end of file
diff --git a/modules-available/baseconfig/lang/en/config-variable-categories.json b/modules-available/baseconfig/lang/en/config-variable-categories.json
deleted file mode 100644
index f0324e6b..00000000
--- a/modules-available/baseconfig/lang/en/config-variable-categories.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "networking": "Internet Access",
- "other": "Uncategorized",
- "power": "Inactivity and Shutdown",
- "sysconfig": "Basic System",
- "timesync": "Time Synchronization",
- "vmchooser": "vmChooser"
-} \ No newline at end of file
diff --git a/modules-available/baseconfig/lang/en/config-variables.json b/modules-available/baseconfig/lang/en/config-variables.json
deleted file mode 100644
index 36ac6e8c..00000000
--- a/modules-available/baseconfig/lang/en/config-variables.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "SLX_ADDONS": "Addons to load. Currently, only *vmware* is available.",
- "SLX_BENCHMARK_VM": "If non-empty, this should be the exact display name of an entry in *vmchooser*, so it will be automatically started after bootup. Useful for benchmarking.",
- "SLX_BIOS_CLOCK": "Specifies whether and how the internal clock of the computer should be set in relation to the system time of the \/MiniLinux\/.\r\n*off* = The internal clock of the computer is not changed.\r\n*local* = The internal clock is set to local time. Preferably if, for example, there is still a native Windows installation available on the PC.\r\n*utc* = The internal clock is set to the \/Coordinated Universal Time\/. This is the most common setup in a pure Linux environment.",
- "SLX_COMMON_SHARE_AUTH": "Athentication method for the common network share. *guest* means no authentication (public share), *user* means the user's credentials will be used.",
- "SLX_COMMON_SHARE_PATH": "Path of network share. Supported are NFS (no authentication only) and CIFS\/SMB (with and without authentication).",
- "SLX_DEMO_PASS": "Password for the *demo* account. Leave empty to disallow logging in as the demo user.\r\nLike the root password, the demo user's password will be sent to the client in its hashed form.",
- "SLX_LOGOUT_TIMEOUT": "Time \/in seconds\/, in which a user session may remain without action before it is terminated.Leave field blank to disable the function.",
- "SLX_NET_DOMAIN": "DNS domain in which the client integrate, provided the DHCP server does not specifies such.",
- "SLX_NTP_SERVER": "Address of the NTP time server. Multiple servers can be specified separated by spaces.The servers are queried in sequence until a responding server is found.",
- "SLX_PROXY_BLACKLIST": "Address or addresses ranges in which the proxy server is not used (for example the address range of the device). Valid entries are individual IP addresses and IP ranges in CIDR notation (for example 1.2.0.0\/16). Multiple selections can be separated by spaces.",
- "SLX_PROXY_IP": "The address to use for the proxy server.",
- "SLX_PROXY_MODE": "Determines whether a proxy server is required to access the Internet.\r\n*off* = do not use a Proxy.\r\n*on* = Always use proxy.\r\n*auto* = Only use proxy when the client PC is in a private address space.",
- "SLX_PROXY_PORT": "The port to use for the proxy server.",
- "SLX_PROXY_TYPE": "Type of the proxy.*socks4*, *socks5*, *http-connect* (HTTP proxy with support from the CONNECT method), *http-relay* (Classic HTTP proxy)",
- "SLX_REMOTE_LOG_SESSIONS": "Determines whether logins and logouts of the users should be reported to the satellite.\r\n*yes* = log with user ID\r\n*anonymous* = anonymous logging\r\n*no* = no logging",
- "SLX_ROOT_PASS": "The root password of the client system. Only required for diagnostic purposes on the client.Leave field blank to disallow root logins.\r\n\/Hint\/: The password SHA-512-with-salt hashed before it's being sent to the client. It's only stored in clear text on the Satellite Server. If you want to have it hashed on the server too, you can supply a pre-hashed passoword in \/$6$...$...\/-format.",
- "SLX_SHUTDOWN_SCHEDULE": "Fixed time to turn off the computer, even if there is a user active.Several times can be specified, separated by spaces.",
- "SLX_SHUTDOWN_TIMEOUT": "Time in seconds after which a computer is switched off, if no user is logged on.Leave blank to disable the function.",
- "SLX_VMCHOOSER_FORLOCATION": "Defines how lectures special to the user's location are handled in the vmchooser.\r\n*IGNORE*: Sort them alphabetically among the global lectures.\r\n*BUMP*: Put them atop the global lectures.\r\n*EXCLUSIVE*: Put them atop the global lectures and aditionally collapse the node which contains the global lectures.",
- "SLX_VMCHOOSER_TAB": "Defines which tab is show by default, if the user doesn't have stored a last used session on his persistent home directory.\r\n*0*: Native Linux sessions\r\n*1*: User specific lectures\r\n*2*: All lectures\r\n*AUTO*: If the computer has low system specs, show the Linux sessions, otherwise, show all lectures",
- "SLX_VMCHOOSER_TEMPLATES": "Defines how lectures that link to template VMs are treated wrt sorting.\r\n*IGNORE*: Sort among regular lectures\r\n*BUMP*: Move to top of list"
-} \ No newline at end of file
diff --git a/modules-available/baseconfig/lang/pt/config-variable-categories.json b/modules-available/baseconfig/lang/pt/config-variable-categories.json
deleted file mode 100644
index 99819f51..00000000
--- a/modules-available/baseconfig/lang/pt/config-variable-categories.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "networking": "Acesso \u00e0 Internet",
- "power": "Inatividade e Desligamento",
- "sysconfig": "Sistema B\u00e1sico",
- "timesync": "Sincroniza\u00e7\u00e3o de Tempo",
- "vmchooser": "vmchooser"
-} \ No newline at end of file
diff --git a/modules-available/baseconfig/lang/pt/config-variables.json b/modules-available/baseconfig/lang/pt/config-variables.json
deleted file mode 100644
index 66ec3b1c..00000000
--- a/modules-available/baseconfig/lang/pt/config-variables.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "SLX_ADDONS": "Para carregar addons. Atualmente apenas o vmware est\u00e1 dispon\u00edvel.",
- "SLX_BIOS_CLOCK": "Especifica se e como o rel\u00f3gio interno do computador deve ser definido em rela\u00e7\u00e3o ao hor\u00e1rio do sistema do \/MiniLinux\/.*off* = O rel\u00f3gio interno do computador n\u00e3o \u00e9 alterado.*local* = O rel\u00f3gio interno est\u00e1 definido para a hora local. De prefer\u00eancia se, por exemplo, ainda existe uma instala\u00e7\u00e3o Windows nativo dispon\u00edvel no PC.*utc* = O rel\u00f3gio interno \u00e9 definido para o \/Tempo Universal Coordenado\/. Esta \u00e9 a configura\u00e7\u00e3o mais comum em um ambiente puramente Linux",
- "SLX_LOGOUT_TIMEOUT": "Hora \/em segundos\/, em que uma sess\u00e3o de usu\u00e1rio pode permanecer sem a\u00e7\u00e3o antes de ser encerrada.Deixe o campo em branco para desativar a fun\u00e7\u00e3o.",
- "SLX_NET_DOMAIN": "Dom\u00ednio DNS no qual o cliente se integra, desde que o servidor DHCP n\u00e3o especifique tal.",
- "SLX_NTP_SERVER": "Endere\u00e7o do servidor de hor\u00e1rio NTP. V\u00e1rios servidores podem ser especificados separados por espa\u00e7os.Os servidores s\u00e3o consultados em seq\u00fc\u00eancia at\u00e9 que um servidor respondendo for encontrado.",
- "SLX_PROXY_BLACKLIST": "Intervalos de endere\u00e7os em que o servidor proxy n\u00e3o \u00e9 usado (por exemplo, o intervalo de endere\u00e7o do dispositivo). As entradas v\u00e1lidas s\u00e3o endere\u00e7os IP individuais e intervalos de IP em nota\u00e7\u00e3o CIDR (por exemplo 1.2.0.0\/16). Sele\u00e7\u00f5es m\u00faltiplas podem ser separadas por espa\u00e7os.",
- "SLX_PROXY_IP": "O endere\u00e7o de servidor proxy a ser usado.",
- "SLX_PROXY_MODE": "Determina se um servidor proxy \u00e9 necess\u00e1rio para acessar a Internet.*off* = n\u00e3o utilizar proxy.*on* = sempre utilizar proxy.*auto* = apenas utilizar proxy quando o PC cliente estiver em um espa\u00e7o de endere\u00e7o privado.",
- "SLX_PROXY_PORT": "A porta a ser utilizada pelo servidor proxy.",
- "SLX_PROXY_TYPE": "Tipo do proxy.*socks4*, *socks5*,*http-connect* (Proxy HTTP com suporte ao m\u00e9todo CONNECT),*http-relay* (Cl\u00e1ssico proxy HTTP)",
- "SLX_REMOTE_LOG_SESSIONS": "Determina se logins e logouts dos usu\u00e1rios devem ser reportados ao sat\u00e9lite.*yes* = Login com ID de usu\u00e1rio*anonymous* = login an\u00f4nimo*no* = sem login",
- "SLX_ROOT_PASS": "A senha root do sistema base. Exigido somente para fins de diagn\u00f3stico no cliente.Deixar campo em branco para n\u00e3o permitir login com root.\/Dica\/: A senha \u00e9 criptografada com hash $6$, ent\u00e3o se torna ileg\u00edvel ap\u00f3s ser salva!",
- "SLX_SHUTDOWN_SCHEDULE": "Hor\u00e1rio fixo para desligar o computador, at\u00e9 mesmo caso tenha um usu\u00e1rio ativo.M\u00faltiplos hor\u00e1rios podem ser especificados, separados por espa\u00e7os.",
- "SLX_SHUTDOWN_TIMEOUT": "Tempo em segundos no qual um computador \u00e9 desligado, caso n\u00e3o tenha um usu\u00e1rio logado.Deixar em branco para desabilitar a fun\u00e7\u00e3o."
-} \ No newline at end of file
diff --git a/modules-available/baseconfig/page.inc.php b/modules-available/baseconfig/page.inc.php
index 5e209f4e..21b5459b 100644
--- a/modules-available/baseconfig/page.inc.php
+++ b/modules-available/baseconfig/page.inc.php
@@ -90,7 +90,7 @@ class Page_BaseConfig extends Page
Message::addError('main.no-permission');
Util::redirect('?do=Main');
}
- // Check if valid submodule mode, stire name if any
+ // Check if valid submodule mode, store name if any
if ($this->targetModule !== false) {
$this->qry_extra['subheading'] = $this->getCurrentModuleName();
if ($this->qry_extra['subheading'] === false) {
@@ -111,7 +111,7 @@ class Page_BaseConfig extends Page
$params = array();
}
// Populate structure with existing config from db
- $res = Database::simpleQuery("SELECT setting, displayvalue FROM {$this->qry_extra['table']} "
+ $res = Database::simpleQuery("SELECT setting, value, displayvalue FROM {$this->qry_extra['table']} "
. " {$where} ORDER BY setting ASC", $params);
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
if (!isset($vars[$row['setting']]) || !is_array($vars[$row['setting']])) {
@@ -119,9 +119,9 @@ class Page_BaseConfig extends Page
continue;
}
$row += $vars[$row['setting']];
- $row['description'] = Util::markup(Dictionary::translateFile('config-variables', $row['setting']));
- if (is_null($row['displayvalue'])) $row['displayvalue'] = $row['defaultvalue'];
- $row['item'] = $this->makeInput($row['validator'], $row['setting'], $row['displayvalue']);
+ if (is_null($row['displayvalue'])) {
+ $row['displayvalue'] = $row['defaultvalue'];
+ }
if (!isset($row['catid'])) {
$row['catid'] = 'unknown';
}
@@ -132,20 +132,23 @@ class Page_BaseConfig extends Page
if (isset($settings[$var['catid']]['settings'][$key])) {
// Value is set in DB
$settings[$var['catid']]['settings'][$key]['checked'] = 'checked';
- continue;
+ } else {
+ // Value is not set in DB
+ $settings[$var['catid']]['settings'][$key] = $var + array(
+ 'setting' => $key
+ );
}
- // Value is not set in DB
- $settings[$var['catid']]['settings'][$key] = $var + array(
- 'setting' => $key,
- 'item' => $this->makeInput($var['validator'], $key, $var['defaultvalue'])
+ $settings[$var['catid']]['settings'][$key] += array(
+ 'item' => $this->makeInput($var['validator'], $key, $var['defaultvalue']),
+ 'description' => Util::markup(Dictionary::translateFileModule($var['module'], 'config-variables', $key))
);
}
// Sort categories
$sortvals = array();
foreach ($settings as $catid => &$setting) {
- $sortvals[] = isset($cats[$catid]) ? (int)$cats[$catid] : 99999;
+ $sortvals[] = isset($cats[$catid]) ? (int)$cats[$catid]['sortpos'] : 99999;
$setting['category_id'] = $catid;
- $setting['category_name'] = Dictionary::translateFile('config-variable-categories', 'cat_' . $catid);
+ $setting['category_name'] = Dictionary::translateFileModule($cats[$catid]['module'], 'config-variable-categories', $catid);
if ($setting['category_name'] === false) {
$setting['category_name'] = $catid;
}