diff options
Diffstat (limited to 'engine/classes')
-rw-r--r-- | engine/classes/ElggPlugin.php | 35 | ||||
-rw-r--r-- | engine/classes/ElggPluginManifest.php | 8 | ||||
-rw-r--r-- | engine/classes/ElggPluginPackage.php | 74 |
3 files changed, 78 insertions, 39 deletions
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php index 2fe29d175..3352105f8 100644 --- a/engine/classes/ElggPlugin.php +++ b/engine/classes/ElggPlugin.php @@ -131,7 +131,7 @@ class ElggPlugin extends ElggObject { * @return string */ public function getPath() { - return $this->path; + return sanitise_filepath($this->path); } @@ -179,20 +179,6 @@ class ElggPlugin extends ElggObject { $old_priority = (int) $this->getPriority(); $max_priority = elgg_get_max_plugin_priority(); - if ($priority == $old_priority) { - return false; - } - - // there's nothing above the max. - if ($priority > $max_priority) { - $priority = $max_priority; - } - - // there's nothing below 1. - if ($priority < 1) { - $priority = 1; - } - // (int) 0 matches (string) first, so cast to string. $priority = (string) $priority; @@ -220,6 +206,20 @@ class ElggPlugin extends ElggObject { return false; } + if ($priority == $old_priority) { + return false; + } + + // there's nothing above the max. + if ($priority > $max_priority) { + $priority = $max_priority; + } + + // there's nothing below 1. + if ($priority < 1) { + $priority = 1; + } + if ($priority > $old_priority) { $op = '-'; $where = "CAST(value as unsigned) BETWEEN $old_priority AND $priority"; @@ -489,6 +489,11 @@ class ElggPlugin extends ElggObject { if ($this->isActive($site_guid)) { return false; } + + if (!$this->canActivate()) { + return false; + } + // set in the db, now perform tasks and emit events if ($this->setStatus(true, $site_guid)) { // emit an event. returning false will make this not be activated. diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php index 290a59a0c..9ddf60396 100644 --- a/engine/classes/ElggPluginManifest.php +++ b/engine/classes/ElggPluginManifest.php @@ -249,7 +249,13 @@ class ElggPluginManifest { * @return sting */ public function getLicense() { - return $this->parser->getAttribute('license'); + // license vs licence. Use license. + $en_us = $this->parser->getAttribute('license'); + if ($en_us) { + return $en_us; + } else { + return $this->parser->getAttribute('licence'); + } } diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php index dcc6918d0..fd54ff731 100644 --- a/engine/classes/ElggPluginPackage.php +++ b/engine/classes/ElggPluginPackage.php @@ -334,27 +334,33 @@ class ElggPluginPackage { } // unless we're doing a full report, break as soon as we fail. - if (!$full_report && !$result) { - return $result; + if (!$full_report && !$result['status']) { + return $result['status']; } else { // build report element and comment - if ($dep_type == 'requires') { - $comment = ''; - } elseif ($dep_type == 'conflicts') { - $comment = ''; - } - $report[] = array( 'type' => $dep_type, 'dep' => $dep, - 'status' => $result, - 'comment' => $comment + 'status' => $result['status'], + 'value' => $result['value'] ); } } } if ($full_report) { + // add provides to full report + $provides = $this->getManifest()->getProvides(); + + foreach ($provides as $provide) { + $report[] = array( + 'type' => 'provides', + 'dep' => $provide, + 'status' => true, + 'value' => '' + ); + } + return $report; } @@ -373,7 +379,7 @@ class ElggPluginPackage { $r = elgg_check_plugins_provides('plugin', $dep['name'], $dep['version'], $dep['comparison']); if ($inverse) { - $r = !$r; + $r['status'] = !$r['status']; } return $r; @@ -388,13 +394,16 @@ class ElggPluginPackage { * @return bool */ private function checkDepElgg(array $dep, $elgg_version, $inverse = false) { - $r = version_compare($elgg_version, $dep['version'], $dep['comparison']); + $status = version_compare($elgg_version, $dep['version'], $dep['comparison']); if ($inverse) { - $r = !$r; + $status = !$status; } - return $r; + return array( + 'status' => $status, + 'value' => $elgg_version + ); } /** @@ -403,7 +412,10 @@ class ElggPluginPackage { * @todo Can this be merged with the plugin checker? * * @param array $dep An Elgg manifest.xml deps array - * @return bool + * @return array An array in the form array( + * 'status' => bool + * 'value' => string The version provided + * ) */ private function checkDepPhpExtension(array $dep) { $name = $dep['name']; @@ -411,21 +423,34 @@ class ElggPluginPackage { $comparison = $dep['comparison']; // not enabled. - $r = extension_loaded($name); + $status = extension_loaded($name); // enabled. check version. $ext_version = phpversion($name); - if ($version && !version_compare($ext_version, $version, $comparison)) { - $r = false; + if ($status) { + // some extensions (like gd) don't provide versions. neat. + // don't check version info and return a lie. + if ($ext_version && $version) { + $status = version_compare($ext_version, $version, $comparison); + } + + if (!$ext_version) { + $ext_version = '???'; + } } // some php extensions can be emulated, so check provides. - if ($r == false) { - $r = elgg_check_plugins_provides('php_extension', $name, $version, $comparison); + if ($status == false) { + $provides = elgg_check_plugins_provides('php_extension', $name, $version, $comparison); + $status = $provides['status']; + $ext_version = $provides['value']; } - return $r; + return array( + 'status' => $status, + 'value' => $ext_version + ); } /** @@ -448,9 +473,12 @@ class ElggPluginPackage { $setting = 0; } - $r = version_compare($setting, $value, $comparison); + $status = version_compare($setting, $value, $comparison); - return $r; + return array( + 'status' => $status, + 'value' => $setting + ); } /** |