Browse Source

fixed config for project name - check path

Piotr Labudda 8 years ago
parent
commit
3e68ba43bf
1 changed files with 13 additions and 4 deletions
  1. 13 4
      SE/se-lib/Config.php

+ 13 - 4
SE/se-lib/Config.php

@@ -133,7 +133,18 @@ class Config {
 
 		$activeProject = V::get('P5_ACTIVE_PROJECT', '', $_SERVER);
 		DBG::log("\$activeProject = '{$activeProject}' (ENV)");
-		if (!$activeProject) $activeProject = DB::getPDO()->fetchValue(" select c.CONF_VAL from CRM_CONFIG c where c.CONF_KEY = 'activeProject' ");
+		if ($activeProject) {
+			$path = APP_PATH_ROOT . DS . "projects" . DS . "{$activeProject}";
+			if (!file_exists($path)) throw new Exception("Missing project folder '{$activeProject}' (env)");
+		}
+
+		if (!$activeProject) {
+			$activeProject = DB::getPDO()->fetchValue(" select c.CONF_VAL from CRM_CONFIG c where c.CONF_KEY = 'activeProject' ");
+			if ($activeProject) {
+				$path = APP_PATH_ROOT . DS . "projects" . DS . "{$activeProject}";
+				if (!file_exists($path)) throw new Exception("Missing project folder '{$activeProject}' (db)");
+			}
+		}
 		DBG::log("\$activeProject = '{$activeProject}' (ENV, DB)");
 		$_activeProject = (string)$activeProject;
 
@@ -143,9 +154,7 @@ class Config {
 	public static function getProjectPath() {
 		$activeProject = self::getProjectName();
 		if (!$activeProject) return null;
-		$path = APP_PATH_ROOT . DS . "projects" . DS . "{$activeProject}";
-		if (!file_exists($path)) throw new Exception("Missing project folder '{$activeProject}'");
-		return $path;
+		return APP_PATH_ROOT . DS . "projects" . DS . "{$activeProject}";
 	}
 
 }