[geeklog-cvs] geeklog: New plugin API function PLG_configChange (feature reque...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Mar 29 05:18:35 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/35f33c620315
changeset: 6866:35f33c620315
user: Dirk Haun <dirk at haun-online.de>
date: Sun Mar 29 11:18:09 2009 +0200
description:
New plugin API function PLG_configChange (feature request #0000694)
diffstat:
3 files changed, 54 insertions(+), 11 deletions(-)
public_html/admin/configuration.php | 34 +++++++++++++++++++++++-----------
public_html/docs/history | 1 +
system/lib-plugins.php | 30 ++++++++++++++++++++++++++++++
diffs (140 lines):
diff -r 1d4790466047 -r 35f33c620315 public_html/admin/configuration.php
--- a/public_html/admin/configuration.php Sat Mar 28 20:04:38 2009 +0100
+++ b/public_html/admin/configuration.php Sun Mar 29 11:18:09 2009 +0200
@@ -2,7 +2,7 @@
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
-// | Geeklog 1.5 |
+// | Geeklog 1.6 |
// +---------------------------------------------------------------------------+
// | configuration.php |
// | |
@@ -29,19 +29,18 @@
// | |
// +---------------------------------------------------------------------------+
+/**
+* Geeklog common function library
+*/
require_once '../lib-common.php';
require_once 'auth.inc.php';
-
-$conf_group = array_key_exists('conf_group', $_POST) ? $_POST['conf_group'] : 'Core';
-
-$config =& config::get_instance();
/**
* Helper function: Provide language dropdown
*
* NOTE: Note that key/value are being swapped!
*
-* @return Array Array of (filename, displayname) pairs
+* @return array Array of (filename, displayname) pairs
*
*/
function configmanager_select_language_helper()
@@ -56,7 +55,7 @@
*
* NOTE: Beautifying code duplicated from usersettings.php
*
-* @return Array Array of (filename, displayname) pairs
+* @return array Array of (filename, displayname) pairs
*
*/
function configmanager_select_theme_helper()
@@ -85,9 +84,15 @@
return $themes;
}
+
+// MAIN
+$display = '';
+
+$conf_group = array_key_exists('conf_group', $_POST)
+ ? $_POST['conf_group'] : 'Core';
+$config =& config::get_instance();
$tokenstate = SEC_checkToken();
-// MAIN
if (array_key_exists('set_action', $_POST) && $tokenstate){
if (SEC_inGroup('Root')) {
if ($_POST['set_action'] == 'restore') {
@@ -102,11 +107,18 @@
$result = null;
if (! array_key_exists('form_reset', $_POST)) {
$result = $config->updateConfig($_POST, $conf_group);
+
+ // notify plugins
+ if (is_array($result) && (count($result) > 0)) {
+ PLG_configChange($conf_group, array_keys($result));
+ }
}
- echo $config->get_ui($conf_group, $_POST['sub_group'], $result);
+ $display = $config->get_ui($conf_group, $_POST['sub_group'], $result);
} else {
- echo $config->get_ui($conf_group, array_key_exists('subgroup', $_POST) ?
- $_POST['subgroup'] : null);
+ $display = $config->get_ui($conf_group, array_key_exists('subgroup', $_POST)
+ ? $_POST['subgroup'] : null);
}
+echo $display;
+
?>
diff -r 1d4790466047 -r 35f33c620315 public_html/docs/history
--- a/public_html/docs/history Sat Mar 28 20:04:38 2009 +0100
+++ b/public_html/docs/history Sun Mar 29 11:18:09 2009 +0200
@@ -11,6 +11,7 @@
+ (TBD) Comment moderation and editable comments, by Jared Wenerd
Other changes:
+- New plugin API function PLG_configChange (feature request #0000694) [Dirk]
- Fixed layout of Batch Add and Batch Admin options of the User Manager [Dirk]
- On a login failure, the user registration form showed up even when new user
registration was disabled (bug #0000843)
diff -r 1d4790466047 -r 35f33c620315 system/lib-plugins.php
--- a/system/lib-plugins.php Sat Mar 28 20:04:38 2009 +0100
+++ b/system/lib-plugins.php Sun Mar 29 11:18:09 2009 +0200
@@ -77,6 +77,7 @@
* @param string $function_name holds name of function to call
* @return void
* @internal not to be used by plugins
+* @todo only supports functions without any parameters
*
*/
function PLG_callFunctionForAllPlugins($function_name)
@@ -2494,4 +2495,33 @@
return COM_refresh($url);
}
+/**
+* Inform plugins of configuration changes
+*
+* NOTE: Plugins will only be notified of 'Core' changes and changes in their
+* own configuration. Changes in other plugins will not be sent.
+*
+* @param string $group plugin name or 'Core' for $_CONF changes
+* @param array $changes names of config values that changed
+* @return void
+* @link http://wiki.geeklog.net/index.php/PLG_configChange
+*
+*/
+function PLG_configChange($group, $changes)
+{
+ global $_PLUGINS;
+
+ $args[1] = $group;
+ $args[2] = $changes;
+
+ if ($group == 'Core') {
+ foreach ($_PLUGINS as $pi_name) {
+ PLG_callFunctionForOnePlugin('plugin_configchange_' . $pi_name,
+ $args);
+ }
+ } else {
+ PLG_callFunctionForOnePlugin('plugin_configchange_' . $group, $args);
+ }
+}
+
?>
More information about the geeklog-cvs
mailing list