From f42cb70e4f39bc91516259dde966ae7c5b114b02 Mon Sep 17 00:00:00 2001 From: Zack Spear Date: Fri, 2 Feb 2024 15:05:00 -0800 Subject: [PATCH] fix: State class for usage in other files --- .../dynamix.my.servers/include/state.php | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/emhttp/plugins/dynamix.my.servers/include/state.php b/emhttp/plugins/dynamix.my.servers/include/state.php index df7171408..8d9c162c2 100644 --- a/emhttp/plugins/dynamix.my.servers/include/state.php +++ b/emhttp/plugins/dynamix.my.servers/include/state.php @@ -170,15 +170,19 @@ class ServerState $this->updateOsCheck = new UnraidOsCheck(); $this->updateOsIgnoredReleases = $this->updateOsCheck->getIgnoredReleases(); - $this->updateOsNotificationsEnabled = !empty(@$this->getWebguiGlobal('notify')['unraidos']); + $this->updateOsNotificationsEnabled = !empty(@$this->getWebguiGlobal('notify', 'unraidos')); $this->updateOsResponse = $this->updateOsCheck->getUnraidOSCheckResult(); } /** * Retrieve the value of a webgui global setting. */ - public function getWebguiGlobal(string $key) { - return $this->webguiGlobals[$key]; + public function getWebguiGlobal(string $key, string $subkey = null) { + if (!$subkey) { + return _var($this->webguiGlobals, $key, []); + } + $keyArray = _var($this->webguiGlobals, $key, []); + return _var($keyArray, $subkey, ''); } /** * Retrieve the server information as an associative array @@ -200,8 +204,8 @@ class ServerState "connectPluginVersion" => $this->connectPluginVersion, "csrf" => $this->var['csrf_token'], "dateTimeFormat" => [ - "date" => @$this->getWebguiGlobal('display')['date'] ?? '', - "time" => @$this->getWebguiGlobal('display')['time'] ?? '', + "date" => @$this->getWebguiGlobal('display', 'date') ?? '', + "time" => @$this->getWebguiGlobal('display', 'time') ?? '', ], "description" => $this->var['COMMENT'] ? htmlspecialchars($this->var['COMMENT']) : '', "deviceCount" => $this->var['deviceCount'], @@ -235,13 +239,13 @@ class ServerState "site" => $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['HTTP_HOST'], "state" => strtoupper(empty($this->var['regCheck']) ? $this->var['regTy'] : $this->var['regCheck']), "theme" => [ - "banner" => !empty($this->getWebguiGlobal('display')['banner']), - "bannerGradient" => $this->getWebguiGlobal('display')['showBannerGradient'] === 'yes' ?? false, - "bgColor" => ($this->getWebguiGlobal('display')['background']) ? '#' . $this->getWebguiGlobal('display')['background'] : '', - "descriptionShow" => (!empty($this->getWebguiGlobal('display')['headerdescription']) && $this->getWebguiGlobal('display')['headerdescription'] !== 'no'), - "metaColor" => ($this->getWebguiGlobal('display')['headermetacolor'] ?? '') ? '#' . $this->getWebguiGlobal('display')['headermetacolor'] : '', - "name" => $this->getWebguiGlobal('display')['theme'], - "textColor" => ($this->getWebguiGlobal('display')['header']) ? '#' . $this->getWebguiGlobal('display')['header'] : '', + "banner" => !empty($this->getWebguiGlobal('display', 'banner')), + "bannerGradient" => $this->getWebguiGlobal('display', 'showBannerGradient') === 'yes' ?? false, + "bgColor" => ($this->getWebguiGlobal('display', 'background')) ? '#' . $this->getWebguiGlobal('display', 'background') : '', + "descriptionShow" => (!empty($this->getWebguiGlobal('display', 'headerdescription')) && $this->getWebguiGlobal('display', 'headerdescription') !== 'no'), + "metaColor" => ($this->getWebguiGlobal('display', 'headermetacolor') ?? '') ? '#' . $this->getWebguiGlobal('display', 'headermetacolor') : '', + "name" => $this->getWebguiGlobal('display', 'theme'), + "textColor" => ($this->getWebguiGlobal('display', 'header')) ? '#' . $this->getWebguiGlobal('display', 'header') : '', ], "ts" => time(), "uptime" => 1000 * (time() - round(strtok(exec("cat /proc/uptime"), ' '))),