Permalink
Browse files

Another installation fix; closes #272

  • Loading branch information...
1 parent 916733d commit abc5d25a4944e6fc89914a298bd1b018d218f44c @benkeen committed May 26, 2015
View
@@ -23,4 +23,4 @@
$params["tablePrefix"] = Core::getDbTablePrefix();
$params["currentPage"] = $currentPage;
-Templates::displayPage("resources/templates/install.tpl", $params);
+Templates::displayPage("resources/templates/install.tpl", $params);
@@ -111,6 +111,12 @@ public function __construct($action, $post = array()) {
}
break;
+ case "installationValidateSettingsFile":
+ $response = Installation::validateSettingsFile();
+ $this->response["success"] = $response["success"];
+ $this->response["content"] = $response["errorMessage"];
+ break;
+
case "resetDataTypes":
Core::init("resetPlugins");
if (Core::checkIsLoggedIn() && Core::$user->isAdmin()) {
@@ -121,6 +121,7 @@ public static function init($runtimeContext = "ui") {
// the order is significant in all of this
if ($runtimeContext != "installation") {
self::initDatabase();
+
if (in_array($runtimeContext, array("installationDatabaseReady", "ui", "generation", "resetPlugins"))) {
self::initSessions();
}
@@ -335,10 +336,15 @@ public static function checkIsInstalled() {
if (!self::$settingsFileExists) {
return false;
}
+
+ // attempt to make the connection
+ Core::initDatabase();
+
$installationComplete = Settings::getSetting("installationComplete");
if (!isset($installationComplete) || $installationComplete == "no") {
return false;
}
+
return true;
}
@@ -180,4 +180,37 @@ public static function createCoreTables() {
return Core::$db->query($queries, $rollbackQueries);
}
+
+ public static function validateSettingsFile() {
+ $file = file(__DIR__ . "/../../settings.php");
+ $found = array(
+ "dbHostname" => false,
+ "dbName" => false,
+ "dbUsername" => false,
+ "dbPassword" => false,
+ "dbTablePrefix" => false
+ );
+
+ foreach ($file as $line) {
+ foreach ($found as $key => $value) {
+ preg_match("/$key/", $line, $matches);
+ if ($matches) {
+ $found[$key] = true;
+ }
+ }
+ }
+
+ $allMatched = true;
+ foreach ($found as $key => $value) {
+ if (!$value) {
+ $allMatched = false;
+ break;
+ }
+ }
+
+ return array(
+ "success" => $allMatched,
+ "error" => "The settings file exists but doesn't contain all the required values. You'll need to remove the file and re-install the script."
+ );
+ }
}
@@ -96,7 +96,6 @@ require([
function submit(e) {
var currentStep = parseInt($(e.target).closest(".gdInstallSection").attr("id").replace(/page/, ""), 10);
$(".gdError").hide();
- var errors = [];
if (currentStep === 1) {
_checkDatabaseInfo();

0 comments on commit abc5d25

Please sign in to comment.