Browse Source

General changes

Cerothen 9 years ago
parent
commit
0e5c0fca4e
2 changed files with 51 additions and 45 deletions
  1. 22 14
      functions.php
  2. 29 31
      settings.php

+ 22 - 14
functions.php

@@ -40,7 +40,7 @@ if (function_exists('ldap_connect')) :
 else :
 else :
 	// Ldap Auth Missing Dependancy
 	// Ldap Auth Missing Dependancy
 	function plugin_auth_ldap_disabled() {
 	function plugin_auth_ldap_disabled() {
-		return 'Plex - Disabled (Dependancy: php-ldap missing!)';
+		return 'LDAP - Disabled (Dependancy: php-ldap missing!)';
 	}
 	}
 endif;
 endif;
 
 
@@ -768,7 +768,7 @@ function createConfig($array, $path = 'config/config.php', $nest = 0) {
 		}
 		}
 	}
 	}
 	
 	
-	if (!$nest) {
+	if (!$nest && !isset($array['CONFIG_VERSION'])) {
 		// Inject Current Version
 		// Inject Current Version
 		$output[] = "\t".'"CONFIG_VERSION" => "'.INSTALLEDVERSION.'"';
 		$output[] = "\t".'"CONFIG_VERSION" => "'.INSTALLEDVERSION.'"';
 	}
 	}
@@ -917,7 +917,6 @@ function upgradeCheck() {
 		unlink('homepageSettings.ini.php');
 		unlink('homepageSettings.ini.php');
 		unset($databaseData);
 		unset($databaseData);
 		unset($homepageConfig);
 		unset($homepageConfig);
-		$effectiveVersion = '1.31';
 	}
 	}
 	
 	
 	// Upgrade to 1.32
 	// Upgrade to 1.32
@@ -942,24 +941,25 @@ function upgradeCheck() {
 		$config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
 		$config["headphonesURL"] = $config["headphonesURL"].(!empty($config["headphonesPort"])?':'.$config["headphonesPort"]:'');
 		unset($config["headphonesPort"]);
 		unset($config["headphonesPort"]);
 		
 		
+		// Write config file
+		$config['CONFIG_VERSION'] = '1.32';
 		$createConfigSuccess = createConfig($config);
 		$createConfigSuccess = createConfig($config);
 		
 		
 		// Create new config
 		// Create new config
 		if ($createConfigSuccess) {
 		if ($createConfigSuccess) {
-			// Make Config Dir (this should never happen as the dir and defaults file should be there);
-			@mkdir('config', 0775, true);
-			
-			// Remove Old ini file
-			unlink('databaseLocation.ini.php');
+			if (file_exists('config/config.php')) {
+				// Remove Old ini file
+				unlink('databaseLocation.ini.php');
+			} else {
+				debug_out('Something is not right here!');
+			}
 		} else {
 		} else {
 			debug_out('Couldn\'t create updated configuration.' ,1);
 			debug_out('Couldn\'t create updated configuration.' ,1);
 		}
 		}
-		$effectiveVersion = '1.32';
 	}
 	}
 	
 	
 	// Upgrade to 1.33
 	// Upgrade to 1.33
 	$config = loadConfig();
 	$config = loadConfig();
-	if (isset($effectiveVersion)) { $config['CONFIG_VERSION'] = $effectiveVersion; }
 	if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
 	if (isset($config['database_Location']) && (!isset($config['CONFIG_VERSION']) || $config['CONFIG_VERSION'] < '1.33')) {
 		// Fix User Directory
 		// Fix User Directory
 		$config['user_home'] = $config['database_Location'].'users/';
 		$config['user_home'] = $config['database_Location'].'users/';
@@ -1353,10 +1353,18 @@ function timezoneOptions() {
 }
 }
 
 
 // Build Database
 // Build Database
