diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-01-05 04:36:07 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-01-05 04:36:07 +0000 |
commit | f2123cdc42c8da21a297158fbb655f72bc92edce (patch) | |
tree | 6eb8c0a4492e5dddd29a87ad68a4ecadc7f01230 | |
parent | 252c054437ac1d3ad43aca1e71ebb936b55d60d2 (diff) | |
download | elgg-f2123cdc42c8da21a297158fbb655f72bc92edce.tar.gz elgg-f2123cdc42c8da21a297158fbb655f72bc92edce.tar.bz2 |
Fixes #2760. Refs #2759. Updated plugin admin actions to use the new system. Added plugin dependency views in admin. ElggPluginPackage->checkDependencies() now returns the detected value.
git-svn-id: http://code.elgg.org/elgg/trunk@7838 36083f99-b078-4883-b0ff-0f9b5a30f544
20 files changed, 688 insertions, 439 deletions
diff --git a/actions/admin/plugins/activate.php b/actions/admin/plugins/activate.php new file mode 100644 index 000000000..7a55cb7bb --- /dev/null +++ b/actions/admin/plugins/activate.php @@ -0,0 +1,42 @@ +<?php +/** + * Activate a plugin or plugins. + * + * Plugins to be activated are passed via $_REQUEST['plugin_guids'] as GUIDs. + * After activating the plugin(s), the views cache and simplecache are invalidated. + * + * @uses mixed $_GET['plugin_guids'] The GUIDs of the plugin to activate. Can be an array. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugin_guids = get_input('plugin_guids'); + +if (!is_array($plugin_guids)) { + $plugin_guids = array($plugin_guids); +} + +foreach ($plugin_guids as $guid) { + $plugin = get_entity($guid); + + if (!($plugin instanceof ElggPlugin)) { + register_error(elgg_echo('admin:plugins:activate:no', array($guid))); + continue; + } + + if ($plugin->activate()) { + //system_message(elgg_echo('admin:plugins:activate:yes', array($plugin->manifest->getName()))); + } else { + register_error(elgg_echo('admin:plugins:activate:no', array($plugin->manifest->getName()))); + } +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/activate_all.php b/actions/admin/plugins/activate_all.php new file mode 100644 index 000000000..4ba4be270 --- /dev/null +++ b/actions/admin/plugins/activate_all.php @@ -0,0 +1,29 @@ +<?php +/** + * Activates all installed and inactive plugins. + * + * All plugins in the mod/ directory are that aren't active are activated and the views + * cache and simplecache are invalidated. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugins = elgg_get_plugins('inactive'); + +foreach ($plugins as $plugin) { + if ($plugin->activate()) { + //system_message(elgg_echo('admin:plugins:activate:yes', array($plugin->manifest->getName()))); + } else { + register_error(elgg_echo('admin:plugins:activate:no', array($plugin->manifest->getName()))); + } +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/deactivate.php b/actions/admin/plugins/deactivate.php new file mode 100644 index 000000000..7a9d59287 --- /dev/null +++ b/actions/admin/plugins/deactivate.php @@ -0,0 +1,42 @@ +<?php +/** + * Deactivate a plugin or plugins. + * + * Plugins to be deactivated are passed via $_REQUEST['plugin_guids'] as GUIDs. + * After deactivating the plugin(s), the views cache and simplecache are invalidated. + * + * @uses mixed $_GET['plugin_guids'] The GUIDs of the plugin to deactivate. Can be an array. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugin_guids = get_input('plugin_guids'); + +if (!is_array($plugin_guids)) { + $plugin_guids = array($plugin_guids); +} + +foreach ($plugin_guids as $guid) { + $plugin = get_entity($guid); + + if (!($plugin instanceof ElggPlugin)) { + register_error(elgg_echo('admin:plugins:deactivate:no', array($guid))); + continue; + } + + if ($plugin->deactivate()) { + //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->manifest->getName()))); + } else { + register_error(elgg_echo('admin:plugins:deactivate:no', array($plugin->manifest->getName()))); + } +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER); diff --git a/actions/admin/plugins/disableall.php b/actions/admin/plugins/deactivate_all.php index 351ebf840..bdeda001f 100644 --- a/actions/admin/plugins/disableall.php +++ b/actions/admin/plugins/deactivate_all.php @@ -6,20 +6,21 @@ * are reset. * * @package Elgg.Core - * @subpackage Administration.Site + * @subpackage Administration.Plugins */ -$plugins = get_installed_plugins(); +$plugins = elgg_get_plugins('active'); -foreach ($plugins as $p => $data) { - if (disable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:disable:yes', array($p))); +foreach ($plugins as $plugin) { + if ($plugin->deactivate()) { + //system_message(elgg_echo('admin:plugins:deactivate:yes', array($plugin->manifest->getName()))); } else { - register_error(elgg_echo('admin:plugins:disable:no', array($p))); + register_error(elgg_echo('admin:plugins:deactivate:no', array($plugin->manifest->getName()))); } } +elgg_delete_admin_notice('first_installation_plugin_reminder'); + // don't regenerate the simplecache because the plugin won't be // loaded until next run. Just invalidate and let it regnerate as needed elgg_invalidate_simplecache(); diff --git a/actions/admin/plugins/disable.php b/actions/admin/plugins/disable.php deleted file mode 100644 index 64994423f..000000000 --- a/actions/admin/plugins/disable.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * Disable a plugin or plugins. - * - * Plugins to be disabled are passed via $_REQUEST['plugin'] as plugin ID (directory name). - * After disabling the plugin(s), the views cache and simplecache are both reset. - * - * @uses mixed $_GET['plugin'] The id (directory name) of the plugin to disable. Can be an array. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$plugin = get_input('plugin'); -if (!is_array($plugin)) { - $plugin = array($plugin); -} - -foreach ($plugin as $p) { - if (disable_plugin($p)) { - system_message(elgg_echo('admin:plugins:disable:yes', array($p))); - - elgg_delete_admin_notice('first_installation_plugin_reminder'); - } else { - register_error(elgg_echo('admin:plugins:disable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER); diff --git a/actions/admin/plugins/enable.php b/actions/admin/plugins/enable.php deleted file mode 100644 index ebabe7bc8..000000000 --- a/actions/admin/plugins/enable.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * Enables a plugin or plugins. - * - * Plugins to be enabled are passed via $_REQUEST['plugin'] as plugin ID (directory name). - * After enabling the plugin(s), the views cache and simplecache are reset. - * - * @uses mixed $_GET['plugin'] The id (directory name) of the plugin to enable. Can be an array. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$plugin = get_input('plugin'); - -if (!is_array($plugin)) { - $plugin = array($plugin); -} - -foreach ($plugin as $p) { - if (enable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:enable:yes', array($p))); - } else { - register_error(elgg_echo('admin:plugins:enable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/enableall.php b/actions/admin/plugins/enableall.php deleted file mode 100644 index 04574f067..000000000 --- a/actions/admin/plugins/enableall.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * Enables all installed plugins. - * - * All plugins in the mod/ directory are enabled and the views cache and simplecache - * are reset. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$plugins = get_installed_plugins(); - -foreach ($plugins as $p => $data) { - if (enable_plugin($p)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:enable:yes', array($p))); - } else { - register_error(elgg_echo('admin:plugins:enable:no', array($p))); - } -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/reorder.php b/actions/admin/plugins/reorder.php deleted file mode 100644 index 29c4a7268..000000000 --- a/actions/admin/plugins/reorder.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - * Changes the load order of a plugin. - * - * Plugin order affects priority for view, action, and page handler - * overriding as well as the order of view extensions. Higher numbers - * are loaded after lower numbers, and so receive higher priority. - * - * NOTE: When viewing the admin page (advanced plugin admin in >= 1.8) plugins - * LOWER on the page have HIGHER priority and will override views, etc - * from plugins above them. - * - * @package Elgg.Core - * @subpackage Administration.Site - */ - -$mod = get_input('plugin'); -$mod = str_replace('.', '', $mod); -$mod = str_replace('/', '', $mod); - -// Get the new order -$order = (int) get_input('order'); - -// Get the current plugin list -$plugins = get_plugin_list(); - -// Inject the plugin order back into the list -if ($key = array_search($mod, $plugins)) { - - unset($plugins[$key]); - while (isset($plugins[$order])) { - $order++; - } - - $plugins[$order] = $mod; -} - -// Disable -if (regenerate_plugin_list($plugins)) { - elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:reorder:yes', array($plugin))); -} else { - register_error(elgg_echo('admin:plugins:reorder:no', array($plugin))); -} - -// don't regenerate the simplecache because the plugin won't be -// loaded until next run. Just invalidate and let it regnerate as needed -elgg_invalidate_simplecache(); -elgg_filepath_cache_reset(); - -forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/set_priority.php b/actions/admin/plugins/set_priority.php new file mode 100644 index 000000000..1203e22de --- /dev/null +++ b/actions/admin/plugins/set_priority.php @@ -0,0 +1,40 @@ +<?php +/** + * Changes the load priority of a plugin. + * + * Plugin priority affects view, action, and page handler + * overriding as well as the order of view extensions. Plugins with higher + * priority are loaded after and override plugins with lower priorities. + * + * NOTE: When viewing the admin page (advanced plugin admin in >= 1.8) plugins + * LOWER on the page have HIGHER priority and will override views, etc + * from plugins above them. + * + * @package Elgg.Core + * @subpackage Administration.Plugins + */ + +$plugin_guid = get_input('plugin_guid'); +$priority = get_input('priority'); + +$plugin = get_entity($plugin_guid); + +if (!($plugin instanceof ElggPlugin)) { + register_error(elgg_echo('admin:plugins:set_priority:no', array($plugin_guid))); + forward(REFERER); +} + +if ($plugin->setPriority($priority)) { + //system_message(elgg_echo('admin:plugins:set_priority:yes', array($plugin->manifest->getName()))); +} else { + register_error(elgg_echo('admin:plugins:set_priority:no', array($plugin->manifest->getName()))); +} + +elgg_delete_admin_notice('first_installation_plugin_reminder'); + +// don't regenerate the simplecache because the plugin won't be +// loaded until next run. Just invalidate and let it regnerate as needed +elgg_invalidate_simplecache(); +elgg_filepath_cache_reset(); + +forward(REFERER);
\ No newline at end of file diff --git a/actions/admin/plugins/simple_update_states.php b/actions/admin/plugins/simple_update_states.php index 7d01e4a46..216a458f4 100644 --- a/actions/admin/plugins/simple_update_states.php +++ b/actions/admin/plugins/simple_update_states.php @@ -1,48 +1,44 @@ <?php /** - * Bulk enable and disable for plugins appearing in the "simple" interface. + * Bulk activate/deactivate for plugins appearing in the "simple" interface. * - * Plugins marked as using the "simple" interface can be enabled and disabled - * en masse by passing the enabled plugins as an array of their plugin ids - * (directory names) through $_REQUEST['enabled_plugins']. All "simple" plugins - * not in this array will be disabled. + * Plugins marked as using the "simple" interface can be activated/deactivated + * en masse by passing the plugins to activate as an array of their plugin guids + * in $_REQUEST['enabled_plugins']. All "simple" plugins not in this array will be + * deactivated. * * Simplecache and views cache are reset. * - * @uses array $_REQUEST['enabled_plugins'] An array of plugin ids (directory names) to enable. + * @uses array $_REQUEST['activated_plugin_guids'] Array of plugin guids to activate. * * @since 1.8 * @package Elgg.Core - * @subpackage Administration.Site + * @subpackage Administration.Plugins */ -$installed_plugins = get_installed_plugins(); -$enabled_plugins = get_input('enabled_plugins', array()); - +$active_plugin_guids = get_input('active_plugin_guids', array()); +$installed_plugins = elgg_get_plugins('any'); $success = TRUE; -foreach ($installed_plugins as $plugin => $info) { +foreach ($installed_plugins as $plugin) { // this is only for simple plugins. - $interface_type = elgg_get_array_value('admin_interface', $info['manifest'], NULL); - if (!$interface_type || $interface_type != 'simple') { + if ($plugin->manifest->getAdminInterface() != 'simple') { continue; } - $plugin_enabled = is_plugin_enabled($plugin); - // only effect changes to plugins not already in that state. - if ($plugin_enabled && !in_array($plugin, $enabled_plugins)) { - $success = $success && disable_plugin($plugin); - } elseif (!$plugin_enabled && in_array($plugin, $enabled_plugins)) { - $success = $success && enable_plugin($plugin); + if ($plugin->isActive() && !in_array($plugin->guid, $active_plugin_guids)) { + $success = $success && $plugin->deactivate(); + } elseif (!$plugin->isActive() && in_array($plugin->guid, $active_plugin_guids)) { + $success = $success && $plugin->activate(); } } if ($success) { elgg_delete_admin_notice('first_installation_plugin_reminder'); - system_message(elgg_echo('admin:plugins:simple_simple_success')); + //system_message(elgg_echo('admin:plugins:simple_simple_success')); } else { - register_error(elgg_echo('admins:plugins:simple_simple_fail')); + register_error(elgg_echo('admin:plugins:simple_simple_fail')); } // don't regenerate the simplecache because the plugin won't be 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 + ); } /** diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index cfb27cd8c..9a3dd630a 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -727,23 +727,132 @@ function elgg_get_plugins_provides($type = null, $name = null) { * @param string $version A version to check against * @param string $comparison The comparison operator to use in version_compare() * - * @return bool + * @return array An array in the form array( + * 'status' => bool Does the provide exist?, + * 'value' => string The version provided + * ) * @since 1.8 */ function elgg_check_plugins_provides($type, $name, $version = null, $comparison = 'ge') { if (!$provided = elgg_get_plugins_provides($type, $name)) { - return false; + return array( + 'status' => false, + 'version' => '' + ); } if ($provided) { + $version = $provided['version']; if ($version) { - return version_compare($provided['version'], $version, $comparison); + $status = version_compare($provided['version'], $version, $comparison); } else { - return true; + $status = true; } } + + return array( + 'status' => $r, + 'value' => $version + ); +} + +/** + * Returns an array of parsed strings for a dependency in the + * format: array( + * 'type' => requires, conflicts, or provides. + * 'name' => The name of the requirement / conflict + * 'value' => A string representing the expected value: <1, >=3, !=enabled + * 'local_value' => The current value, ("Not installed") + * 'comment' => Free form text to help resovle the problem ("Enable / Search for plugin <link>") + * ) + * + * @param array $dep An ElggPluginPackage dependency array + * @return array + */ +function elgg_get_plugin_dependency_strings($dep) { + $dep_system = elgg_get_array_value('type', $dep); + $info = elgg_get_array_value('dep', $dep); + $type = elgg_get_array_value('type', $info); + + if (!$dep_system || !$info || !$type) { + return false; + } + + // rewrite some of these to be more readable + switch($info['comparison']) { + case 'lt': + $comparison = '<'; + break; + case 'gt': + $comparison = '>'; + break; + case 'ge': + $comparison = '>='; + break; + case 'le': + $comparison = '<='; + break; + default; + $comparison = $info['comparison']; + break; + } + + /* + 'requires' 'plugin oauth_lib' <1.3 1.3 'downgrade' + 'requires' 'php setting bob' >3 3 'change it' + 'conflicts' 'php setting' >3 4 'change it' + 'provides' 'plugin oauth_lib' 1.3 -- -- + */ + $strings = array(); + $strings['type'] = elgg_echo('ElggPlugin:Dependencies:' . ucwords($dep_system)); + + switch ($type) { + case 'elgg_version': + case 'elgg_release': + // 'Elgg Version' + $strings['name'] = elgg_echo('ElggPlugin:Dependencies:Elgg'); + $strings['value'] = "$comparison {$info['version']}"; + $strings['local_value'] = $dep['value']; + $strings['comment'] = ''; + break; + + case 'php_extension': + // PHP Extension %s [version] + $strings['name'] = elgg_echo('ElggPlugin:Dependencies:PhpExtension', array($info['name'])); + if ($info['version']) { + $strings['value'] = "$comparison {$info['version']}"; + $strings['local_value'] = $dep['value']; + } else { + $strings['value'] = ''; + $strings['local_value'] = ''; + } + $strings['comment'] = ''; + break; + + case 'php_ini': + $strings['name'] = elgg_echo('ElggPlugin:Dependencies:PhpIni', array($info['name'])); + $strings['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['local_value'] = $dep['version']; + $strings['comment'] = ''; + break; + } + + if ($dep['status']) { + $strings['comment'] = elgg_echo('ok'); + } + + return $strings; } + + /** * Shorthand function for finding the plugin settings. * @@ -1208,12 +1317,12 @@ function plugin_init() { elgg_register_action("plugins/settings/save", '', 'admin'); elgg_register_action("plugins/usersettings/save"); - elgg_register_action('admin/plugins/enable', '', 'admin'); - elgg_register_action('admin/plugins/disable', '', 'admin'); - elgg_register_action('admin/plugins/enableall', '', 'admin'); - elgg_register_action('admin/plugins/disableall', '', 'admin'); + elgg_register_action('admin/plugins/activate', '', 'admin'); + elgg_register_action('admin/plugins/deactivate', '', 'admin'); + elgg_register_action('admin/plugins/activate_all', '', 'admin'); + elgg_register_action('admin/plugins/deactivate_all', '', 'admin'); - elgg_register_action('admin/plugins/reorder', '', 'admin'); + elgg_register_action('admin/plugins/set_priority', '', 'admin'); } elgg_register_event_handler('init', 'system', 'plugin_init');
\ No newline at end of file diff --git a/languages/en.php b/languages/en.php index 7199f5aa9..10a99f9d3 100644 --- a/languages/en.php +++ b/languages/en.php @@ -83,51 +83,15 @@ $english = array( 'PluginException:NoAvailableParser' => 'Cannot find a parser for manifest API version %s in plugin %s.', 'PluginException:ParserErrorMissingRequiredAttribute' => "Missing required '%s' attribute in manifest for plugin %s.", - 'ElggPluginPackage:UnknownDep' => 'Unknown dependency %s in plugin %s', - - 'ElggPluginPackage:Requires:Plugin:lt' => '%s requires the %s plugin below version %s. Version %s is installed.', - 'ElggPluginPackage:Requires:Plugin:le' => '%s requires the %s plugin version %s or below. Version %s is installed.', - 'ElggPluginPackage:Requires:Plugin:=' => '%s requires the %s plugin version %s. Version %s is installed.', - 'ElggPluginPackage:Requires:Plugin:!=' => '%s requires the %s plugin not equal to version %s. Version %s is installed.', - 'ElggPluginPackage:Requires:Plugin:ge' => '%s requires the %s plugin version %s or higher. Version %s is installed.', - 'ElggPluginPackage:Requires:Plugin:gt' => '%s requires the %s plugin higher than version %s. Version %s is installed.', - - 'ElggPluginPackage:Requires:Plugin:NotEnabled:lt' => '%s requires the %s plugin below version %s.', - 'ElggPluginPackage:Requires:Plugin:NotEnabled:le' => '%s requires the %s plugin version %s or below.', - 'ElggPluginPackage:Requires:Plugin:NotEnabled:=' => '%s requires the %s plugin version %s.', - 'ElggPluginPackage:Requires:Plugin:NotEnabled:!=' => '%s requires the %s plugin not equal to version %s.', - 'ElggPluginPackage:Requires:Plugin:NotEnabled:ge' => '%s requires the %s plugin version %s or higher.', - 'ElggPluginPackage:Requires:Plugin:NotEnabled:gt' => '%s requires the %s plugin higher than version %s.', - 'ElggPluginPackage:Requires:Plugin:NotEnabled:NoVersion' => '%s requires the %s plugin.', - - 'ElggPluginPackage:Requires:Elgg:lt' => '%s requires Elgg below version %s.', - 'ElggPluginPackage:Requires:Elgg:le' => '%s requires Elgg %s or below.', - 'ElggPluginPackage:Requires:Elgg:=' => '%s requires Elgg version %s.', - 'ElggPluginPackage:Requires:Elgg:!=' => '%s requires Elgg not equal to version %s.', - 'ElggPluginPackage:Requires:Elgg:ge' => '%s requires Elgg version %s or higher.', - 'ElggPluginPackage:Requires:Elgg:gt' => '%s requires Elgg higher than version %s.', - - 'ElggPluginPackage:Requires:PhpExtension:NotInstalled:lt' => '%s requires the %s PHP extension below version %s.', - 'ElggPluginPackage:Requires:PhpExtension:NotInstalled:le' => '%s requires the %s PHP extension version %s or below.', - 'ElggPluginPackage:Requires:PhpExtension:NotInstalled:=' => '%s requires the %s PHP extension version %s.', - 'ElggPluginPackage:Requires:PhpExtension:NotInstalled:!=' => '%s requires the %s PHP extension not equal to version %s.', - 'ElggPluginPackage:Requires:PhpExtension:NotInstalled:ge' => '%s requires the %s PHP extension version %s or higher.', - 'ElggPluginPackage:Requires:PhpExtension:NotInstalled:gt' => '%s requires the %s PHP extension higher than version %s.', - 'ElggPluginPackage:Requires:PhpExtension:NotInstalled:NoVersion' => '%s requires the %s PHP extension.', - - 'ElggPluginPackage:Requires:PhpExtension:lt' => '%s requires the %s PHP extension below version %s. Version %s is installed.', - 'ElggPluginPackage:Requires:PhpExtension:le' => '%s requires the %s PHP extension version %s or below. Version %s is installed.', - 'ElggPluginPackage:Requires:PhpExtension:=' => '%s requires the %s PHP extension version %s. Version %s is installed.', - 'ElggPluginPackage:Requires:PhpExtension:!=' => '%s requires the %s PHP extension not equal to version %s. Version %s is installed.', - 'ElggPluginPackage:Requires:PhpExtension:ge' => '%s requires the %s PHP extension version %s or higher. Version %s is installed.', - 'ElggPluginPackage:Requires:PhpExtension:gt' => '%s requires the %s PHP extension higher than version %s. Version %s is installed.', - - 'ElggPluginPackage:Requires:PhpIni:lt' => '%s requires the %s php.ini option set less than %s. Currently set to %s.', - 'ElggPluginPackage:Requires:PhpIni:le' => '%s requires the %s php.ini option set less than or equal to %s. Currently set to %s.', - 'ElggPluginPackage:Requires:PhpIni:=' => '%s requires the %s php.ini option set to %s. Currently set to %s.', - 'ElggPluginPackage:Requires:PhpIni:!=' => '%s requires the %s php.ini option not set to %s. Currently set to %s.', - 'ElggPluginPackage:Requires:PhpIni:ge' => '%s requires the %s php.ini option set greater than or equal to %s. Currently set to %s.', - 'ElggPluginPackage:Requires:PhpIni:gt' => '%s requires the %s php.ini option set greater than %s. Currently set to %s.', + 'ElggPlugin:Dependencies:Requires' => 'Requires', + 'ElggPlugin:Dependencies:Conflicts' => 'Conflicts', + 'ElggPlugin:Dependencies:Provides' => 'Provides', + + 'ElggPlugin:Dependencies:Elgg' => 'Elgg version', + 'ElggPlugin:Dependencies:PhpExtension' => 'PHP extension: %s', + 'ElggPlugin:Dependencies:PhpIni' => 'PHP ini setting: %s', + 'ElggPlugin:Dependencies:Plugin' => 'Plugin: %s', + 'InvalidParameterException:NonElggUser' => "Passing a non-ElggUser to an ElggUser constructor!", @@ -578,6 +542,8 @@ $english = array( 'item:object:plugin' => 'Plugins', 'admin:plugins' => "Plugins", + 'admin:plugins:activate_all' => 'Activate All', + 'admin:plugins:deactivate_all' => 'Deactivate All', 'admin:plugins:description' => "This admin panel allows you to control and configure tools installed on your site.", 'admin:plugins:opt:linktext' => "Configure tools...", 'admin:plugins:opt:description' => "Configure the tools installed on the site. ", @@ -588,15 +554,19 @@ $english = array( 'admin:plugins:label:website' => "URL", 'admin:plugins:label:moreinfo' => 'more info', 'admin:plugins:label:version' => 'Version', - 'admin:plugins:label:directory' => 'Directory', - 'admin:plugins:warning:elggversionunknown' => 'Warning: This plugin does not specify a compatible Elgg version.', - 'admin:plugins:warning:elggtoolow' => 'Warning: This plugin requires a later version of Elgg!', - 'admin:plugins:reorder:yes' => "Plugin %s was reordered successfully.", - 'admin:plugins:reorder:no' => "Plugin %s could not be reordered.", - 'admin:plugins:disable:yes' => "Plugin %s was disabled successfully.", - 'admin:plugins:disable:no' => "Plugin %s could not be disabled.", - 'admin:plugins:enable:yes' => "Plugin %s was enabled successfully.", - 'admin:plugins:enable:no' => "Plugin %s could not be enabled.", + 'admin:plugins:label:location' => 'Location', + 'admin:plugins:label:dependencies' => 'Dependencies', + + 'admin:plugins:warning:elgg_version_unknown' => 'This plugin uses a legacy manifest file and does not specify a compatible Elgg version. It probably will not work!', + 'admin:plugins:warning:unmet_dependencies' => 'This plugin has unmet dependencies and cannot be activated. Check dependencies under more info.', + 'admin:plugins:cannot_activate' => 'Cannot Activate', + + 'admin:plugins:set_priority:yes' => "Reordered %s.", + 'admin:plugins:set_priority:no' => "Could not reorder %s.", + 'admin:plugins:deactivate:yes' => "Deactivated %s.", + 'admin:plugins:deactivate:no' => "Could not deactivate %s.", + 'admin:plugins:activate:yes' => "Activated %s.", + 'admin:plugins:activate:no' => "Could not activate %s.", 'admin:plugins:categories:all' => 'All categories', 'admin:plugins:plugin_website' => 'Plugin website', 'admin:plugins:author' => '%s', @@ -606,6 +576,13 @@ $english = array( 'admin:plugin_settings' => 'Plugin Settings', 'admin:plugins:simple_simple_fail' => 'Could not save settings.', 'admin:plugins:simple_simple_success' => 'Settings saved.', + 'admin:plugins:simple:cannot_activate' => 'Cannot activate this plugin. Check the advanced plugin admin area for more information.', + + 'admin:plugins:dependencies:type' => 'Type', + 'admin:plugins:dependencies:name' => 'Name', + 'admin:plugins:dependencies:value' => 'Value', + 'admin:plugins:dependencies:local_value' => 'Actual value', + 'admin:plugins:dependencies:comment' => 'Comment', 'admin:statistics' => "Statistics", 'admin:statistics:description' => "This is an overview of statistics on your site. If you need more detailed statistics, a professional administration feature is available.", @@ -766,10 +743,6 @@ $english = array( 'content:latest:blurb' => 'Alternatively, click here to view the latest content from across the site.', 'link:text' => 'view link', - - 'enableall' => 'Enable All', - 'disableall' => 'Disable All', - /** * Generic questions */ diff --git a/mod/profile/manifest.xml b/mod/profile/manifest.xml index a1307f24d..f857f28e7 100644 --- a/mod/profile/manifest.xml +++ b/mod/profile/manifest.xml @@ -1,14 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> -<plugin_manifest> - <field key="author" value="Curverider ltd" /> - <field key="version" value="1.8" /> - <field key="category" value="bundled" /> - <field key="category" value="social" /> - <field key="description" value="Elgg profile plugin." /> - <field key="website" value="http://www.elgg.org/" /> - <field key="copyright" value="(C) Curverider 2008-2010" /> - <field key="licence" value="GNU Public License version 2" /> - <field key="elgg_version" value="2010030101" /> - <field key="elgg_install_state" value="enabled" /> - <field key="admin_interface" value="advanced" /> +<plugin_manifest version="1.8"> + <name>Profile</name> + <description>The default profile plugin.</description> + <author>Elgg.org</author> + <version>1.8</version> + <category>bundled</category> + <category>social</category> + <website>http://elgg.org/</website> + <copyright>(C) The Elgg Foundation and others</copyright> + <license>GNU Public License Version 2</license> + <activate_on_install>true</activate_on_install> + <admin_interface>advanced</admin_interface> + + <requires> + <type>elgg_version</type> + <version>3009030802</version> + </requires> </plugin_manifest> diff --git a/views/default/admin/components/plugin.php b/views/default/admin/components/plugin.php index ae611af07..d190e94a5 100644 --- a/views/default/admin/components/plugin.php +++ b/views/default/admin/components/plugin.php @@ -2,152 +2,218 @@ /** * Elgg plugin manifest class * - * This file renders a plugin for the admin screen, including active/deactive, manifest details & display plugin - * settings. + * This file renders a plugin for the admin screen, including active/deactive, + * manifest details & display plugin settings. * - * @package Elgg - * @subpackage Core + * @package Elgg.Core + * @subpackage Plugins */ $plugin = $vars['plugin']; -$details = $vars['details']; - -$active = $details['active']; -$manifest = $details['manifest']; - -$plugin_pretty_name = (isset($manifest['name'])) ? $manifest['name'] : $plugin; - -// Check elgg version if available -$version_check_valid = false; -if ($manifest['elgg_version']) { - $version_check_valid = check_plugin_compatibility($manifest['elgg_version']); -} +$priority = $plugin->getPriority(); +$active = $plugin->isActive(); +$name = $plugin->manifest->getName(); +$can_activate = $plugin->canActivate(); +$max_priority = elgg_get_max_plugin_priority(); +$actions_base = '/action/admin/plugins/'; $ts = time(); $token = generate_action_token($ts); -$active_class = ($active) ? 'active' : 'not_active'; - -$top_url = $up_url = $down_url = $bottom_url = ''; -if ($vars['order'] > 10) { - $top_url = elgg_get_site_url()."action/admin/plugins/reorder?plugin={$plugin}&order=1&__elgg_token=$token&__elgg_ts=$ts"; - $top_link = '<a href="' . elgg_format_url($top_url) . '">' . elgg_echo('top') . '</a>'; - - $order = $vars['order'] - 11; - - $up_url = elgg_get_site_url()."action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts"; - $up_link = '<a href="' . elgg_format_url($up_url) . '">' . elgg_echo('up') . '</a>'; +$active_class = ($active && $can_activate) ? 'active' : 'not_active'; + +// build reordering links +$links = ''; + +// top and up link only if not at top +if ($priority > 1) { + $top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => 'first', + 'is_action' => true + )); + + $links .= elgg_view('output/url', array( + 'href' => $top_url, + 'text' => elgg_echo('top'), + 'is_action' => true + )); + + $up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => '-1', + 'is_action' => true + )); + + $links .= elgg_view('output/url', array( + 'href' => $up_url, + 'text' => elgg_echo('up'), + 'is_action' => true + )); } -if ($vars['order'] < $vars['maxorder']) { - $order = $vars['order'] + 11; - $down_url = elgg_get_site_url()."action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts"; - $down_link = '<a href="' . elgg_format_url($down_url) . '">' . elgg_echo('down') . '</a>'; - - $order = $vars['maxorder'] + 11; - $bottom_url = elgg_get_site_url()."action/admin/plugins/reorder?plugin={$plugin}&order=$order&__elgg_token=$token&__elgg_ts=$ts"; - $bottom_link = '<a href="' . elgg_format_url($bottom_url) . '">' . elgg_echo('bottom') . '</a>'; +// down and bottom links only if not at bottom +if ($priority < $max_priority) { + $down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => '+1', + 'is_action' => true + )); + + $links .= elgg_view('output/url', array( + 'href' => $down_url, + 'text' => elgg_echo('down'), + 'is_action' => true + )); + + $bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array( + 'plugin_guid' => $plugin->guid, + 'priority' => 'last', + 'is_action' => true + )); + + $links .= elgg_view('output/url', array( + 'href' => $bottom_url, + 'text' => elgg_echo('bottom'), + 'is_action' => true + )); } -if ($active) { - $url = elgg_get_site_url()."action/admin/plugins/disable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts"; - $enable_disable = '<a class="elgg-button elgg-cancel-button" href="' . elgg_format_url($url) . '">' . elgg_echo('disable') . '</a>'; +// activate / deactivate links +if ($can_activate) { + if ($active) { + $action = 'deactivate'; + $class = 'elgg-cancel-button'; + } else { + $action = 'activate'; + $class = 'elgg-submit-button'; + } + + $url = elgg_http_add_url_query_elements($actions_base . $action, array( + 'plugin_guids[]' => $plugin->guid, + 'is_action' => true + )); + + $action_button = elgg_view('output/url', array( + 'href' => $url, + 'text' => elgg_echo($action), + 'is_action' => true, + 'class' => "elgg-button $class" + )); } else { - $url = elgg_get_site_url()."action/admin/plugins/enable?plugin=$plugin&__elgg_token=$token&__elgg_ts=$ts"; - $enable_disable = '<a class="elgg-button elgg-submit-button" href="' . elgg_format_url($url) . '">' . elgg_echo('enable') . '</a>'; + $action_button = elgg_view('output/url', array( + 'text' => elgg_echo('admin:plugins:cannot_activate'), + 'disabled' => 'disabled', + 'class' => "elgg-action-button disabled" + )); } - -$categories_list = ''; -if ($manifest['category']) { +// Display categories +$categories = $plugin->manifest->getCategories(); +$categories_html = ''; +if ($categories) { $categories_arr = array(); - $base_url = elgg_get_site_url()."pg/admin/plugins?category="; + $base_url = elgg_get_site_url() . "pg/admin/plugins?category="; - foreach($manifest['category'] as $category) { + foreach ($categories as $category) { $url = $base_url . urlencode($category); $categories_arr[] = "<a href=\"$url\">" . htmlspecialchars($category) . '</a>'; } - $categories_list = implode(', ', $categories_arr); + $categories_html = implode(', ', $categories_arr); } -$screenshots = ''; -if ($manifest['screenshot']) { - $base_url = elgg_get_site_url()."mod/"; - +// @todo We need to make a page handler to read these files in. +// this is broken. +$screenshot_html = ''; +$screenshots = $plugin->manifest->getScreenshots(); +if ($screenshots) { + $base_url = elgg_get_plugin_path() . $plugin->getID() . '/'; $limit = 4; - foreach ($manifest['screenshot'] as $screenshot) { + foreach ($screenshots as $screenshot) { if ($limit <= 0) { break; } - $screenshot_src = $base_url . $plugin . "/$screenshot"; - $screenshots .= "<li class=\"plugin_screenshot\"><a href=\"$screenshot_src\"><img src=\"$screenshot_src\"></a></li>"; + $screenshot_src = $plugin->getPath() . $screenshot['path']; + $screenshots .= "<li class=\"plugin-screenshot\"><a href=\"$screenshot_src\"><img src=\"$screenshot_src\"></a></li>"; $limit--; } } +// metadata +$description = elgg_view('output/longtext', array('value' => $plugin->manifest->getDescription())); +$author = '<span>' . elgg_echo('admin:plugins:label:author') . '</span>: ' + . elgg_view('output/text', array('value' => $plugin->manifest->getAuthor())); +$version = htmlspecialchars($plugin->manifest->getVersion()); +$website = elgg_view('output/url', array( + 'href' => $plugin->manifest->getWebsite(), + 'text' => $plugin->manifest->getWebsite() +)); + +$copyright = elgg_view('output/text', array('value' => $plugin->manifest->getCopyright())); +$license = elgg_view('output/text', array('value' => $plugin->manifest->getLicense())); + ?> <div class="plugin_details <?php echo $active_class ?>"> <div class="admin_plugin_reorder"> - <?php echo "$top_link $up_link $down_link $bottom_link"; ?> + <?php echo "$links"; ?> </div><div class="clearfloat"></div> - <div class="admin_plugin_enable_disable"><?php echo $enable_disable; ?></div> + <div class="admin_plugin_enable_disable"><?php echo $action_button; ?></div> - <?php - if (elgg_view_exists("settings/{$plugin}/edit")) { - $link = elgg_get_site_url()."pg/admin/plugin_settings/$plugin"; - $settings_link = "<a class='plugin_settings small link' href='$link'>[". elgg_echo('settings') ."]</a>"; - } - ?> - <h3><?php echo "$plugin_pretty_name $settings_link"; ?></h3> - <?php - echo $settings_panel; +<?php +$settings_view = 'settings/' . $plugin->getID() . '/edit'; +if (elgg_view_exists($settings_view)) { + $link = elgg_get_site_url() . "pg/admin/plugin_settings/" . $plugin->getID(); + $settings_link = "<a class='plugin_settings small link' href='$link'>[" . elgg_echo('settings') . "]</a>"; +} +?> + <h3><?php echo $plugin->manifest->getName() . " $version $settings_link"; ?></h3> + <div class="plugin_description"><?php echo $description; ?></div> + <p class="plugin_author"><?php echo $author . ' - ' . $website; ?></p> + + <?php + if ($plugin->manifest->getApiVersion() < 1.8) { + $reqs = $plugin->manifest->getRequires(); + if (!$reqs) { + $message = elgg_echo('admin:plugins:warning:elgg_version_unknown'); + echo "<p class=\"plugin-cannot-activate\">$message</p>"; + } + } - if ($manifest) { + if (!$can_activate) { + $message = elgg_echo('admin:plugins:warning:unmet_dependencies'); + echo "<p class=\"plugin-cannot-activate\">$message</p>"; + } ?> - <div class="plugin_description"><?php echo elgg_view('output/longtext',array('value' => $manifest['description'])); ?></div> - <p class="plugin_author"><span><?php echo elgg_echo('admin:plugins:label:author') . "</span>: ". htmlspecialchars($manifest['author']) ?></p> - <p class="plugin_version"><span><?php echo elgg_echo('admin:plugins:label:version') . "</span>: ". htmlspecialchars($manifest['version']) ?></p> <p><a class="manifest_details small link"><?php echo elgg_echo("admin:plugins:label:moreinfo"); ?></a></p> <div class="manifest_file hidden"> + <div><?php echo elgg_echo('admin:plugins:label:location') . ": " . htmlspecialchars($plugin->getPath()) ?></div> <?php - if ((!$version_check_valid) || (!isset($manifest['elgg_version']))) { + if ($categories_html) { ?> - <div id="version_check"> - <?php - if (!isset($manifest['elgg_version'])) { - echo elgg_echo('admin:plugins:warning:elggversionunknown'); - } else { - echo elgg_echo('admin:plugins:warning:elggtoolow'); - } - ?> - </div> + <div><?php echo elgg_echo('admin:plugins:label:categories') . ": " . $categories_html; ?></div> <?php } - ?> - <div><?php echo elgg_echo('admin:plugins:label:directory') . ": ". htmlspecialchars($plugin) ?></div> - <?php - if ($categories_list) { - ?> - <div><?php echo elgg_echo('admin:plugins:label:categories') . ": ". $categories_list ?></div> - <?php - } if ($screenshots) { ?> <div><ul><?php echo $screenshots; ?></ul></div> <?php } ?> - <div><?php echo elgg_echo('admin:plugins:label:copyright') . ": ". htmlspecialchars($manifest['copyright']) ?></div> - <div><?php echo elgg_echo('admin:plugins:label:licence') . ": ". htmlspecialchars($manifest['licence'] . $manifest['license']) ?></div> - <div><?php echo elgg_echo('admin:plugins:label:website') . ": "; ?><a href="<?php echo $manifest['website']; ?>"><?php echo $manifest['website']; ?></a></div> - <?php } ?> + <div><?php echo elgg_echo('admin:plugins:label:copyright') . ": " . $copyright; ?></div> + <div><?php echo elgg_echo('admin:plugins:label:licence') . ": " . $license; ?></div> + + <div><?php echo elgg_echo('admin:plugins:label:dependencies'); ?>: + <?php + echo elgg_view('admin/components/plugin_dependencies', array('plugin' => $plugin)); + ?> + </div> </div> </div>
\ No newline at end of file diff --git a/views/default/admin/components/plugin_dependencies.php b/views/default/admin/components/plugin_dependencies.php new file mode 100644 index 000000000..9e0e284f1 --- /dev/null +++ b/views/default/admin/components/plugin_dependencies.php @@ -0,0 +1,45 @@ +<?php +/** + * Shows a table of plugin dependecies for ElggPlugin in $vars['plugin']. + * + * This uses a table because it's a table of data. + * + * @package Elgg.Core + * @subpackage Admin.Plugins + */ + +$plugin = elgg_get_array_value('plugin', $vars, false); +$deps = $plugin->package->checkDependencies(true); + +$columns = array('type', 'name', 'value', 'local_value', 'comment'); + +echo '<table class="elgg-plugins-dependencies styled"> + <tr> +'; + +foreach ($columns as $column) { + $column = elgg_echo("admin:plugins:dependencies:$column"); + echo "<th>$column</th>"; +} + +echo '<tr/>'; + +foreach ($deps as $dep) { + $fields = elgg_get_plugin_dependency_strings($dep); + + if ($dep['status']) { + $class = 'elgg-satisfied-dependency'; + } else { + $class = 'elgg-unsatisfied-dependency'; + } + + echo "<tr class=\"$class\">"; + + foreach ($columns as $column) { + echo "<td class=\"pam \">{$fields[$column]}</td>"; + } + + echo '</tr>'; +} + +echo '</table>';
\ No newline at end of file diff --git a/views/default/admin/plugins/advanced.php b/views/default/admin/plugins/advanced.php index ead930090..1138ace4f 100644 --- a/views/default/admin/plugins/advanced.php +++ b/views/default/admin/plugins/advanced.php @@ -4,25 +4,25 @@ * * Shows a list of all plugins sorted by load order. * - * @package Elgg - * @subpackage Core + * @package Elgg.Core + * @subpackage Admin.Plugins */ -regenerate_plugin_list(); -$installed_plugins = get_installed_plugins(); -$plugin_list = array(); -$show_category = get_input('category', NULL); +elgg_generate_plugin_entities(); +$installed_plugins = elgg_get_plugins('any'); +$show_category = get_input('category', null); // Get a list of the all categories // and trim down the plugin list if we're not viewing all categories. // @todo this could be cached somewhere after have the manifest loaded $categories = array(); -foreach ($installed_plugins as $id => $plugin) { - $plugin_categories = $plugin['manifest']['category']; +foreach ($installed_plugins as $plugin) { + $plugin_categories = $plugin->manifest->getCategories(); // handle plugins that don't declare categories - if ((!$plugin_categories && $show_category) || ($show_category && !in_array($show_category, $plugin_categories))) { + // unset them here because this is the list we foreach + if ($show_category && !in_array($show_category, $plugin_categories)) { unset($installed_plugins[$id]); } @@ -57,9 +57,13 @@ $category_form = elgg_view('input/form', array( // Page Header elements $title = elgg_view_title(elgg_echo('admin:plugins')); -// @todo Until "en/disable all" means "All plugins on this page" hide when not looking at all. +// @todo Until "en/deactivate all" means "All plugins on this page" hide when not looking at all. if (!isset($show_category) || empty($show_category)) { - $buttons = "<a class='elgg-action-button' href=\"{$CONFIG->url}action/admin/plugins/enableall?__elgg_token=$token&__elgg_ts=$ts\">".elgg_echo('enableall')."</a> <a class='elgg-action-button disabled' href=\"{$CONFIG->url}action/admin/plugins/disableall?__elgg_token=$token&__elgg_ts=$ts\">".elgg_echo('disableall')."</a> "; + $activate_url = "{$CONFIG->url}action/admin/plugins/activate_all?__elgg_token=$token&__elgg_ts=$ts"; + $deactivate_url = "{$CONFIG->url}action/admin/plugins/deactivate_all?__elgg_token=$token&__elgg_ts=$ts"; + + $buttons = "<a class='elgg-action-button' href=\"$activate_url\">" . elgg_echo('admin:plugins:activate_all') . '</a> '; + $buttons .= "<a class='elgg-action-button disabled' href=\"$deactivate_url\">" . elgg_echo('admin:plugins:deactivate_all') . '</a> '; $buttons .= "<br /><br />"; } else { $buttons = ''; @@ -76,25 +80,12 @@ $buttons .= $category_form; <br /> <?php -$limit = get_input('limit', 10); -$offset = get_input('offset', 0); - -$plugin_list = get_plugin_list(); -$max = 0; -foreach($plugin_list as $key => $foo) { - if ($key > $max) $max = $key; -} - // Display list of plugins -$n = 0; -foreach ($installed_plugins as $plugin => $data) { +foreach ($installed_plugins as $plugin) { echo elgg_view('admin/components/plugin', array( 'plugin' => $plugin, - 'details' => $data, - 'maxorder' => $max, - 'order' => array_search($plugin, $plugin_list) + 'max_priority' => $max_priority )); - $n++; } ?> <script type="text/javascript"> diff --git a/views/default/admin/plugins/simple.php b/views/default/admin/plugins/simple.php index e53ecb0c1..d9be51a29 100644 --- a/views/default/admin/plugins/simple.php +++ b/views/default/admin/plugins/simple.php @@ -8,22 +8,20 @@ * @subpackage Core */ -regenerate_plugin_list(); -$installed_plugins = get_installed_plugins(); +elgg_generate_plugin_entities(); +$installed_plugins = elgg_get_plugins('any'); $plugin_list = array(); $title = elgg_view_title(elgg_echo('admin:plugins')); -foreach ($installed_plugins as $installed_name => $plugin) { - if (!isset($plugin['manifest']['admin_interface']) || $plugin['manifest']['admin_interface'] == 'advanced') { - continue; +foreach ($installed_plugins as $plugin) { + $interface = $plugin->manifest->getAdminInterface(); + if ($interface == 'simple') { + $plugin_list[$plugin->manifest->getName()] = $plugin; } - - $plugin['installed_name'] = $installed_name; - - $plugin_list[$plugin['manifest']['name']] = $plugin; } ksort($plugin_list); + $form_body .= <<<___END <div id="content_header" class="clearfix"> <div class="content-header-title">$title</div> @@ -31,10 +29,21 @@ $form_body .= <<<___END <ul class="admin_plugins margin-top"> ___END; -foreach ($plugin_list as $name => $info) { - $manifest = $info['manifest']; - $version_valid = (isset($manifest['elgg_version'])) ? check_plugin_compatibility($manifest['elgg_version']) : FALSE; - if ($info['active']) { +$actions_base = '/action/admin/plugins/'; +$ts = time(); +$token = generate_action_token($ts); + +foreach ($plugin_list as $name => $plugin) { + $plugin_guid = $plugin->guid; + $plugin_id = $plugin->getID(); + $active = $plugin->isActive(); + $can_activate = $plugin->canActivate(); + $author = $plugin->manifest->getAuthor(); + $version = $plugin->manifest->getVersion(); + $website = $plugin->manifest->getWebsite(); + $description = $plugin->manifest->getDescription(); + + if ($active) { $active_class = 'active'; $checked = 'checked="checked"'; } else { @@ -42,41 +51,50 @@ foreach ($plugin_list as $name => $info) { $checked = ''; } - $author = $link = $version = $settings = ''; + if ($can_activate) { + $disabled = ''; + } else { + $disabled = 'disabled="disabled"'; + $description .= '<p>' . elgg_echo('admin:plugins:simple:cannot_activate') . '</p>'; + } + + $description = elgg_view('output/longtext', array('value' => $description)); + + $author_html = $link_html = $version_html = $settings_html = ''; - if (isset($manifest['author'])) { - $author = elgg_echo('admin:plugins:author', array($manifest['author'])); + if ($author) { + $author_html = elgg_echo('admin:plugins:author', array($author)); } - if (isset($manifest['version'])) { - $version = ' | ' . elgg_echo('admin:plugins:version', array($manifest['version'])); + if ($version) { + $version_html = ' | ' . elgg_echo('admin:plugins:version', array($version)); } - if (isset($manifest['website'])) { - $link = " | <a href=\"{$manifest['website']}\">" . elgg_echo('admin:plugins:plugin_website') . '</a>'; + if ($website) { + $link_html = " | <a href=\"$website\">" . elgg_echo('admin:plugins:plugin_website') . '</a>'; } - if (elgg_view_exists("settings/{$info['installed_name']}/edit")) { - $settings_href = elgg_get_site_url()."pg/admin/plugin_settings/{$info['installed_name']}"; - $settings = " | <a class='plugin_settings link' href='$settings_href'>". elgg_echo('settings') ."</a>"; + if (elgg_view_exists("settings/$plugin_id/edit")) { + $settings_href = elgg_get_site_url() . "pg/admin/plugin_settings/$plugin_id"; + $settings_html = " | <a class='plugin_settings link' href='$settings_href'>" . elgg_echo('settings') . "</a>"; } $form_body .= <<<___END <li class="plugin_details $active_class"> <span class="plugin_controls"> - <input type="checkbox" id="{$info['installed_name']}" class="plugin_enabled" $checked name="enabled_plugins[]" value="{$info['installed_name']}"/> - <label for="{$info['installed_name']}">$name</label> + <input type="checkbox" id="$plugin_guid" class="plugin_enabled" $checked $disabled name="active_plugin_guids[]" value="$plugin_guid"/> + <label for="$plugin_guid">$name</label> </span> <span class="plugin_info"> <span class="plugin_description"> - {$manifest['description']} + $description </span> <span class="plugin_metadata small"> - $author - $version - $link - $settings + $author_html + $version_html + $link_html + $settings_html </span> </span> </li> |