3 . "${_EXEC}"/pdiread.sh
6 local cardfile="$_DATA/vcard/$1"
9 . $_EXEC/session_lock.sh
11 if ! tempfile="$(CHECK_SLOCK "$cardfile")"; then
12 printf '[div .message %s]' "$(l10n "This card is not set up for editing within this session.")"
14 card="$(pdi_load "$tempfile")"
16 [form .card #${cardfile##*/} action="/cards/update_card.sh" method="POST"
17 [input type="hidden" name="tid" value="$(transid ${tempfile})"]
18 [div .section .basic $(
19 edit_item "$card" N GENDER
20 [ "$(pdi_count "$card" NICKNAME)" -gt 0 ] \
21 && edit_item "$card" NICKNAME
22 edit_item "$card" BDAY
23 edit_item "$card" X-ZACK-JOINDATE
24 [ "$(pdi_count "$card" X-ZACK-LEAVEDATE)" -gt 0 ] \
25 && edit_item "$card" X-ZACK-LEAVEDATE
26 card_item "$card" SOUND PHOTO LOGO
28 [div .section .phone $(edit_item "$card" TEL)]
29 [div .section .message $(
30 edit_item "$card" EMAIL
31 [ $(pdi_count "$card" IMPP) -gt 0 ] && edit_item "$card" IMPP
32 [ $(pdi_count "$card" URL ) -gt 0 ] && edit_item "$card" URL
34 [div .section .address $(edit_item "$card" ADR)]
35 [div .section .note $(edit_item "$card" NOTE)]
36 [div .section .attendance
37 [h3 $(l10n course_attendance) ] $(
38 for course in "$_DATA"/ical/*.ics; do
39 printf '[label [input type="checkbox" name="attendance" value="%s" %s] %s]' \
41 "$(grep -qF "${course##*/} ${cardfile##*/}" "$_DATA/mappings/attendance" \
42 && printf 'checked="checked"'
44 "$(pdi_value "$(pdi_load "$course")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
46 [h3 $(l10n CATEGORIES) ] $(
47 grep -xE '[^ ]+' "$_DATA"/mappings/categories |while read -r cat; do
48 printf '[label [input type="checkbox" name="CATEGORIES" value="%s" %s] %s]' \
50 "$(seq 1 $(pdi_count "$card" CATEGORIES) |while read c; do
51 pdi_value "$card" CATEGORIES $c |grep -qxF "$cat" \
52 && printf 'checked="checked"' && break
58 [div .item .delete label="$(l10n edit_delete)"
59 [input type="checkbox" #delete]
60 [label for="delete" $(l10n edit_delete)]
61 [button type="submit" name="action" value="delete" $(l10n edit_delete)]
64 [select name="newfield"
65 [option value="" disabled="disabled" selected="selected" $(l10n edit_addfieldtext)]
66 $(for f in NICKNAME EMAIL TEL IMPP ADR URL NOTE; do
67 printf '[option value="%s" %s] ' "$f" "$(l10n "$f")"
69 ][button type="submit" name="action" value="addfield" $(l10n edit_addfield)]
71 [button .item type="submit" name="action" value="update" $(l10n edit_update)]
72 [button .item type="submit" name="action" value="cancel" $(l10n edit_cancel)]
74 [input type="hidden" name="UID" value="$(pdi_value "$card" UID |HTML)"]
75 [input type="hidden" name="card" value="${cardfile##*/}"]
83 local card="$(pdi_load "$cardfile")"
85 [div .card #${cardfile##*/}
86 [div .section .basic . $(
87 card_item "$card" FN GENDER NICKNAME BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE SOUND PHOTO LOGO
89 [div .section .phone . $(card_item "$card" TEL)]
90 [div .section .message . $(card_item "$card" EMAIL IMPP URL)]
91 [div .section .address . $(card_item "$card" ADR)]
92 [div .section .note . $(card_item "$card" NOTE)]
93 [div .section .attendance [h3 $(l10n course_attendance) ] [ul
94 $(grep -F " ${cardfile##*/}" "$_DATA/mappings/attendance" |while read each discard; do
95 printf '[li [a .item .attendance href="/courses#%s" . %s]]' \
97 "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
99 $(card_item "$card" CATEGORIES)
102 [a .item href="/cards/edit_card.sh?card=${cardfile##*/}" $(l10n edit)]
103 [a .item href="/cards/export_card.sh?card=${cardfile##*/}" $(l10n vcf_export)]
110 local cardfile cachefile date size name ldate=0 lsize lname
112 while read cardfile; do
113 cachefile="${_DATA}/cache/${cardfile##*/}.cache"
114 # if [ -s "$cachefile" -a "$cachefile" -nt "$cardfile" \
115 # -a "$cachefile" -nt "${_EXEC}/cards" ]; then
116 if [ -s "$cachefile" -a "$cachefile" -nt "$cardfile" ]; then
119 print_card "$cardfile" |tee "$cachefile"
126 attfile="$_DATA/mappings/attendance"
128 if [ ! "$fatt" ]; then
130 printf '%s\n' "$_DATA/vcard"/*.vcf
131 elif [ "${fatt#* }" = "${fatt}" ]; then
133 grep -xiE "(${fatt}) .+vcf" "$attfile" \
135 printf '%s/vcard/%s\n' "$_DATA" "${vcf##* }"
138 # debug "filter ${fatt%% *}"
139 filter_attendance "${fatt#* }" \
141 grep -xiE "(${fatt%% *}) ${vcf##*/}" "$attfile"
144 printf '%s/vcard/%s\n' "$_DATA" "${vcf##* }"
150 local filter f fex='x;p;'
152 filter="$(printf %s "${filter}" \
153 | sed -E 's;[]\/\(\)\\\$\?\.\+\*\;\[\{\}];\\&;g;
157 while [ "$filter" ]; do
158 f="${filter%%^*}" filter="${filter#*^}"
162 COURSE:*) fatt="${fatt}${fatt:+ }${f#*:}"
164 ANY:*) fex="/\n.*(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}"
166 NAME:*) fex="/\n(N|FN|NICKNAME)(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}"
168 STREET:*|ZIP:*) fex="/\nADR(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}"
170 *) fex="/\n${f%%:*}(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}"
175 # for cardfile in "${_DATA}"/vcard/*.vcf; do
176 filter_attendance "$fatt" |while read cardfile; do
177 printf '%s\n' "$cardfile"
180 | sed -nE ':X; /\nEND\;?:VCARD\r?$/!{ N; bX; }; h; s;\n.*$;;; x; s;^[^\n]+\n;;;
187 while read cardfile; do
188 card="$(pdi_load "$cardfile")"
192 printf '%s %s\n' "$(pdi_value "$card" FN)" "$cardfile"
195 printf '%s %s\n' "$(pdi_value "$card" N || pdi_value "$card" FN)" "$cardfile"
198 printf '%s %s\n' "$(pdi_value "$card" BDAY || printf 0000-00-00)" "$cardfile"
203 | sed -E 's;^.*\t;;g'
209 | grep -xvF "$edit" \