"${course##*/}" \
"$(grep -qF "${course##*/} ${cardfile##*/}" "$_DATA/mappings/attendance" \
&& printf 'checked="checked"'
- )" \
- "$(pdi_value "$(pdi_load "$course")" SUMMARY |unescape |HTML)"
+ )" \
+ "$(pdi_value "$(pdi_load "$course")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
done)
[h3 $(l10n CATEGORIES) ] $(
grep -xE '[^ ]+' "$_DATA"/mappings/categories |while read -r cat; do
[div .section .message . $(card_item "$card" EMAIL IMPP URL)]
[div .section .address . $(card_item "$card" ADR)]
[div .section .note . $(card_item "$card" NOTE)]
- [div .section .attendance [h3 $(l10n course_attendance) ] [ul .
+ [div .section .attendance [h3 $(l10n course_attendance) ] [ul
$(grep -F " ${cardfile##*/}" "$_DATA/mappings/attendance" |while read each discard; do
printf '[li [a .item .attendance href="/courses#%s" . %s]]' \
"$each" \
- "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY |unescape |HTML)"
+ "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
done)]
$(card_item "$card" CATEGORIES)
]
#!/bin/zsh
-# Copyright 2014, 2016, 2019 Paul Hänsch
+# Copyright 2014, 2016, 2019, 2020 Paul Hänsch
#
# This file is part of Confetti.
#
. "$_EXEC/pdiread.sh"
. "$_EXEC/session_lock.sh"
+. "$_EXEC/cgilite/storage.sh"
unset filter order card action newfield
unset cardfile attfile tempfile
filter="$(REF f)"
order="$(REF o)"
-card="$(POST card |PATH)"
-cardfile="$_DATA/vcard/${card##*/}"
+card="$(POST card |PATH)"; card="${card##*/}"
+cardfile="$_DATA/vcard/${card}"
attfile="$_DATA/mappings/attendance"
action="$(POST action)"
REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
;;
update)
- # attendance=()
- # for att in attendance attendance{0..100}; do
- # [ -n "${_POST[$att]}" ] && attendance+=("${_POST[$att]}")
- # done
- # sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do
- # touch "$_DATA/ical/$course"
- # done
- # sed -i -r '/^(.+)\t'$card'$/d' "$attfile"
- # for each in $attendance; do
- # echo "$each\t$card"
- # done >>"$attfile"
- # sed -rn 's:^(.+)'$card'$:\1:p' "$attfile" |while read course; do
- # touch "$_DATA/ical/$course"
- # done
+ if LOCK "$attfile"; then
+ grep -F " ${card}" "$attfile" |while read course junk; do
+ touch "$_DATA/courses/${course}"
+ done
+ sed -i -r "/^.+ ${card}\$/d" "$attfile"
+ seq 1 $(POST_COUNT attendance) |while read n; do
+ printf '%s %s\n' "$(POST attendance $n)" "$card"
+ done >>"$attfile"
+ grep -F " ${card}" "$attfile" |while read course junk; do
+ touch "$_DATA/courses/${course}"
+ done
+ RELEASE "$attfile"
+ else
+ SET_COOKIE 0 message="COULD NOT UPDATE COURSE MAPPINGS"
+ fi
cp "$tempfile" "$cardfile"
RELEASE_SLOCK "$cardfile"