]> source.dussan.org Git - nextcloud-server.git/commitdiff
add function to list all plugins
authorRobin Appelman <icewind1991@gmail.com>
Tue, 28 Sep 2010 22:03:02 +0000 (22:03 +0000)
committerRobin Appelman <icewind1991@gmail.com>
Tue, 28 Sep 2010 22:03:02 +0000 (22:03 +0000)
inc/lib_plugin.php

index c846fe25603857cbcc2832c2b8dcf4d51394f768..1e75a51e30bc6b2d7785b9f8937ee638cb1f726c 100644 (file)
@@ -56,17 +56,35 @@ class OC_PLUGIN{
                return false;
        }
        
+       /**
+        * Get a list of all installed plugins
+        */
+       public static function listPlugins() {
+               global $SERVERROOT;
+               $plugins = array();
+               $fd = opendir($SERVERROOT . '/plugins');
+               while ( false !== ($filename = readdir($fd)) ) {
+                       if ( $filename<>'.' AND $filename<>'..' AND ('.' != substr($filename, 0, 1))) {
+                               if(file_exists($SERVERROOT . '/plugins/'.$filename.'/plugin.xml')){
+                                       $plugins[]=$filename;
+                               }
+                       }
+               }
+               closedir($fd);
+               return $plugins;
+       }
+       
        /**
         * Load all plugins that aren't blacklisted
         */
        public static function loadPlugins() {
                global $SERVERROOT;
-               $plugins = array();
+               $plugins = self::listPlugins();
                $blacklist=self::loadBlacklist();
                $fd = opendir($SERVERROOT . '/plugins');
-               while ( false !== ($filename = readdir($fd)) ) {
-                       if ( $filename<>'.' AND $filename<>'..' AND ('.' != substr($filename, 0, 1)) AND array_search($filename,$blacklist)===false) {
-                               self::load($filename);
+               foreach($plugins as $plugin){
+                       if (array_search($plugin,$blacklist)===false) {
+                               self::load($plugin);
                        }
                }
                closedir($fd);
@@ -76,7 +94,7 @@ class OC_PLUGIN{
        * load the blacklist from blacklist.txt
        * @return array
        */
-       private static function loadBlacklist(){
+       public static function loadBlacklist(){
                global $SERVERROOT;
                if(count(self::$blacklist)>0){
                        return self::$blacklist;