]> git.plutz.net Git - confetti/commitdiff
keep filter and order settings when updating a card
authorpaul <paul@plutz.net>
Sun, 1 Dec 2013 04:29:07 +0000 (04:29 +0000)
committerpaul <paul@plutz.net>
Sun, 1 Dec 2013 04:29:07 +0000 (04:29 +0000)
svn path=/trunk/; revision=28

actions/edit_attendee.sh [new file with mode: 0644]
actions/new_attendee.sh
actions/update_attendee.sh
cgi.sh
templates/view_attendee.sh

diff --git a/actions/edit_attendee.sh b/actions/edit_attendee.sh
new file mode 100644 (file)
index 0000000..9a5bcb4
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/zsh
+
+cgi_refdata
+
+card="$_GET[\"card\"]"
+debug card: $card
+filter="&filter=$_REF[\"filter\"]"
+filtertype="&filtertype=$_REF[\"filtertype\"]"
+order="&order=$_REF[\"order\"]"
+
+echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}&edit=$card\n\n"
index b7242bf61b665f2347e10e2d5649c3847b2c7f05..d1eb77a3ae9bed8c034a0dd45c47630c3f95915a 100644 (file)
@@ -1,6 +1,11 @@
 #!/bin/zsh
 
 cgi_post
+cgi_refdata
+
+filter="&filter=$_REF[\"filter\"]"
+filtertype="&filtertype=$_REF[\"filtertype\"]"
+order="&order=$_REF[\"order\"]"
 
 uid=$(dbus-uuidgen)
 card="${uid}.vcf"
@@ -20,4 +25,4 @@ UID:$uid
 END:VCARD
 EOF
 
-echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card\n\n"
+echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}&edit=$card\n\n"
index 6bfbe8822315d4f666a4850dd8fd2abde2491e1c..9657d0577b4bd57728bbd757a5b0719a9d0585e7 100644 (file)
@@ -1,6 +1,11 @@
 #!/bin/zsh
 
 cgi_post
+cgi_refdata
+
+filter="&filter=$_REF[\"filter\"]"
+filtertype="&filtertype=$_REF[\"filtertype\"]"
+order="&order=$_REF[\"order\"]"
 
 card="$_POST[\"card\"]"
 tempfile="temp/$card"
@@ -24,21 +29,21 @@ case "$_POST[\"action\"]" in
   addfield)
     echo "$_POST[\"newfield\"]:\r" >>"$tempfile"
     echo "END:VCARD\r" >>"$tempfile"
-    echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card\n\n"
+    echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}&edit=$card\n\n"
     ;;
   update)
     echo "END:VCARD\r" >>"$tempfile"
     mv "$tempfile" "$cardfile"
-    echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n"
+    echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}#$card\n\n"
     ;;
   cancel)
     rm "$tempfile"
     [ -f "$cardfile" ] \
-      && echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n" \
-      || echo -n "Location: http://$HTTP_HOST/?page=attendees\n\n"
+      && echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}#$card\n\n" \
+      || echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}\n\n"
     ;;
   delete)
     rm "$tempfile" "$cardfile"
-    echo -n "Location: http://$HTTP_HOST/?page=attendees\n\n"
+    echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}\n\n"
     ;;
 esac
diff --git a/cgi.sh b/cgi.sh
index bde75d668fbfb429e1ed50d9809ba37911c8bd72..39172ba9ecdd7bb8abc3997d182b97fe114085c3 100755 (executable)
--- a/cgi.sh
+++ b/cgi.sh
@@ -2,6 +2,7 @@
 
 declare -A _GET
 declare -A _POST
+declare -A _REF
 
 cgi_get() {  # parse HTTP GET string
   echo "$QUERY_STRING" |tr '&' '\n' |while read query; do
@@ -25,3 +26,11 @@ cgi_post() {  # parse HTTP POST string
     fi
   done
 }
+
+cgi_refdata() { # Parse GET data from referer
+  echo "$HTTP_REFERER" |cut -d'?' -f2- |tr '&' '\n' |while read query; do
+    key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')"
+    val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')"
+    _REF["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")"
+  done
+}
index 1bfcceebd5df65fca3761fa97fa68ac90253f32e..53c508c2a22a1e08bd83f7471de68e0a213c3c1f 100755 (executable)
@@ -59,7 +59,7 @@ done
 echo '  </div>'
 echo ''
 echo '  <div class="section control">'
-echo '    <a class="item control" href="?page=attendees&edit='${id}'">'$(l10n edit)'</a>'
+echo '    <a class="item control" href="?action=edit_attendee&card='${id}'">'$(l10n edit)'</a>'
 echo '    <a class="item control" href="?export=vcard&card='${id}'">'$(l10n vcf_export)'</a>'
 echo '  </div>'
 echo '</div>'