Support for POST only variables using Horde_Ajax_Imple, and fix
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 8 Nov 2009 16:53:47 +0000 (11:53 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 8 Nov 2009 16:53:47 +0000 (11:53 -0500)
kronolith's tag actions to require POST for state changing actions.

15 files changed:
ansel/lib/Ajax/Imple/EditCaption.php
ansel/lib/Ajax/Imple/EditFaces.php
ansel/lib/Ajax/Imple/Embed.php
ansel/lib/Ajax/Imple/GallerySlugCheck.php
ansel/lib/Ajax/Imple/ImageSaveGeotag.php
ansel/lib/Ajax/Imple/LocationAutoCompleter.php
ansel/lib/Ajax/Imple/TagActions.php
ansel/lib/Ajax/Imple/ToggleGalleryActions.php
ansel/lib/Ajax/Imple/ToggleOtherGalleries.php
imp/lib/Ajax/Imple/ContactAutoCompleter.php
kronolith/js/tagactions.js
kronolith/lib/Ajax/Imple/ContactAutoCompleter.php
kronolith/lib/Ajax/Imple/Embed.php
kronolith/lib/Ajax/Imple/TagActions.php
kronolith/lib/Ajax/Imple/TagAutoCompleter.php

index 519bda7..5d3d812 100644 (file)
@@ -48,7 +48,7 @@ class Ansel_Ajax_Imple_EditCaption extends Horde_Ajax_Imple_Base
         Horde::addInlineScript($js, 'dom');
     }
 
-    public function handle($args)
+    public function handle($args, $post)
     {
         include_once dirname(__FILE__) . '/../../base.php';
 
index 651a495..2c23b38 100644 (file)
@@ -28,7 +28,7 @@ class Ansel_Ajax_Imple_EditFaces extends Horde_Ajax_Imple_Base
         Horde::addInlineScript($js, 'dom');
     }
 
