Browse Source

added Config get project

Piotr Labudda 8 years ago
parent
commit
588a4652df
1 changed files with 23 additions and 0 deletions
  1. 23 0
      SE/se-lib/Config.php

+ 23 - 0
SE/se-lib/Config.php

@@ -123,4 +123,27 @@ class Config {
 		return $_cnf[$conf_file];
 		return $_cnf[$conf_file];
 	}
 	}
 
 
+	/**
+	 * activeProject - SE/projects/{activeProject}/
+	 * may be set by ENV or in CRM_CONFIG
+	 */
+	public static function getProjectName() {
+		static $_activeProject = null;
+		if (null !== $_activeProject) return $_activeProject;
+
+		$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' ");
+		DBG::log("\$activeProject = '{$activeProject}' (ENV, DB)");
+		$_activeProject = (string)$activeProject;
+
+		return $_activeProject;
+	}
+
+	public static function getProjectPath() {
+		$activeProject = self::getProjectName();
+		if (!$activeProject) return null;
+		return APP_PATH_ROOT . DS . "projects" . DS . "{$activeProject}";
+	}
+
 }
 }