issue100, add/remove tag and tag-condition use HTTP POST
authorAndreas Unterkircher <unki@netshadow.at>
Sun, 13 Jan 2008 17:35:00 +0000 (18:35 +0100)
committerAndreas Unterkircher <unki@netshadow.at>
Sun, 13 Jan 2008 17:35:00 +0000 (18:35 +0100)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.class.php
phpfspot.js
rpc.php

index 09540400137b2b048bbd82c5a3f9abc78c56b9c5..8646ff1d0b06f8bd7d9f8629f86a40b715f479bf 100644 (file)
@@ -643,6 +643,9 @@ class PHPFSPOT {
 
       if(!in_array($tag, $_SESSION['selected_tags']))
          array_push($_SESSION['selected_tags'], $tag);
+
+
+      return "ok";
    
    } // addTag()
 
@@ -663,6 +666,8 @@ class PHPFSPOT {
          sort($_SESSION['selected_tags']);
       }
 
+      return "ok";
+
    } // delTag()
 
    /**
@@ -1447,6 +1452,8 @@ class PHPFSPOT {
    {
       $_SESSION['tag_condition'] = $mode;
 
+      return "ok";
+
    } // setTagCondition()
 
    /** 
index c90d80e1365e337fb730ff4abed673d02d23c8c3..ca3f9c01508fa8c94e25eae0794823d7986b8f12 100644 (file)
@@ -12,24 +12,35 @@ function showCredits()
 
 function Tags(mode, id)
 {
+   var objTemp = new Object();
+
    if(mode == "add") {
-      // add the tag to users session
-      HTML_AJAX.grab(encodeURI('rpc.php?action=addtag&id=' + id));
+      // add tag to users session
+      objTemp['action'] = 'addtag';
+      objTemp['id'] = id;
    }
    else if(mode == "del") {
-      // del the tag from users session
-      HTML_AJAX.grab(encodeURI('rpc.php?action=deltag&id=' + id));
+      // del tag from users session
+      objTemp['action'] = 'deltag';
+      objTemp['id'] = id;
    }
    else if(mode == "condition") {
       setCheckedValue(id, id.value);
-      HTML_AJAX.grab(encodeURI('rpc.php?action=tagcondition&mode=' + id.value));
+      objTemp['action'] = 'tagcondition';
+      objTemp['mode'] = id.value;
    }
 
-   refreshAvailableTags();
-   refreshSelectedTags();
-   refreshPhotoIndex();
+   var retr = HTML_AJAX.post('rpc.php', objTemp);
+   if(retr == "ok") {
+      refreshAvailableTags();
+      refreshSelectedTags();
+      refreshPhotoIndex();
+   }
+   else {
+      window.alert(retr);
+   }
 
-}
+} // Tags()
 
 function refreshAvailableTags()
 {
@@ -101,7 +112,6 @@ function startSearch()
    to_day = document.getElementById('today').value;
    to = to_year +"-"+ to_month +"-"+ to_day;
 
-   // Create object with values of the form
    var objTemp = new Object();
    objTemp['action'] = 'search';
 
diff --git a/rpc.php b/rpc.php
index b2d258c5c0748b1530bcc229d4ebfcafc6232c09..4bb297331abbad7bff7d38a9e2c66704f8788743 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -67,14 +67,14 @@ class PHPFSPOT_RPC {
             break;
 
          case 'addtag':
-            if(isset($_GET['id']) && is_numeric($_GET['id'])) {
-               $fspot->addTag($_GET['id']);
+            if(isset($_POST['id']) && is_numeric($_POST['id'])) {
+               print $fspot->addTag($_POST['id']);
             }
             break;
 
          case 'deltag':
-            if(isset($_GET['id']) && is_numeric($_GET['id'])) {
-               $fspot->delTag($_GET['id']);
+            if(isset($_POST['id']) && is_numeric($_POST['id'])) {
+               print $fspot->delTag($_POST['id']);
             }
             break;
 
@@ -87,8 +87,8 @@ class PHPFSPOT_RPC {
             break;
 
          case 'tagcondition':
-            if(isset($_GET['mode']) && in_array($_GET['mode'], Array('or', 'and'))) {
-               $fspot->setTagCondition($_GET['mode']);
+            if(isset($_POST['mode']) && in_array($_POST['mode'], Array('or', 'and'))) {
+               print $fspot->setTagCondition($_POST['mode']);
             }
             break;