aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-20 15:11:42 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-20 15:11:42 +0000
commit44fedcf732370708395227b3fd89cb336389ec8e (patch)
tree8b9debc278f1770f52a79a42c595abdcd02e7513
parent2953dea01d0e6e01688b18627c384fddb637e8e1 (diff)
downloadelgg-44fedcf732370708395227b3fd89cb336389ec8e.tar.gz
elgg-44fedcf732370708395227b3fd89cb336389ec8e.tar.bz2
Closes #20: Plugin management and config panel
http://trac.elgg.org/elgg/ticket/20 git-svn-id: https://code.elgg.org/elgg/trunk@1027 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--actions/admin/plugins/disable.php29
-rw-r--r--actions/admin/plugins/enable.php29
-rw-r--r--admin/plugins/index.php5
-rw-r--r--engine/lib/plugins.php2
-rw-r--r--languages/en.php13
-rw-r--r--views/default/admin/plugins.php30
-rw-r--r--views/default/admin/plugins_opt/plugin.php46
-rw-r--r--views/default/object/plugin.php13
8 files changed, 157 insertions, 10 deletions
diff --git a/actions/admin/plugins/disable.php b/actions/admin/plugins/disable.php
new file mode 100644
index 000000000..6fd85b0eb
--- /dev/null
+++ b/actions/admin/plugins/disable.php
@@ -0,0 +1,29 @@
+<?php
+ /**
+ * Disable plugin action.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ require_once("../../../engine/start.php");
+
+ // block non-admin users
+ admin_gatekeeper();
+
+ // Get the user
+ $plugin = get_input('plugin');
+
+ // Disable
+ if (disable_plugin($plugin))
+ system_message(sprintf(elgg_echo('admin:plugins:disable:yes'), $plugin));
+ else
+ system_message(sprintf(elgg_echo('admin:plugins:disable:no'), $plugin));
+
+ header("Location: {$CONFIG->wwwroot}admin/plugins/");
+ exit;
+?> \ No newline at end of file
diff --git a/actions/admin/plugins/enable.php b/actions/admin/plugins/enable.php
new file mode 100644
index 000000000..a29ee5694
--- /dev/null
+++ b/actions/admin/plugins/enable.php
@@ -0,0 +1,29 @@
+<?php
+ /**
+ * Enable plugin action.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ require_once("../../../engine/start.php");
+
+ // block non-admin users
+ admin_gatekeeper();
+
+ // Get the user
+ $plugin = get_input('plugin');
+
+ // Disable
+ if (enable_plugin($plugin))
+ system_message(sprintf(elgg_echo('admin:plugins:enable:yes'), $plugin));
+ else
+ system_message(sprintf(elgg_echo('admin:plugins:enable:no'), $plugin));
+
+ header("Location: {$CONFIG->wwwroot}admin/plugins/");
+ exit;
+?> \ No newline at end of file
diff --git a/admin/plugins/index.php b/admin/plugins/index.php
index a369523b9..14d830840 100644
--- a/admin/plugins/index.php
+++ b/admin/plugins/index.php
@@ -18,10 +18,7 @@
// Make sure only valid admin users can see this
admin_gatekeeper();
- // get list of plugins, itterate through - permit enable/disable & further config.
-
-
// Display main admin menu
- page_draw(elgg_echo("admin:plugins"),elgg_view_layout("one_column", elgg_view("admin/plugins")));
+ page_draw(elgg_echo("admin:plugins"),elgg_view_layout("one_column", elgg_view("admin/plugins", array('installed_plugins' => get_installed_plugins()))));
?> \ No newline at end of file
diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php
index dd9a75e20..a91006e1b 100644
--- a/engine/lib/plugins.php
+++ b/engine/lib/plugins.php
@@ -265,6 +265,7 @@
{
global $CONFIG;
+ $plugin = sanitise_string($plugin);
$site_guid = (int) $site_guid;
if ($site_guid == 0)
$site_guid = $CONFIG->site_guid;
@@ -298,6 +299,7 @@
{
global $CONFIG;
+ $plugin = sanitise_string($plugin);
$site_guid = (int) $site_guid;
if ($site_guid == 0)
$site_guid = $CONFIG->site_guid;
diff --git a/languages/en.php b/languages/en.php
index f92755fe1..568132f16 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -246,7 +246,14 @@
'admin:plugins' => "Tool Administration",
'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. ",
+ 'admin:plugins:opt:description' => "Configure the tools installed on the site. ",
+ 'admin:plugins:label:author' => "Author",
+ 'admin:plugins:label:copyright' => "Copyright",
+ 'admin:plugins:label:website' => "URL",
+ '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:statistics' => "Statistics",
'admin:statistics:description' => "This admin panel will allow you to view statistics about your site.",
@@ -277,7 +284,9 @@
'delete' => "Delete",
'load' => "Load",
'upload' => "Upload",
- 'ban' => "Ban",
+ 'ban' => "Ban",
+ 'enable' => "Enable",
+ 'disable' => "Disable",
/**
* Generic data words
diff --git a/views/default/admin/plugins.php b/views/default/admin/plugins.php
index f5de338fc..5c8f7d1dd 100644
--- a/views/default/admin/plugins.php
+++ b/views/default/admin/plugins.php
@@ -14,9 +14,31 @@
// Description of what's going on
echo "<p>" . nl2br(elgg_echo("admin:plugins:description")) . "</p>";
+ $limit = get_input('limit', 10);
+ $offset = get_input('offset', 0);
-?>
- TODO: Writeme - add automatic plugin config
- Enable/disable is system level thing.
- Config is a link to a config/PLUGINNAME/view ...? with the plugin registering a config action?
+ // Get the installed plugins
+ $installed_plugins = $vars['installed_plugins'];
+ $count = count($installed_plugins);
+
+ // Display list of plugins
+ $n = 0;
+ foreach ($installed_plugins as $plugin => $data)
+ {
+ if (($n>=$offset) && ($n < $offset+$limit))
+ echo elgg_view("admin/plugins_opt/plugin", array('plugin' => $plugin, 'details' => $data));
+
+ $n++;
+ }
+
+ // Diplay nav
+ if ($count)
+ {
+ elgg_view('navigation/pagination',array(
+ 'baseurl' => $_SERVER['REQUEST_URI'],
+ 'offset' => $offset,
+ 'count' => $count,
+ ));
+ }
+?> \ No newline at end of file
diff --git a/views/default/admin/plugins_opt/plugin.php b/views/default/admin/plugins_opt/plugin.php
new file mode 100644
index 000000000..58bde4d67
--- /dev/null
+++ b/views/default/admin/plugins_opt/plugin.php
@@ -0,0 +1,46 @@
+<?php
+ /**
+ * Elgg plugin manifest class
+ *
+ * This file renders a plugin for the admin screen, including active/deactive, manifest details & display plugin
+ * settings.
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+
+ $plugin = $vars['plugin'];
+ $details = $vars['details'];
+
+ $active = $details['active'];
+ $manifest = $details['manifest'];
+?>
+<div id="plugin_details" class="<?php if ($active) echo "active"; else "not-active" ?>">
+ <div><h2><?php echo $plugin; ?></h2></div>
+
+ <?php if ($manifest) { ?>
+ <div><?php echo $manifest['description'] ?></div>
+ <div><?php echo elgg_echo('admin:plugins:label:author') . ": ". $manifest['author'] ?></div>
+ <div><?php echo elgg_echo('admin:plugins:label:copyright') . ": ". $manifest['copyright'] ?></div>
+ <div><?php echo elgg_echo('admin:plugins:label:website') . ": "; ?><a href="<?php echo $manifest['website']; ?>"><?php echo $manifest['website']; ?></a></div>
+ <?php } ?>
+
+ <?php if ($plugin_object = find_plugin_settings($plugin)) { ?>
+ <div id="<?php echo $plugin; ?>_settings">
+ <?php echo elgg_view("object/plugin", array('plugin_object' => $plugin_object)) ?>
+ </div>
+ <?php } ?>
+
+ <div>
+ <?php if ($active) { ?>
+ <a href="<?php echo $vars['url']; ?>actions/admin/plugins/disable?plugin=<?php echo $plugin; ?>"><?php echo elgg_echo("disable"); ?></a>
+ <?php } else { ?>
+ <a href="<?php echo $vars['url']; ?>actions/admin/plugins/enable?plugin=<?php echo $plugin; ?>"><?php echo elgg_echo("enable"); ?></a>
+ <?php } ?>
+ </div>
+</div> \ No newline at end of file
diff --git a/views/default/object/plugin.php b/views/default/object/plugin.php
new file mode 100644
index 000000000..552d42192
--- /dev/null
+++ b/views/default/object/plugin.php
@@ -0,0 +1,13 @@
+<?php
+ /**
+ * Elgg plugin
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Marcus Povey
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+?>
+// render a plugin & settings \ No newline at end of file