X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=actions%2Fupdate_card.sh;h=f18c9ee3e659832c2da4e568a967385188220bf9;hp=2250f1967abc5edb8a66c4b83ddc73527b27b437;hb=aedb6776919b351df7df7c310c238c41317ddc44;hpb=69e661b5c8ec195bd3c4998a623a60607b47059e diff --git a/actions/update_card.sh b/actions/update_card.sh index 2250f19..f18c9ee 100755 --- a/actions/update_card.sh +++ b/actions/update_card.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 Paul Hänsch +# Copyright 2014, 2016 Paul Hänsch # # This file is part of Confetti. # @@ -29,32 +29,38 @@ tempfile="$_DATA/temp/$card" cardfile="$_DATA/vcard/$card" attfile="$_DATA/mappings/attendance" -_POST[0N]="$(echo "${_POST[0N]}" |sed 's:;: :')" -_POST[1N]="$(echo "${_POST[1N]}" |sed 's:;: :')" -_POST[2N]="$(echo "${_POST[2N]}" |sed 's:;: :')" -_POST[3N]="$(echo "${_POST[3N]}" |sed 's:;: :')" -_POST[4N]="$(echo "${_POST[4N]}" |sed 's:;: :')" +_POST[0N]="${_POST[0N]//;/,}" +_POST[1N]="${_POST[1N]//;/,}" +_POST[2N]="${_POST[2N]//;/,}" +_POST[3N]="${_POST[3N]//;/,}" +_POST[4N]="${_POST[4N]//;/,}" -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" -echo "UID:${_POST[UID]}\r" >>"$tempfile" +[ "$_POST[hi_select]" = "list" ] && hi_company="${_POST[hi_company]}" || hi_company="${_POST[hi_other]}" +[ -n "${_POST[hi_company]}${_POST[hi_number]}${_POST[hi_status]}" ] \ +&& _POST[X-HEALTH-INSURANCE]="${hi_company//;/,};${_POST[hi_number]//;/,};${_POST[hi_status]//;/,}" + +sed -r 's;$;\r;' >"$tempfile" <>"$tempfile" +done +[ "${_POST[action]}" = addfield ] && printf '%s:\n' "${_POST[newfield]}" +) +END:VCARD +EOF case "${_POST[action]}" in addfield) - echo "${_POST[newfield]}:\r" >>"$tempfile" - echo "END:VCARD\r" >>"$tempfile" - echo -n "Location: ?p=cards${filter}${filtertype}${order}&edit=$card\n\n" + redirect "?p=cards${filter}${filtertype}${order}&edit=$card" ;; update) attendance=() @@ -72,18 +78,17 @@ case "${_POST[action]}" in touch "$_DATA/ical/$course" done - echo "END:VCARD\r" >>"$tempfile" mv "$tempfile" "$cardfile" - echo -n "Location: ?p=cards${filter}${filtertype}${order}#$card\n\n" + redirect "?p=cards${filter}${filtertype}${order}#$card" ;; cancel) rm "$tempfile" [ -f "$cardfile" ] \ - && echo -n "Location: ?p=cards${filter}${filtertype}${order}#$card\n\n" \ - || echo -n "Location: ?p=cards${filter}${filtertype}${order}\n\n" + && redirect "?p=cards${filter}${filtertype}${order}#$card" \ + || redirect "?p=cards${filter}${filtertype}${order}" ;; delete) rm "$tempfile" "$cardfile" - echo -n "Location: ?p=cards${filter}${filtertype}${order}\n\n" + redirect "?p=cards${filter}${filtertype}${order}" ;; esac