aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggPluginPackage.php276
1 files changed, 0 insertions, 276 deletions
diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php
index 6301ad1f2..dcc6918d0 100644
--- a/engine/classes/ElggPluginPackage.php
+++ b/engine/classes/ElggPluginPackage.php
@@ -453,282 +453,6 @@ class ElggPluginPackage {
return $r;
}
-
- /**************************************
- * Detailed reports for requirements. *
- **************************************/
-
-
- /**
- * Returns a report of the dependencies with human
- * readable statuses.
- *
- * @return array
- */
- public function getDependenciesReport() {
- $requires = $this->getManifest()->getRequires();
- $conflicts = $this->getManifest()->getConflicts();
- $enabled_plugins = get_installed_plugins('enabled');
-
- $status = true;
- $messages = array();
-
- $return = array(
- array(
- 'type' => 'requires',
- 'dep' => $dep,
- 'status' => 'bool',
- 'comment' => ''
- )
- );
-
- foreach ($requires as $require) {
- switch ($require['type']) {
- case 'elgg_version':
- $result = $this->checkRequiresElgg($require, get_version());
- break;
-
- case 'elgg_release':
- $result = $this->checkRequiresElgg($require, get_version(true));
- break;
-
- case 'plugin':
- $result = $this->checkDepsPlugin($require, $enabled_plugins);
- break;
-
- case 'php_extension':
- $result = $this->checkRequiresPhpExtension($require);
- break;
-
- case 'php_ini':
- $result = $this->checkRequiresPhpIni($require);
- break;
-
- default:
- $result = array(
- 'status' => false,
- 'message' => elgg_echo('ElggPluginPackage:UnknownDep',
- array($require['type'], $this->getManifest()->getPluginID()))
- );
- break;
- }
-
- if (!$result['status']) {
- $status = false;
- $messages[] = $result['message'];
- }
- }
-
- foreach ($conflicts as $conflict) {
-
- }
-
- $return = array(
- 'status' => $status,
- 'messages' => $messages
- );
-
- return $return;
- }
-
- /**
- * Checks if $plugins meets the requirement by $require.
- *
- * Returns an array in the form array('status' => bool, 'message' => 'Any messages')
- *
- * @param array $require An Elgg manifest.xml requires array
- * @param array $plugins A list of plugins as returned by get_installed_plugins();
- * @return array
- */
- private function checkRequiresPlugin(array $require, array $plugins = array()) {
- $status = true;
- $message = '';
-
- $name = $require['name'];
- $version = $require['version'];
- $comparison = $require['comparison'];
-
- // not enabled.
- if (!array_key_exists($name, $plugins)) {
- $status = false;
-
- if ($version) {
- $message = elgg_echo("ElggPluginPackage:Requires:Plugin:NotEnabled:$comparison",
- array($this->getManifest()->getPluginID(), $name, $version));
- } else {
- $message = elgg_echo('ElggPluginPackage:Requires:Plugin:NotEnabled:NoVersion',
- array($this->getManifest()->getPluginID(), $name));
- }
- }
-
- // enabled. check version.
- if ($status != false) {
- $requires_plugin_info = $plugins[$name];
-
- //@todo boot strapping until we can migrate everything over to ElggPluginPackage.
- $plugin_package = new ElggPluginPackage($name);
- $plugin_version = $plugin_package->getManifest()->getVersion();
-
- if ($version && !version_compare($plugin_version, $version, $comparison)) {
- $status = false;
-
- $message = elgg_echo("ElggPluginPackage:Requires:Plugin:$comparison",
- array($this->getManifest()->getPluginID(), $name, $version, $plugin_version));
- }
- }
-
- // if all else fails check with the provides
- if ($status == false) {
- if (elgg_check_plugins_provides('plugin', $name)) {
- // it's provided. check version if asked.
- $status = true;
- $message = '';
-
- if ($version && !elgg_check_plugins_provides('plugin', $name, $version, $comparison)) {
- // change the message to something more meaningful
- $provide = elgg_get_plugins_provides('plugin', $name);
- $plugin_version = "{$provide['provided_by']}:$name={$provide['version']}";
-
- $status = false;
- $message = elgg_echo("ElggPluginPackage:Requires:Plugin:$comparison",
- array($this->getManifest()->getPluginID(), $name, $version, $plugin_version));
- }
- }
- }
-
- return array(
- 'status' => $status,
- 'message' => $message
- );
- }
-
- /**
- * Checks if $elgg_version meets the requirement by $require.
- *
- * Returns an array in the form array('status' => bool, 'message' => 'Any messages')
- *
- * @param array $require An Elgg manifest.xml requires array
- * @param array $elgg_version An Elgg version (either YYYYMMDDXX or X.Y.Z)
- * @return array
- */
- private function checkRequiresElgg(array $require, $elgg_version) {
- $status = true;
- $message = '';
- $version = $require['version'];
- $comparison = $require['comparison'];
-
- if (!version_compare($elgg_version, $version, $comparison)) {
- $status = false;
- $message = elgg_echo("ElggPluginPackage:Requires:Elgg:$comparison",
- array($this->getManifest()->getPluginID(), $version));
- }
-
- return array(
- 'status' => $status,
- 'message' => $message
- );
- }
-
- /**
- * Checks if the PHP extension in $require is loaded.
- *
- * @todo Can this be merged with the plugin checker?
- *
- * @param array $require An Elgg manifest.xml deps array
- * @return array
- */
- private function checkRequiresPhpExtension($require) {
- $status = true;
- $message = '';
-
- $name = $require['name'];
- $version = $require['version'];
- $comparison = $require['comparison'];
-
- // not enabled.
- if (!extension_loaded($name)) {
- $status = false;
- if ($version) {
- $message = elgg_echo("ElggPluginPackage:Requires:PhpExtension:NotInstalled:$comparison",
- array($this->getManifest()->getPluginID(), $name, $version));
- } else {
- $message = elgg_echo('ElggPluginPackage:Requires:PhpExtension:NotInstalled:NoVersion',
- array($this->getManifest()->getPluginID(), $name));
- }
- }
-
- // enabled. check version.
- if ($status != false) {
- $ext_version = phpversion($name);
-
- if ($version && !version_compare($ext_version, $version, $comparison)) {
- $status = false;
- $message = elgg_echo("ElggPluginPackage:Requires:PhpExtension:$comparison",
- array($this->getManifest()->getPluginID(), $name, $version));
- }
- }
-
- // some php extensions can be emulated, so check provides.
- if ($status == false) {
- if (elgg_check_plugins_provides('php_extension', $name)) {
- // it's provided. check version if asked.
- $status = true;
- $message = '';
-
- if ($version && !elgg_check_plugins_provides('php_extension', $name, $version, $comparison)) {
- // change the message to something more meaningful
- $provide = elgg_get_plugins_provides('php_extension', $name);
- $plugin_version = "{$provide['provided_by']}:$name={$provide['version']}";
-
- $status = false;
- $message = elgg_echo("ElggPluginPackage:Requires:PhpExtension:$comparison",
- array($this->getManifest()->getPluginID(), $name, $version, $plugin_version));
- }
- }
- }
-
- return array(
- 'status' => $status,
- 'message' => $message
- );
- }
-
-
- /**
- * Check if the PHP ini setting satisfies $require.
- *
- * @param array $require An Elgg manifest.xml requires array
- * @return array
- */
- private function checkRequiresPhpIni($require) {
- $status = true;
- $message = '';
-
- $name = $require['name'];
- $value = $require['value'];
- $comparison = $require['comparison'];
-
- // ini_get() normalizes truthy values to 1 but falsey values to 0 or ''.
- // version_compare() considers '' < 0, so normalize '' to 0.
- // ElggPluginManifest normalizes all bool values and '' to 1 or 0.
- $setting = ini_get($name);
-
- if ($setting === '') {
- $setting = 0;
- }
-
- if (!version_compare($setting, $value, $comparison)) {
- $status = false;
- $message = elgg_echo("ElggPluginPackage:Requires:PhpIni:$comparison",
- array($this->getManifest()->getPluginID(), $name, $value, $setting));
- }
-
- return array(
- 'status' => $status,
- 'message' => $message
- );
- }
-
/**
* Activate the plugin.
*