diff options
-rw-r--r-- | actions/plugins/settings/save.php | 36 | ||||
-rw-r--r-- | engine/lib/plugins.php | 11 | ||||
-rw-r--r-- | languages/en.php | 7 | ||||
-rw-r--r-- | views/default/admin/plugins_opt/plugin.php | 4 | ||||
-rw-r--r-- | views/default/object/plugin.php | 22 |
5 files changed, 73 insertions, 7 deletions
diff --git a/actions/plugins/settings/save.php b/actions/plugins/settings/save.php new file mode 100644 index 000000000..0a8991641 --- /dev/null +++ b/actions/plugins/settings/save.php @@ -0,0 +1,36 @@ +<?php + /** + * Elgg plugin settings save 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/ + */ + + $params = get_input('params'); + $plugin = get_input('plugin'); + + $result = false; + + foreach ($params as $k => $v) + { + // Save + $result = set_plugin_setting($k, $v, $plugin); + + // Error? + if (!$result) + { + system_message(sprintf(elgg_echo('plugins:settings:save:fail'), $plugin)); + + forward($_SERVER['HTTP_REFERER']); + + exit; + } + } + + system_message(sprintf(elgg_echo('plugins:settings:save:ok'), $plugin)); + forward($_SERVER['HTTP_REFERER']); +?>
\ No newline at end of file diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index a91006e1b..51488434c 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -163,7 +163,7 @@ if ($plugins) { - foreach ($plugins as $plugins) + foreach ($plugins as $plugin) if (strcmp($plugin->title, $plugin_name)==0) return $plugin; } @@ -182,14 +182,16 @@ { $plugin = find_plugin_settings($plugin_name); - if (!$plugin) + if (!$plugin) $plugin = new ElggPlugin(); if ($name!='title') { + $plugin->title = $plugin_name; $plugin->$name = $value; - $plugin->save(); + + return $plugin->getGUID(); } return false; @@ -390,6 +392,9 @@ { // Now run this stuff, but only once run_function_once("plugin_run_once"); + + // Register some actions + register_action("plugins/settings/save", false, "", true); } // Register a startup event diff --git a/languages/en.php b/languages/en.php index 501eac321..7a4b72fa1 100644 --- a/languages/en.php +++ b/languages/en.php @@ -200,7 +200,12 @@ */
'river' => "River",
- 'river:relationship:friend' => 'is now friends with',
+ 'river:relationship:friend' => 'is now friends with', + /** + * Plugins + */ + 'plugins:settings:save:ok' => "Settings for the %s plugin were saved successfully.", + 'plugins:settings:save:fail' => "There was a problem saving settings for the %s plugin.",
/**
* Search
diff --git a/views/default/admin/plugins_opt/plugin.php b/views/default/admin/plugins_opt/plugin.php index ef8dd36f0..6e20ac9a0 100644 --- a/views/default/admin/plugins_opt/plugin.php +++ b/views/default/admin/plugins_opt/plugin.php @@ -31,9 +31,9 @@ <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)) { ?> + <?php if (elgg_view("settings/{$plugin}/edit")) { ?> <div id="<?php echo $plugin; ?>_settings"> - <?php echo elgg_view("object/plugin", array('plugin_object' => $plugin_object)) ?> + <?php echo elgg_view("object/plugin", array('plugin' => $plugin, 'entity' => find_plugin_settings($plugin))) ?> </div> <?php } ?> diff --git a/views/default/object/plugin.php b/views/default/object/plugin.php index 552d42192..edaf1f0db 100644 --- a/views/default/object/plugin.php +++ b/views/default/object/plugin.php @@ -9,5 +9,25 @@ * @copyright Curverider Ltd 2008 * @link http://elgg.org/ */ + + $entity = $vars['entity']; + $plugin = $vars['plugin']; + ?> -// render a plugin & settings
\ No newline at end of file +<div> + <form action="<?php echo $vars['url']; ?>action/plugins/settings/save" method="post"> + + <?php + echo elgg_view("settings/{$plugin}/edit",$vars); + ?> + + <p> + <input type="hidden" name="plugin" value="<?php echo $plugin ?>" /> + <input type="submit" value="<?php + + echo elgg_echo('save'); + + ?>" /> + </p> + </form> +</div>
\ No newline at end of file |