From d9ee4599c943bf674f180a5fab849ec256658a41 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sun, 13 Jan 2008 18:35:00 +0100 Subject: [PATCH] issue100, add/remove tag and tag-condition use HTTP POST Signed-off-by: Andreas Unterkircher --- phpfspot.class.php | 7 +++++++ phpfspot.js | 30 ++++++++++++++++++++---------- rpc.php | 12 ++++++------ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/phpfspot.class.php b/phpfspot.class.php index 0954040..8646ff1 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -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() /** diff --git a/phpfspot.js b/phpfspot.js index c90d80e..ca3f9c0 100644 --- a/phpfspot.js +++ b/phpfspot.js @@ -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 b2d258c..4bb2973 100644 --- 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; -- 2.25.1