]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Cleaned up constructor logic for ElggPluginPackage. Better detection of invalid...
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 14 Dec 2010 03:01:24 +0000 (03:01 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 14 Dec 2010 03:01:24 +0000 (03:01 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7614 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/classes/ElggPluginPackage.php

index 4a10da43d4aa3d258012083f09a15ec07eb81acf..8bbacce223c69a9c42997742f2c6c267b6ca0d04 100644 (file)
@@ -95,28 +95,29 @@ class ElggPluginPackage {
        public function __construct($plugin, $validate = true) {
                if (substr($plugin, 0, 1) == '/') {
                        // this is a path
-                       $plugin = sanitise_filepath($plugin);
-
-                       if (!is_dir($plugin)) {
-                               throw new PluginException(elgg_echo('PluginException:InvalidPath', array($plugin)));
-                       }
+                       $path = sanitise_filepath($plugin);
 
                        // the id is the last element of the array
-                       $path_array = explode('/', trim($plugin, '/'));
-                       $this->id = array_pop($path_array);
-                       $this->path = $plugin;
+                       $path_array = explode('/', trim($path, '/'));
+                       $id = array_pop($path_array);
                } else {
-                       // this is a plugin name
-
+                       // this is a plugin id
                        // strict plugin names
                        if (preg_match('/[^a-z0-9\.\-_]/i', $id)) {
                                throw new PluginException(elgg_echo('PluginException:InvalidID', array($plugin)));
                        }
 
-                       $this->id = $plugin;
-                       $this->path = get_config('pluginspath') . "$plugin/";
+                       $path = get_config('pluginspath') . "$plugin/";
+                       $id = $plugin;
                }
 
+               if (!is_dir($path)) {
+                       throw new PluginException(elgg_echo('PluginException:InvalidPath', array($path)));
+               }
+
+               $this->path = $path;
+               $this->id = $id;
+
                if ($validate && !$this->isValid()) {
                        if ($this->invalidPluginError) {
                                throw new PluginException(elgg_echo('PluginException:InvalidPlugin:Details',