-function createSQLiteDB() {
-	if (!is_file(DATABASE_LOCATION.'users.db')) {
+function createSQLiteDB($path = false) {
+	if ($path === false) {
+		if (defined('DATABASE_LOCATION')) {
+			$path = DATABASE_LOCATION;
+		} else {
+			debug_out('No Path Specified!');
+		}
+	}
+	
+	if (!is_file($path.'users.db')) {
 		if (!isset($GLOBALS['file_db'])) {
 		if (!isset($GLOBALS['file_db'])) {
-			$GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
+			$GLOBALS['file_db'] = new PDO('sqlite:'.$path.'users.db');
 			$GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 			$GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 		}
 		}
 		
 		
@@ -1447,7 +1455,7 @@ function updateSQLiteDB($db_path = false) {
 	}
 	}
 	
 	
 	// Create New Database
 	// Create New Database
-	$success = createSQLiteDB();
+	$success = createSQLiteDB($db_path);
 	
 	
 	// Restore Items
 	// Restore Items
 	if ($success) {
 	if ($success) {

+ 29 - 31
settings.php

@@ -862,24 +862,21 @@ echo buildSettings(
 	array(
 	array(
 		'title' => 'Homepage Settings',
 		'title' => 'Homepage Settings',
 		'id' => 'homepage_settings',
 		'id' => 'homepage_settings',
-		'fields' => array(
-			array(
-				'type' => 'header',
-				'label' => 'General',
-			),
-			array(
-				'type' => $userSelectType,
-				'labelTranslate' => 'SHOW_HOMEPAGE',
-				'name' => 'homePageAuthNeeded',
-				'value' => HOMEPAGEAUTHNEEDED,
-				'options' => $userTypes,
-			),
+		'tabs' => array(
 			array(
 			array(
-				'type' => 'header',
-				'label' => 'Services',
+				'title' => 'General',
+				'id' => 'home_general',
+				'image' => 'images/gear.png',
+				'fields' => array(
+					array(
+						'type' => $userSelectType,
+						'labelTranslate' => 'SHOW_HOMEPAGE',
+						'name' => 'homePageAuthNeeded',
+						'value' => HOMEPAGEAUTHNEEDED,
+						'options' => $userTypes,
+					),
+				),
 			),
 			),
-		),
-		'tabs' => array(
 			array(
 			array(
 				'title' => 'Plex',
 				'title' => 'Plex',
 				'id' => 'plex',
 				'id' => 'plex',
@@ -902,6 +899,13 @@ echo buildSettings(
 						'pattern' => '[a-zA-Z0-9]{20}',
 						'pattern' => '[a-zA-Z0-9]{20}',
 						'value' => PLEXTOKEN,
 						'value' => PLEXTOKEN,
 					),
 					),
+					array(
+						'type' => $userSelectType,
+						'labelTranslate' => 'SHOW_ON_HOMEPAGE',
+						'name' => 'plexHomeAuth',
+						'value' => PLEXHOMEAUTH,
+						'options' => $userTypes,
+					),
 					array(
 					array(
 						array(
 						array(
 							'type' => 'checkbox',
 							'type' => 'checkbox',
@@ -928,13 +932,6 @@ echo buildSettings(
 							'value' => PLEXPLAYINGNOW,
 							'value' => PLEXPLAYINGNOW,
 						),
 						),
 					),
 					),
-					array(
-						'type' => $userSelectType,
-						'labelTranslate' => 'SHOW_ON_HOMEPAGE',
-						'name' => 'plexHomeAuth',
-						'value' => PLEXHOMEAUTH,
-						'options' => $userTypes,
-					),
 				),
 				),
 			),
 			),
 			array(
 			array(
@@ -959,6 +956,13 @@ echo buildSettings(
 						'pattern' => '[a-zA-Z0-9]{32}',
 						'pattern' => '[a-zA-Z0-9]{32}',
 						'value' => EMBYTOKEN,
 						'value' => EMBYTOKEN,
 					),
 					),
+					array(
+						'type' => $userSelectType,
+						'labelTranslate' => 'SHOW_ON_HOMEPAGE',
+						'name' => 'embyHomeAuth',
+						'value' => EMBYHOMEAUTH,
+						'options' => $userTypes,
+					),
 					array(
 					array(
 						array(
 						array(
 							'type' => 'checkbox',
 							'type' => 'checkbox',
@@ -985,13 +989,6 @@ echo buildSettings(
 							'value' => EMBYPLAYINGNOW,
 							'value' => EMBYPLAYINGNOW,
 						),
 						),
 					),
 					),
-					array(
-						'type' => $userSelectType,
-						'labelTranslate' => 'SHOW_ON_HOMEPAGE',
-						'name' => 'embyHomeAuth',
-						'value' => EMBYHOMEAUTH,
-						'options' => $userTypes,
-					),
 				),
 				),
 			),
 			),
 			array(
 			array(
@@ -1268,7 +1265,7 @@ echo buildSettings(
 	array(
 	array(
 		'title' => 'Advanced Settings',
 		'title' => 'Advanced Settings',
 		'id' => 'advanced_settings',
 		'id' => 'advanced_settings',
-		'onready' => '$(\'.be-auth\').each(function() { $(this).parent().hide(); }); $(\'.be-auth-\'+$(\'#authBackend_id\').val()).each(function() { $(this).parent().show(); });',
+		'onready' => '$(\'#authType_id\').trigger(\'change\')',
 		'tabs' => array(
 		'tabs' => array(
 			array(
 			array(
 				'title' => 'Backend Authentication',
 				'title' => 'Backend Authentication',
@@ -1280,6 +1277,7 @@ echo buildSettings(
 						'labelTranslate' => 'AUTHTYPE',
 						'labelTranslate' => 'AUTHTYPE',
 						'name' => 'authType',
 						'name' => 'authType',
 						'value' => AUTHTYPE,
 						'value' => AUTHTYPE,
+						'onchange' => 'if (this.value == \'internal\') { $(\'.be-auth, #authBackend_id, #authBackendCreate_id\').parent().hide(); } else { $(\'#authBackend_id, #authBackendCreate_id\').trigger(\'change\').parent().show(); }',
 						'options' => array(
 						'options' => array(
 							'Organizr' => 'internal',
 							'Organizr' => 'internal',
 							'Organizr & Backend' => 'both',
 							'Organizr & Backend' => 'both',