Przeglądaj źródła

clean up update config and delete config item

CauseFX 4 lat temu
rodzic
commit
ac8d6dc2fd

+ 12 - 9
api/classes/organizr.class.php

@@ -57,7 +57,7 @@ class Organizr
 	use TransmissionHomepageItem;
 	use UnifiHomepageItem;
 	use WeatherHomepageItem;
-        use uTorrentHomepageItem;
+	use uTorrentHomepageItem;
 	
 	// ===================================
 	// Organizr Version
@@ -821,6 +821,7 @@ class Organizr
 		// Inject Parts
 		foreach ($new as $k => $v) {
 			$current[$k] = $v;
+			$this->config[$k] = $v;
 		}
 		// Return Create
 		return $this->createConfig($current);
@@ -838,8 +839,10 @@ class Organizr
 		foreach ($new as $k) {
 			if (isset($current[$k])) {
 				$current['deletedConfigItems'][$k] = $current[$k];
+				$this->config['deletedConfigItems'][$k] = $current[$k];
 			}
 			unset($current[$k]);
+			unset($this->config[$k]);
 		}
 		// Return Create
 		return $this->createConfig($current);
@@ -4234,13 +4237,13 @@ class Organizr
 						$class .= ' faded';
 					}
 					break;
-                                case 'homepageOrderuTorrent':
-                                        $class = 'bg-qbit';
-                                        $image = 'plugins/images/tabs/utorrent.png';
-                                        if (!$this->config['homepageuTorrentEnabled']) {
-                                                $class .= ' faded';
-                                        }
-                                        break;
+				case 'homepageOrderuTorrent':
+					$class = 'bg-qbit';
+					$image = 'plugins/images/tabs/utorrent.png';
+					if (!$this->config['homepageuTorrentEnabled']) {
+						$class .= ' faded';
+					}
+					break;
 				case 'homepageOrderrTorrent':
 					$class = 'bg-qbit';
 					$image = 'plugins/images/tabs/rTorrent.png';
@@ -6876,4 +6879,4 @@ class Organizr
 		return count($request) > 1 ? $results : $results[$firstKey];
 	}
 	
-}
+}

+ 3 - 5
api/functions/upgrade-functions.php

@@ -84,7 +84,7 @@ trait UpgradeFunctions
 	{
 		$updateItems = [];
 		foreach ($keys as $new => $old) {
-			if ($this->config[$old]) {
+			if (isset($this->config[$old])) {
 				if ($this->config[$old] !== '') {
 					$updateItemsNew = [$new => $this->config[$old]];
 					$updateItems = array_merge($updateItems, $updateItemsNew);
@@ -112,12 +112,10 @@ trait UpgradeFunctions
 				$updateComplete = $this->updateConfig($updateItems);
 			}
 			if ($updateComplete) {
-				$this->config = $this->config();
-				$removeConfigItems = $this->removeConfigItem(['homepageOrdercustomhtml', 'homepageOrdercustomhtmlTwo', 'homepageCustomHTMLoneEnabled', 'homepageCustomHTMLoneAuth', 'customHTMLone', 'homepageCustomHTMLtwoEnabled', 'homepageCustomHTMLtwoAuth', 'customHTMLtwo']);
+				$removeConfigItems = $this->removeConfigItem(['homepagCustomHTMLoneAuth', 'homepagCustomHTMLoneEnabled', 'homepagCustomHTMLtwoAuth', 'homepagCustomHTMLtwoEnabled', 'homepageOrdercustomhtml', 'homepageOrdercustomhtmlTwo', 'homepageCustomHTMLoneEnabled', 'homepageCustomHTMLoneAuth', 'customHTMLone', 'homepageCustomHTMLtwoEnabled', 'homepageCustomHTMLtwoAuth', 'customHTMLtwo']);
 				if ($removeConfigItems) {
-					$this->config = $this->config();
+					return true;
 				}
-				return true;
 			}
 		}
 		return false;