From 3e5cbe4a13ed9243b432d4d7db55bca1f54920d9 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Sun, 8 Nov 2009 16:33:54 -0500 Subject: [PATCH] Fix toggle actions to work properly with only POST data --- ansel/js/togglewidget.js | 8 ++------ ansel/lib/Ajax/Imple/ToggleGalleryActions.php | 6 +++--- ansel/lib/Ajax/Imple/ToggleOtherGalleries.php | 11 +++++------ 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/ansel/js/togglewidget.js b/ansel/js/togglewidget.js index c299065f9..1dbf970c7 100755 --- a/ansel/js/togglewidget.js +++ b/ansel/js/togglewidget.js @@ -29,10 +29,6 @@ function togglePlusMinus(node, requestType) } var url = Ansel.widgets[requestType].url; - - var params = new Object(); - params.pref_value = pref_value; - new Ajax.Request(url, { - parameters: params - }); + var params = { "value": "value=" + pref_value }; + new Ajax.Request(url, { parameters: params }); } \ No newline at end of file diff --git a/ansel/lib/Ajax/Imple/ToggleGalleryActions.php b/ansel/lib/Ajax/Imple/ToggleGalleryActions.php index 357474e19..7f2094636 100644 --- a/ansel/lib/Ajax/Imple/ToggleGalleryActions.php +++ b/ansel/lib/Ajax/Imple/ToggleGalleryActions.php @@ -15,7 +15,7 @@ class Ansel_Ajax_Imple_ToggleGalleryActions extends Horde_Ajax_Imple_Base // Include the js Horde::addScriptFile('togglewidget.js'); - $url = $this->_getUrl('ToggleGalleryActions', 'ansel', array('input' => 'pref_value', 'sessionWrite' => true)); + $url = $this->_getUrl('ToggleGalleryActions', 'ansel', array('post' => 'value', 'sessionWrite' => true)); $js = array(); $js[] = "Ansel.widgets['galleryActions'] = {'bindTo': '" . $this->_params['bindTo'] . "', 'url': '" . $url . "'}"; @@ -26,10 +26,10 @@ class Ansel_Ajax_Imple_ToggleGalleryActions extends Horde_Ajax_Imple_Base public function handle($args, $post) { - if (empty($args['input'])) { + if (!isset($post['value'])) { return 0; } - $input = Horde_Util::getPost($args['input']); + $input = Horde_Util::getPost($post['value']); $GLOBALS['prefs']->setValue('show_actions', $input); return 1; diff --git a/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php b/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php index 715c17167..8bc74eeda 100644 --- a/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php +++ b/ansel/lib/Ajax/Imple/ToggleOtherGalleries.php @@ -15,7 +15,7 @@ class Ansel_Ajax_Imple_ToggleOtherGalleries extends Horde_Ajax_Imple_Base // Include the js Horde::addScriptFile('togglewidget.js'); - $url = $this->_getUrl('ToggleOtherGalleries', 'ansel', array('input' => 'pref_value', 'sessionWrite' => true)); + $url = $this->_getUrl('ToggleOtherGalleries', 'ansel', array('post' => 'value', 'sessionWrite' => true)); $js = array(); $js[] = "Ansel.widgets['otherGalleries'] = {'bindTo': '" . $this->_params['bindTo'] . "', 'url': '" . $url . "'}"; $js[] = "Event.observe(Ansel.widgets.otherGalleries.bindTo + '-toggle', 'click', function(event) {doActionToggle('" . $this->_params['bindTo'] . "', 'otherGalleries'); Event.stop(event)});"; @@ -25,14 +25,13 @@ class Ansel_Ajax_Imple_ToggleOtherGalleries extends Horde_Ajax_Imple_Base public function handle($args, $post) { - if (empty($args['input'])) { + if (!isset($post['value'])) { return 0; } - $input = Horde_Util::getPost($args['input']); - $GLOBALS['prefs']->setValue('show_othergalleries', $input); - echo $GLOBALS['prefs']->getValue('show_othergalleries'); - return 1; + $GLOBALS['prefs']->setValue('show_othergalleries', $post['value']); + + return $GLOBALS['prefs']->getValue('show_othergalleries'); } } -- 2.11.0