3 # Copyright 2014, 2016 Paul Hänsch
5 # This file is part of Confetti.
7 # Confetti is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # Confetti is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public License
18 # along with Confetti. If not, see <http://www.gnu.org/licenses/>.
22 filter="&filter=${_REF[filter]}"
23 filtertype="&filtertype=${_REF[filtertype]}"
24 order="&order=${_REF[order]}"
27 tempfile="$_DATA/temp/$card"
28 cardfile="$_DATA/vcard/$card"
29 attfile="$_DATA/mappings/attendance"
33 printf %s\\n "$each" \
34 | sed -r ':X;$!{N;bX}; s;\r\n;\n;g; s;([;,\\]);\\\1;g; s;\n;\\n;g;'
36 | sed -r ':X;$!{N;bX}; s;\n;\;;g'
39 [ "${_POST[hi_select]}" = "list" ] || _POST[hi_company]="${_POST[hi_other]}"
40 [ -n "${_POST[hi_company]}${_POST[hi_number]}${_POST[hi_status]}" ] \
41 && _POST[X-HEALTH-INSURANCE]="$(vcf_escape "${_POST[hi_company]}" "${_POST[hi_number]}" "${_POST[hi_status]}")"
43 sed -r 's;$;\r;' >"$tempfile" <<EOF
46 N:$(vcf_escape "${_POST[0N]}" "${_POST[1N]}" "${_POST[2N]}" "${_POST[3N]}" "${_POST[4N]}")
49 for field in $VCF_FIELDS; do for key in $field $field{0..100}; do
50 [ -z "${_POST[$key]+x}" ] && break
51 [ -z "${_POST[$key]}" ] && continue
54 printf '%s;TYPE=%s:%s\r\n' "${field}" "${_POST[phonetype${key#TEL}]}" "$(vcf_escape "${_POST[$key]}")"
57 printf '%s:%s\r\n' "${field}" "${_POST[$key]}"
60 printf '%s:%s\r\n' "${field}" "$(vcf_escape "${_POST[$key]}")"
64 [ "${_POST[action]}" = addfield ] && printf '%s:\r\n' "${_POST[newfield]}"
69 case "${_POST[action]}" in
71 redirect "?p=cards${filter}${filtertype}${order}&edit=$card"
75 for att in attendance attendance{0..100}; do
76 [ -n "${_POST[$att]}" ] && attendance+=("${_POST[$att]}")
78 sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do
79 touch "$_DATA/ical/$course"
81 sed -i -r '/^(.+)\t'$card'$/d' "$attfile"
82 for each in $attendance; do
85 sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do
86 touch "$_DATA/ical/$course"
89 mv "$tempfile" "$cardfile"
90 redirect "?p=cards${filter}${filtertype}${order}#$card"
95 && redirect "?p=cards${filter}${filtertype}${order}#$card" \
96 || redirect "?p=cards${filter}${filtertype}${order}"
99 rm "$tempfile" "$cardfile"
100 redirect "?p=cards${filter}${filtertype}${order}"