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/>.
20 [ -z "$_GET[\"order\"]" ] && _GET["order"]=firstname
23 ls -1 ${_DATA}/ical/*ics |while read file; do
24 icstime="$(sed -rn 's:^DTSTART\:(TZID=.*\:)?([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z?\r$:\2-\3-\4 \5\:\6\:\7:p' "$file")"
25 echo "$(date -d "$icstime" "+%u %H%M%S")\t$file"
26 done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:'
30 case "$_GET[\"filtertype\"]" in
32 grep -il "$_GET[\"filter\"]" ${_DATA}/vcard/*vcf
35 egrep -xil "(FN|NICKNAME|N)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
38 egrep -xil "(ADR)(;.+)*:([^;]*;){2}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
41 egrep -xil "(ADR)(;.+)*:([^;]*;){5}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
44 egrep -xil "(TEL)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
47 egrep -xil "(BDAY)(;.+)*:$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
51 *) ls -1 ${_DATA}/vcard/*vcf 2>/dev/null
53 esac |case "$_GET[\"order\"]" in
56 fn=$(sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$file")
62 ln=$(sed -rn 's:^N(;.+)*\:([^;]*;){0} *([^;]*).*$:\3:p' "$file")
68 bd=$(sed -rn 's:^BDAY(;.+)*\:(.*)$:\2:p' "$file")
75 esac |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:'
79 tr -d '\n' <"$1" |sed -r 's:\r ::g;s:\r:\n:g' \
82 s:^X-MS-CARDPICTURE:001 PHOTO:p;
86 s:^NICKNAME:005 NICKNAME:p;
88 s:^GENDER:007 GENDER:p;
89 s:^X-GENDER:007 GENDER:p;
94 s:^MEMBER:012 MEMBER:p;
95 s:^CATEGORIES:013 CATEGORIES:p;
96 s:^ANNIVERSARY:014 ANNIVERSARY:p;
97 s:^X-ANNIVERSARY:014 ANNIVERSARY:p;
98 s:^X-EVOLUTION-ANNIVERSARY:014 ANNIVERSARY:p;
99 s:^X-KADDRESSBOOK-X-Anniversary:014 ANNIVERSARY:p;
101 s:^EMAIL:016 EMAIL:p;
104 s:^X-AIM(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:aim\:\2:p;
105 s:^X-ICQ(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:aim\:\2:p;
106 s:^X-GOOGLE-TALK(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:xmpp\:\2:p;
107 s:^X-JABBER(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:xmpp\:\2:p;
108 s:^X-MSN(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:msn\:\2:p;
109 s:^X-YAHOO(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:ymsgr\:\2:p;
110 s:^X-SIP(;[^"\:]+|;"[^"]+")*\:(sip\:)?(.*)$:018 IMPP\1\:sip\:\3:p;
112 s:^LABEL(;[^"\:]+|;"[^"]+")*\:(.*)$:019 ADR;LABEL="\2"\1\::p;
114 s:^X-EVOLUTION-BLOG-URL:021 URL:p;
119 s:^RELATED:025 RELATED:p;
120 s:^AGENT:025 RELATED\;TYPE=agent:p;
121 s:^X-ASSISTANT:025 RELATED\;TYPE=assistant;VALUE=text:p;
122 s:^X-EVOLUTION-ASSISTANT:025 RELATED\;TYPE=assistant;VALUE=text:p;
123 s:^X-KADDRESSBOOK-X-AssistantsName:025 RELATED\;TYPE=assistant;VALUE=text:p;
124 s:^X-MANAGER:025 RELATED\;TYPE=manager;VALUE=text:p;
125 s:^X-EVOLUTION-MANAGER:025 RELATED\;TYPE=manager;VALUE=text:p;
126 s:^X-KADDRESSBOOK-X-ManagersName:025 RELATED\;TYPE=manager;VALUE=text:p;
127 s:^X-SPOUSE:025 RELATED\;TYPE=spouse;VALUE=text:p;
128 s:^X-EVOLUTION-SPOUSE:025 RELATED\;TYPE=spouse;VALUE=text:p;
129 s:^X-KADDRESSBOOK-X-SpouseName:025 RELATED\;TYPE=spouse;VALUE=text:p;
135 s:^CLIENTPIDMAP.*$::;
147 s:^VERSION.*$:000 VERSION\:4.0:p;
150 s:^([A-Z].*)$:024 \1:p;
152 |sort |while read -r line; do
158 fn=$(echo -E "$line" |sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:g' |tr -d '\r')
161 n=$(echo -E "$line" \
162 |sed -rn 's:^([0-9]{3} )([^;\:]+)(;[^"\:]+|;"[^"]+")*\:([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\7 \5 \6 \4 \8:gp' \
163 |sed -r 's:,: :;s:\;: :g;s: +: :g' \
169 nick=$(echo -E "$line" |sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:g' |tr -d '\r')
173 [ -n "$n" ] && fn="$n"
174 #[ -n "$fn" -a -n "$nick" ] && fn="$fn aka. $nick"
175 [ -n "$fn" ] && echo -E "003 FN:$fn" \
176 || echo -E "003 FN:$nick"
182 | sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:key="\1"\nvalue="\3"\ntag=\2:g' \
183 | while read -r line; do
185 key=*) echo -E "$line"
187 value=*) echo -E "$line"
191 | sed -r 's:^tag=::;s:\;([A-Z+_-]+="[^"]+"|[A-Z+_-]+=[^\;]+):\n\1:g;' \
192 | sed -r 's:([A-Z+_-]+)="?(.*)"?:tag\[\1\]="\2":g' \
194 | sort |while read -r tag; do
195 nt="$(echo -E "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\1:')"
196 nv="$(echo -E "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\2:')"
197 [ "$nt" = "$ot" ] && vl="$nv,$vl" || vl="$nv"
198 echo -E "tag[$nt]=\"$vl\""
204 | sed -r 's:[\\$`]:\\&:g'
207 view_attendee() { #Parameter: Cardfile
209 cardfile="$_DATA/vcard/${id}"
210 cachefile="$_DATA/cache/${id}.cache"
212 if [ "$cachefile" -nt "$cardfile" ]; then
217 vcf_parse "$cardfile" |while read -r line; do
220 value*) eval "$line";;
223 if [ -z "$key" ]; then
226 values[$key]="$value"
227 for t in ${(k)tag}; do
228 tags[${key}_$t]="$tag[$t]"
231 if [ -n "$values[$key]" ]; then
233 while [ -n "$values[$key$n]" ]; do n=$(($n + 1)); done
242 . ${_EXEC}/templates/view_attendee.sh |tee "$cachefile"
246 edit_attendee() { #Parameter: Cardfile
248 cardfile="$_DATA/vcard/$id"
249 tempfile="$_DATA/temp/$id"
250 [ -f "$tempfile" ] && cardfile="$tempfile"
255 vcf_parse "$cardfile" |while read -r line; do
258 value*) eval "$line";;
261 if [ -z "$key" ]; then
264 [ -n "$value" ] && values[$key]="$value" || values[$key]='\r'
265 for t in ${(k)tag}; do
266 tags[${key}_$t]="$tag[$t]"
269 if [ -n "$values[$key]" ]; then
271 while [ -n "$values[${key}${n}]" ]; do n=$(($n + 1)); done
280 . ${_EXEC}/templates/edit_attendee.sh
288 . ${_EXEC}/templates/attendees.css.sh
291 . ${_EXEC}/templates/text_attendee.sh
292 . ${_EXEC}/templates/attendees.html.sh