aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggPluginPackage.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-04 21:04:34 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-04 21:04:34 +0000
commit1026deb7ef24677a2a0b48b4297911a4c2eceb6d (patch)
treef155d96d9369aab9adae2f2c07c69fac1fd84914 /engine/classes/ElggPluginPackage.php
parent21874b0235acfe83d9f260d9bc71489dbce9172f (diff)
downloadelgg-1026deb7ef24677a2a0b48b4297911a4c2eceb6d.tar.gz
elgg-1026deb7ef24677a2a0b48b4297911a4c2eceb6d.tar.bz2
Added new priority 'requires' for plugin dep system. You can now say that a plugin is required to be after / before another plugin in the system.
git-svn-id: http://code.elgg.org/elgg/trunk@8016 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/classes/ElggPluginPackage.php')
-rw-r--r--engine/classes/ElggPluginPackage.php57
1 files changed, 56 insertions, 1 deletions
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