]> git.plutz.net Git - confetti/blob - actions/update_attendee.sh
basic update functions for vcards
[confetti] / actions / update_attendee.sh
1 #!/bin/zsh
2
3 cgi_post
4
5 card="$_POST[\"card\"]"
6 tempfile="temp/$card"
7 cardfile="vcard/$card"
8
9 echo "BEGIN:VCARD\r" >"$tempfile"
10 echo "VERSION:4.0\r" >>"$tempfile"
11 for field in $VCF_FIELDS; do
12   value="$_POST[\"$field\"]"
13   n=0
14   while [ -n "$value" ]; do
15     echo "${field}:${value}\r"
16     value="$_POST[\"$field$n\"]"
17     n=$(($n + 1))
18   done
19 done >>"$tempfile"
20
21 case "$_POST[\"action\"]" in
22   addfield)
23     echo "$_POST[\"newfield\"]:\r" >>"$tempfile"
24     echo "END:VCARD\r" >>"$tempfile"
25     echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card#$card\n\n"
26     ;;
27   update)
28     echo "END:VCARD\r" >>"$tempfile"
29     mv "$tempfile" "$cardfile"
30     echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n"
31     ;;
32   cancel)
33     rm "$tempfile"
34     echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n"
35     ;;
36 esac