Fix toggle actions to work properly with only POST data
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 8 Nov 2009 21:33:54 +0000 (16:33 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 9 Nov 2009 16:36:32 +0000 (11:36 -0500)
ansel/js/togglewidget.js
ansel/lib/Ajax/Imple/ToggleGalleryActions.php
ansel/lib/Ajax/Imple/ToggleOtherGalleries.php

index c299065..1dbf970 100755 (executable)
@@ -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
index 357474e..7f20946 100644 (file)
@@ -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;
index 715c171..8bc74ee 100644 (file)
@@ -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');
     }
 
 }