-    function handle($args)
+    function handle($args, $post)
     {
         include_once dirname(__FILE__) . '/../../base.php';
 
index a6bce56..c06c630 100644 (file)
@@ -28,7 +28,7 @@ class Ansel_Ajax_Imple_Embed extends Horde_Ajax_Imple_Base
      *
      * @param array $args  Arguments for this view.
      */
-    public function handle($args)
+    public function handle($args, $post)
     {
         include_once dirname(__FILE__) . '/../../base.php';
 
index 2b3a6e9..6e3705d 100644 (file)
@@ -24,7 +24,7 @@ class Ansel_Ajax_Imple_GallerySlugCheck extends Horde_Ajax_Imple_Base
         Horde::addInlineScript($js, 'dom');
     }
 
-    public function handle($args)
+    public function handle($args, $post)
     {
         include_once dirname(__FILE__) . '/../../base.php';
         if (empty($args['input'])) {
index 3ed59fb..bce0d16 100644 (file)
@@ -21,7 +21,7 @@ class Ansel_Ajax_Imple_ImageSaveGeotag extends Horde_Ajax_Imple_Base
         return $this->_getUrl('ImageSaveGeotag', 'ansel');
     }
 
-    public function handle($args)
+    public function handle($args, $post)
     {
         include_once dirname(__FILE__) . '/../../base.php';
 
index 847cd53..7719de8 100644 (file)
@@ -48,7 +48,7 @@ class Ansel_Ajax_Imple_LocationAutoCompleter extends Horde_Ajax_Imple_AutoComple
         return $ret;
     }
 
-    public function handle($args)
+    public function handle($args, $post)
     {
         include_once dirname(__FILE__) . '/../../base.php';
 
index 36d561f..3e9644f 100644 (file)
@@ -31,7 +31,7 @@ class Ansel_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
         Horde::addInlineScript($js, 'dom');
     }
 
-    public function handle($args)
+    public function handle($args, $post)
     {
         include_once dirname(__FILE__) . '/../../base.php';
 
index 260cb12..357474e 100644 (file)
@@ -24,7 +24,7 @@ class Ansel_Ajax_Imple_ToggleGalleryActions extends Horde_Ajax_Imple_Base
         Horde::addInlineScript($js, 'dom');
     }
 
-    public function handle($args)
+    public function handle($args, $post)
     {
          if (empty($args['input'])) {
             return 0;
index 3ceaced..715c171 100644 (file)
@@ -23,7 +23,7 @@ class Ansel_Ajax_Imple_ToggleOtherGalleries extends Horde_Ajax_Imple_Base
         Horde::addInlineScript($js, 'dom');
     }
 
-    public function handle($args)
+    public function handle($args, $post)
     {
          if (empty($args['input'])) {
             return 0;
index f5b7e01..5f534a8 100644 (file)
@@ -81,7 +81,7 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCompleter
      *
      * @return array  The data to send to the autocompleter JS code.
      */
-    public function handle($args)
+    public function handle($args, $post)
     {
         // Avoid errors if 'input' isn't set and short-circuit empty searches.
         if (empty($args['input']) ||
index ea98b2b..9dd3f13 100644 (file)
@@ -1,10 +1,9 @@
 function addTag(resource, type, endpoint)
 {
     if (!$('newtags-input_' + resource).value.blank()) {
-        var params = new Object();
-        params.imple="/action=add/resource=" + resource + "/type=" + type + "/tags=" + $('newtags-input_' + resource).value;
+        var params = { "params": "resource=" + resource + "/type=" + type + "/tags=" + $('newtags-input_' + resource).value };
         new Ajax.Updater({success:'tags_' + resource},
-                         endpoint,
+                         endpoint + "/action=add/post=params",
                          {
                              method: 'post',
                              parameters: params,
@@ -18,10 +17,9 @@ function addTag(resource, type, endpoint)
 
 function removeTag(resource, type, tagid, endpoint)
 {
-    var params = new Object();
-    params.imple = "/action=remove/resource=" + resource + "/type=" + type + "/tags=" + tagid;
+    var params = {"params": "resource=" + resource + "/type=" + type + "/tags=" + tagid };
     new Ajax.Updater({success:'tags_' + resource},
-                     endpoint,
+                     endpoint + "/action=remove/post=params",
                      {
                          method: 'post',
                          parameters: params
index 6a7656f..d036006 100644 (file)
@@ -40,7 +40,7 @@ class Kronolith_Ajax_Imple_ContactAutoCompleter extends Horde_Ajax_Imple_AutoCom
      *
      * @return string  TODO
      */
-    public function handle($args)
+    public function handle($args, $post)
     {
         // Avoid errors if 'input' isn't set and short-circuit empty searches.
         if (empty($args['input']) ||
index 1f0434e..df1af19 100644 (file)
@@ -38,7 +38,7 @@ class Kronolith_Ajax_Imple_Embed extends Horde_Ajax_Imple_Base
      *
      * @param array $args  Arguments for this view.
      */
-    public function handle($args)
+    public function handle($args, $post)
     {
         /* First, determine the type of view we are asking for */
         $view = $args['view'];
index 4edeb39..f529652 100644 (file)
@@ -38,20 +38,21 @@ class Kronolith_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
      * the type of object (event/calendar) and 'tags' should be the integer
      * tag_id of the tag to remove.
      */
-    public function handle($args)
+    public function handle($args, $post)
     {
+        require_once dirname(__FILE__) . '/../../base.php';
         global $ansel_storage;
 
         $request = $args['action'];
-        $content = array('id' => $args['resource'], 'type' => $args['type']);
-        $tags = $args['tags'];
+        $content = array('id' => $post['resource'], 'type' => $post['type']);
+        $tags = $post['tags'];
 
         // Check perms
-        if ($args['type'] == 'calendar') {
-            $cal = $GLOBALS['kronolith_shares']->getShare($args['resource']);
+        if ($post['type'] == 'calendar') {
+            $cal = $GLOBALS['kronolith_shares']->getShare($post['resource']);
             $perm = $cal->hasPermission(Horde_Auth::getAuth(), PERMS_EDIT);
-        } elseif($args['type'] == 'event') {
-            $event = Kronolith::getDriver()->getByUID($args['resource']);
+        } elseif($post['type'] == 'event') {
+            $event = Kronolith::getDriver()->getByUID($post['resource']);
             $perm = $event->hasPermission(PERMS_EDIT, Horde_Auth::getAuth());
         }
 
@@ -60,14 +61,14 @@ class Kronolith_Ajax_Imple_TagActions extends Horde_Ajax_Imple_Base
             $tagger = Kronolith::getTagger();
             switch ($request) {
             case 'add':
-                $tagger->tag($args['resource'], $tags, $args['type']);
+                $tagger->tag($post['resource'], $tags, $post['type']);
                 break;
             case 'remove':
-                $tagger->untag($args['resource'], (int)$tags, $args['type']);
+                $tagger->untag($post['resource'], (int)$tags, $post['type']);
                 break;
             }
         }
-        return $this->_getTagHtml($tagger, $args['resource'], $args['type']);
+        return $this->_getTagHtml($tagger, $post['resource'], $post['type']);
 
     }
 
index 8b61091..69ced62 100644 (file)
@@ -43,7 +43,7 @@ class Kronolith_Ajax_Imple_TagAutoCompleter extends Horde_Ajax_Imple_AutoComplet
      *
      * @return string  TODO
      */
-    public function handle($args)
+    public function handle($args, $post)
     {
         // Avoid errors if 'input' isn't set and short-circuit empty searches.
         if (empty($args['input']) ||