Browse Source

more work on db upgrade functions
fix mobile logo size

causefx 8 years ago
parent
commit
96802a6073

+ 2 - 2
api/functions/api-functions.php

@@ -236,10 +236,10 @@ function updateDB($path, $filename, $oldVerNum = false)
 				}
 			}
 		}
-		updateConfig(array('configVersion' => $GLOBALS['installedVersion']));
 		return true;
 	} catch (Dibi\Exception $e) {
-		return $e;
+		writeLog('error', 'Update Function -  Error [' . $e . ']', 'Database');
+		return false;
 	}
 }
 

+ 1 - 1
api/functions/organizr-functions.php

@@ -849,7 +849,7 @@ function logoOrText()
 	if ($GLOBALS['useLogo'] == false) {
 		return '<h1>' . $GLOBALS['title'] . '</h1>';
 	} else {
-		return '<img style="max-width: 350px;" src="' . $GLOBALS['logo'] . '" alt="Home" />';
+		return '<img class="loginLogo" src="' . $GLOBALS['logo'] . '" alt="Home" />';
 	}
 }
 

+ 24 - 17
api/functions/upgrade-functions.php

@@ -1,21 +1,28 @@
 <?php
-
 function upgradeCheck()
 {
-    $updateDB = false;
-    $compare = new Composer\Semver\Comparator;
-    $oldVer = $GLOBALS['installedVersion'];
-    // Upgrade check start for version below
-    $versionCheck = '2.0.0-alpha-100';
-    if ($compare->lessThan($oldVer, $versionCheck)) {
-        $updateDB = true;
-        $oldVer = $versionCheck;
-    }
-    // End Upgrade check start for version above
-    if ($updateDB == true) {
-        //return 'Upgraded Needed - Current Version '.$oldVer.' - New Version: '.$versionCheck;
-        // Upgrade database to latest version
-        updateDB($GLOBALS['dbLocation'],$GLOBALS['dbName'],$oldVer);
-    }
-    return true;
+	$updateDB = false;
+	$updateSuccess = true;
+	$compare = new Composer\Semver\Comparator;
+	$oldVer = $GLOBALS['configVersion'];
+	// Upgrade check start for version below
+	$versionCheck = '2.0.0-alpha-100';
+	if ($compare->lessThan($oldVer, $versionCheck)) {
+		$updateDB = true;
+		$oldVer = $versionCheck;
+	}
+	// End Upgrade check start for version above
+	if ($updateDB == true) {
+		//return 'Upgraded Needed - Current Version '.$oldVer.' - New Version: '.$versionCheck;
+		// Upgrade database to latest version
+		$updateSuccess = (updateDB($GLOBALS['dbLocation'], $GLOBALS['dbName'], $oldVer)) ? true : false;
+	}
+	// Update config.php version if different to the installed version
+	if ($updateSuccess && $GLOBALS['installedVersion'] !== $GLOBALS['configVersion']) {
+		updateConfig(array('apply_CONFIG_VERSION' => $GLOBALS['installedVersion']));
+	}
+	if ($updateSuccess == false) {
+		die('Database update failed - Please manually check logs and fix - Then reload this page');
+	}
+	return true;
 }

+ 4 - 0
css/organizr.css

@@ -811,4 +811,8 @@ input.has-success {
     max-height: 85vh;
     overflow-x: hidden;
     overflow-y: scroll;
+}
+.loginLogo {
+    max-width: 350px;
+    max-height: 225px;
 }

+ 6 - 1
js/functions.js

@@ -3814,7 +3814,12 @@ function buildMediaResults(array,source,term){
 }
 function launch(){
 	organizrConnect('api/?v1/launch_organizr').success(function (data) {
-		var json = JSON.parse(data);
+        try {
+            var json = JSON.parse(data);
+        } catch (e) {
+            message('FATAL ERROR',data,'bottom-right','#FFF','error','60000');
+            return false;
+        }
 		if(json.data.user == false){ location.reload(); }
 		currentVersion = json.data.status.version;
 		activeInfo = {