X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=actions%2Fupdate_attendee.sh;h=6f46cb2034eaeda33c967523fcb59fde5d1126a6;hp=3c6ad55c4ee530048033adf7289528321545b274;hb=d959549ee6cec995f6e8975002b3bc0e9375e564;hpb=9917259ba7ae33000a3aeb892f392ed71ad0377d diff --git a/actions/update_attendee.sh b/actions/update_attendee.sh index 3c6ad55..6f46cb2 100644 --- a/actions/update_attendee.sh +++ b/actions/update_attendee.sh @@ -2,6 +2,36 @@ cgi_post -debug $_POST +card="$_POST[\"card\"]" +tempfile="temp/$card" +cardfile="vcard/$card" -echo -n "Location: http://$HTTP_HOST/?page=attendees\n\n" +echo "BEGIN:VCARD\r" >"$tempfile" +echo "VERSION:4.0\r" >>"$tempfile" +echo "N:$_POST[\"0N\"];$_POST[\"1N\"];$_POST[\"2N\"];$_POST[\"3N\"];$_POST[\"4N\"]\r" >>"$tempfile" +for field in $VCF_FIELDS; do + value="$_POST[\"$field\"]" + n=0 + while [ -n "$value" ]; do + echo "${field}:${value}\r" + value="$_POST[\"$field$n\"]" + n=$(($n + 1)) + done +done >>"$tempfile" + +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#$card\n\n" + ;; + update) + echo "END:VCARD\r" >>"$tempfile" + mv "$tempfile" "$cardfile" + echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n" + ;; + cancel) + rm "$tempfile" + echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n" + ;; +esac