3 # Copyright 2014 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/>.
23 filter="&filter=$_REF[\"filter\"]"
24 filtertype="&filtertype=$_REF[\"filtertype\"]"
25 order="&order=$_REF[\"order\"]"
27 card="$_POST[\"card\"]"
28 tempfile="$_DATA/temp/$card"
29 cardfile="$_DATA/vcard/$card"
30 attfile="$_DATA/mappings/attendance"
32 _POST["0N"]="$(echo "$_POST[\"0N\"]" |sed 's:;: :')"
33 _POST["1N"]="$(echo "$_POST[\"1N\"]" |sed 's:;: :')"
34 _POST["2N"]="$(echo "$_POST[\"2N\"]" |sed 's:;: :')"
35 _POST["3N"]="$(echo "$_POST[\"3N\"]" |sed 's:;: :')"
36 _POST["4N"]="$(echo "$_POST[\"4N\"]" |sed 's:;: :')"
38 echo "BEGIN:VCARD\r" >"$tempfile"
39 echo "VERSION:4.0\r" >>"$tempfile"
40 echo "N:$_POST[\"0N\"];$_POST[\"1N\"];$_POST[\"2N\"];$_POST[\"3N\"];$_POST[\"4N\"]\r" >>"$tempfile"
41 echo "UID:$_POST[\"UID\"]\r" >>"$tempfile"
42 for field in $VCF_FIELDS; do
43 value="$_POST[\"$field\"]"
45 while [ -n "$value" ]; do
46 value="$(echo "$value" |sed -r ':a;N;$!ba;s:\n:\\\\n:g;s:\r:\\\\r:g')"
47 echo "${field}:${value}\r"
48 value="$_POST[\"$field$n\"]"
53 case "$_POST[\"action\"]" in
55 echo "$_POST[\"newfield\"]:\r" >>"$tempfile"
56 echo "END:VCARD\r" >>"$tempfile"
57 echo -n "Location: ?page=attendees${filter}${filtertype}${order}&edit=$card\n\n"
61 for att in attendance attendance{0..100}; do
62 [ -n "$_POST[\"$att\"]" ] && attendance+=("$_POST[\"$att\"]")
64 sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do
65 touch "$_DATA/ical/$course"
67 sed -i -r '/^(.+)\t'$card'$/d' "$attfile"
68 for each in $attendance; do
71 sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do
72 touch "$_DATA/ical/$course"
75 echo "END:VCARD\r" >>"$tempfile"
76 mv "$tempfile" "$cardfile"
77 echo -n "Location: ?page=attendees${filter}${filtertype}${order}#$card\n\n"
82 && echo -n "Location: ?page=attendees${filter}${filtertype}${order}#$card\n\n" \
83 || echo -n "Location: ?page=attendees${filter}${filtertype}${order}\n\n"
86 rm "$tempfile" "$cardfile"
87 echo -n "Location: ?page=attendees${filter}${filtertype}${order}\n\n"