aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggMenuItem.php18
-rw-r--r--engine/classes/ElggPlugin.php2
-rw-r--r--engine/classes/ElggPluginManifest.php67
-rw-r--r--engine/classes/ElggPluginPackage.php57
-rw-r--r--engine/lib/plugins.php20
5 files changed, 122 insertions, 42 deletions
diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php
index 40df8f182..a190a89ef 100644
--- a/engine/classes/ElggMenuItem.php
+++ b/engine/classes/ElggMenuItem.php
@@ -46,17 +46,17 @@ class ElggMenuItem {
/**
* @var string Identifier of this item's parent
*/
- protected $parent_name = '';
+ protected $parent_name = '';
- /**
- * @var ElggMenuItem The parent object or null
- */
- protected $parent = null;
+ /**
+ * @var ElggMenuItem The parent object or null
+ */
+ protected $parent = null;
- /**
- * @var array Array of children objects or empty array
- */
- protected $children = array();
+ /**
+ * @var array Array of children objects or empty array
+ */
+ protected $children = array();
/**
* ElggMenuItem constructor
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php
index 5782ac4dd..11b57e8d0 100644
--- a/engine/classes/ElggPlugin.php
+++ b/engine/classes/ElggPlugin.php
@@ -791,7 +791,7 @@ class ElggPlugin extends ElggObject {
}
$this->attributes[$name] = $value;
-
+
return true;
} else {
return set_private_setting($this->guid, $name, $value);
diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php
index 9ddf60396..95f008f98 100644
--- a/engine/classes/ElggPluginManifest.php
+++ b/engine/classes/ElggPluginManifest.php
@@ -32,6 +32,15 @@ class ElggPluginManifest {
'comparison' => 'ge'
);
+ /**
+ * The expected structure of a requires element
+ */
+ private $depsRequiresStructPriority = array(
+ 'type' => '',
+ 'name' => '',
+ 'priority' => '',
+ );
+
/*
* The expected structure of elgg and elgg_release requires element
*/
@@ -405,6 +414,10 @@ class ElggPluginManifest {
$struct = $this->depsRequiresStructPlugin;
break;
+ case 'priority':
+ $struct = $this->depsRequiresStructPriority;
+ break;
+
case 'php_extension':
$struct = $this->depsRequiresStructPhpExtension;
break;
@@ -438,32 +451,34 @@ class ElggPluginManifest {
$normalized_req = $this->buildStruct($struct, $req);
// normalize comparison operators
- switch ($normalized_req['comparison']) {
- case '<':
- $normalized_req['comparison'] = 'lt';
- break;
-
- case '<=':
- $normalized_req['comparison'] = 'le';
- break;
-
- case '>':
- $normalized_req['comparison'] = 'gt';
- break;
-
- case '>=':
- $normalized_req['comparison'] = 'ge';
- break;
-
- case '==':
- case 'eq':
- $normalized_req['comparison'] = '=';
- break;
-
- case '<>':
- case 'ne':
- $normalized_req['comparison'] = '!=';
- break;
+ if (isset($normalized_req['comparison'])) {
+ switch ($normalized_req['comparison']) {
+ case '<':
+ $normalized_req['comparison'] = 'lt';
+ break;
+
+ case '<=':
+ $normalized_req['comparison'] = 'le';
+ break;
+
+ case '>':
+ $normalized_req['comparison'] = 'gt';
+ break;
+
+ case '>=':
+ $normalized_req['comparison'] = 'ge';
+ break;
+
+ case '==':
+ case 'eq':
+ $normalized_req['comparison'] = '=';
+ break;
+
+ case '<>':
+ case 'ne':
+ $normalized_req['comparison'] = '!=';
+ break;
+ }
}
$normalized[] = $normalized_req;
diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php
index 01437a4e4..db62620a8 100644
--- a/engine/classes/ElggPluginPackage.php
+++ b/engine/classes/ElggPluginPackage.php
@@ -42,7 +42,7 @@ class ElggPluginPackage {
* @var array
*/
private $depsSupportedTypes = array(
- 'elgg_version', 'elgg_release', 'php_extension', 'php_ini', 'plugin'
+ 'elgg_version', 'elgg_release', 'php_extension', 'php_ini', 'plugin', 'priority',
);
/**
@@ -332,6 +332,10 @@ class ElggPluginPackage {
$result = $this->checkDepPlugin($dep, $enabled_plugins, $inverse);
break;
+ case 'priority':
+ $result = $this->checkDepPriority($dep, $enabled_plugins, $inverse);
+ break;
+
case 'php_extension':
$result = $this->checkDepPhpExtension($dep);
break;
@@ -394,6 +398,57 @@ class ElggPluginPackage {
}
/**
+ * Checks if $plugins meets the requirement by $dep.
+ *
+ * @param array $dep An Elgg manifest.xml deps array
+ * @param array $plugins A list of plugins as returned by get_installed_plugins();
+ * @param bool $inverse Inverse the results to use as a conflicts.
+ * @return bool
+ */
+ private function checkDepPriority(array $dep, array $plugins, $inverse = false) {
+ // see if we exist as an ElggPlugin
+ $this_plugin = elgg_get_plugin_from_id($this->getID());
+ $this_priority = $this_plugin->getPriority();
+
+ foreach ($plugins as $test_plugin) {
+ if ($test_plugin->getID() == $dep['name']) {
+ break;
+ }
+ }
+
+ $test_plugin_priority = $test_plugin->getPriority();
+
+ switch ($dep['priority']) {
+ case 'before':
+ $status = $this_priority < $test_plugin_priority;
+ break;
+
+ case 'after':
+ $status = $this_priority > $test_plugin_priority;
+ break;
+
+ default;
+ $status = false;
+ }
+
+ // get the current value
+ if ($this_priority < $test_plugin_priority) {
+ $value = 'before';
+ } else {
+ $value = 'after';
+ }
+
+ if ($inverse) {
+ $status = !$status;
+ }
+
+ return array(
+ 'status' => $status,
+ 'value' => $value
+ );
+ }
+
+ /**
* Checks if $elgg_version meets the requirement by $dep.
*
* @param array $dep An Elgg manifest.xml deps array
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index 2174814bd..e61874ebc 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -669,6 +669,7 @@ function elgg_get_plugin_dependency_strings($dep) {
'requires' 'php setting bob' >3 3 'change it'
'conflicts' 'php setting' >3 4 'change it'
'provides' 'plugin oauth_lib' 1.3 -- --
+ 'priority' 'before blog' -- after 'move it'
*/
$strings = array();
$strings['type'] = elgg_echo('ElggPlugin:Dependencies:' . ucwords($dep_system));
@@ -678,7 +679,7 @@ function elgg_get_plugin_dependency_strings($dep) {
case 'elgg_release':
// 'Elgg Version'
$strings['name'] = elgg_echo('ElggPlugin:Dependencies:Elgg');
- $strings['value'] = "$comparison {$info['version']}";
+ $strings['expected_value'] = "$comparison {$info['version']}";
$strings['local_value'] = $dep['value'];
$strings['comment'] = '';
break;
@@ -687,10 +688,10 @@ function elgg_get_plugin_dependency_strings($dep) {
// PHP Extension %s [version]
$strings['name'] = elgg_echo('ElggPlugin:Dependencies:PhpExtension', array($info['name']));
if ($info['version']) {
- $strings['value'] = "$comparison {$info['version']}";
+ $strings['expected_value'] = "$comparison {$info['version']}";
$strings['local_value'] = $dep['value'];
} else {
- $strings['value'] = '';
+ $strings['expected_value'] = '';
$strings['local_value'] = '';
}
$strings['comment'] = '';
@@ -698,17 +699,26 @@ function elgg_get_plugin_dependency_strings($dep) {
case 'php_ini':
$strings['name'] = elgg_echo('ElggPlugin:Dependencies:PhpIni', array($info['name']));
- $strings['value'] = "$comparison {$info['value']}";
+ $strings['expected_value'] = "$comparison {$info['value']}";
$strings['local_value'] = $dep['value'];
$strings['comment'] = '';
break;
case 'plugin':
$strings['name'] = elgg_echo('ElggPlugin:Dependencies:Plugin', array($info['name']));
- $strings['value'] = "$comparison {$info['version']}";
+ $strings['expected_value'] = "$comparison {$info['version']}";
$strings['local_value'] = $dep['version'];
$strings['comment'] = '';
break;
+
+ case 'priority':
+ $expected_priority = ucwords($info['priority']);
+ $real_priority = ucwords($dep['value']);
+ $strings['name'] = elgg_echo('ElggPlugin:Dependencies:Priority');
+ $strings['expected_value'] = elgg_echo("ElggPlugin:Dependencies:Priority:$expected_priority", array($info['name']));
+ $strings['local_value'] = elgg_echo("ElggPlugin:Dependencies:Priority:$real_priority", array($info['name']));
+ $strings['comment'] = '';
+ break;
}
if ($dep['status']) {