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 b7242bf..d1eb77a 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 6bfbe88..9657d05 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 bde75d6..39172ba 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 1bfccee..53c508c 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>'