From edec37b402e3f7afbf767c398fc6aca2670fe3d1 Mon Sep 17 00:00:00 2001
From: Robin Appelman <icewind1991@gmail.com>
Date: Mon, 25 Jul 2011 20:12:35 +0200
Subject: [PATCH] add OC_APP::getCurrentApp() to get the id of the active app

---
 lib/app.php | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/app.php b/lib/app.php
index 64704f09bb..475015f677 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -383,5 +383,21 @@ class OC_APP{
 		}
 		return $data;
 	}
+	
+	/**
+	 * get the id of loaded app
+	 * @return string
+	 */
+	public static function getCurrentApp(){
+		global $WEBROOT;
+		$script=substr($_SERVER["SCRIPT_NAME"],strlen($WEBROOT)+1);
+		$topFolder=substr($script,0,strpos($script,'/'));
+		if($topFolder=='apps'){
+			$length=strlen($topFolder);
+			return substr($script,$length+1,strpos($script,'/',$length+1)-$length-1);
+		}else{
+			return $topFolder;
+		}
+	}
 }
 ?>
\ No newline at end of file
-- 
GitLab