]> source.dussan.org Git - nextcloud-server.git/commitdiff
add OC_APP::getCurrentApp() to get the id of the active app
authorRobin Appelman <icewind1991@gmail.com>
Mon, 25 Jul 2011 18:12:35 +0000 (20:12 +0200)
committerRobin Appelman <icewind1991@gmail.com>
Mon, 25 Jul 2011 18:25:53 +0000 (20:25 +0200)
lib/app.php

index 64704f09bbd424f4f3c7302331c2978e6e22bf5b..475015f67792fc08c22ea295f525e1c3c7452754 100644 (file)
@@ -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