order="&order=$_REF[\"order\"]"
card="$_POST[\"card\"]"
-tempfile="temp/$card"
-cardfile="vcard/$card"
+tempfile="$_DATA/temp/$card"
+cardfile="$_DATA/vcard/$card"
+attfile="$_DATA/mappings/attendance"
echo "BEGIN:VCARD\r" >"$tempfile"
echo "VERSION:4.0\r" >>"$tempfile"
echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}&edit=$card\n\n"
;;
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" >>"$attfile"
+ done
+
echo "END:VCARD\r" >>"$tempfile"
mv "$tempfile" "$cardfile"
echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}#$card\n\n"
[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
# create directories for object storage
-for each in "$_DATA"/{vcard,ical,cache,temp}; do
+for each in "$_DATA"/{vcard,ical,cache,temp,mappings}; do
[ ! -e "$each" ] && mkdir "$each"
[ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
done
+touch "$_DATA/mappings/attendance"
# create htaccess file
[ -f .htaccess ] || cat >.htaccess <<EOF
[ -z "$_GET[\"order\"]" ] && _GET["order"]=firstname
+listcourses() {
+ ls -1 ${_DATA}/ical/*ics |while read file; do
+ 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")"
+ echo "$(date -d "$icstime" "+%u %H%M%S")\t$file"
+ done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:'
+}
+
listcards() {
case "$_GET[\"filtertype\"]" in
any)
display: inline-block;
float:left;
width: 20ex;
- margin: .125em .5ex .5ex .5ex;
+ margin: .125em .25ex .5ex .25ex;
padding: 0 .2em .2em .2em;
background: #EEE;
}
+.cardlist .card .section a.attendance {
+ display: inline-block;
+ margin-right: 1ex;
+ word-wrap: break-word;
+}
+
+.cardlist .card .attendance {
+ width: 83.5ex;
+}
+.cardlist .card .attendance .check {
+ display: inline-block;
+ width: 27ex;
+}
+
.cardlist .card .control {
float: right;
text-align: right;
check_gen() {
[ "$value[GENDER]" = "$1" ] && echo 'selected="selected"'
}
+check_a() {
+ egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && echo 'checked="checked"'
+}
n_last="$(echo "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
n_first="$(echo "$values[N]" |sed -rn 's:^([^;]*;){1} *([^;]*).*$:\2:p')"
done
echo ' </div>'
echo ''
+echo ' <div class="section attendance">'
+echo ' <span class="sectitle">'$(l10n course_attendance)'</span>'
+listcourses |while read each; do
+ cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")"
+ echo ' <span class="check attendance"><input type="checkbox" name="attendance" value="'$each'" '$(check_a "$each")'/>'$cname'</span>'
+done
+echo ' </div>'
+echo ''
echo ' <div class="section control">'
echo ' <button class="item control" type="submit" name="action" value="addfield">'$(l10n edit_addfield)'</button>'
echo ' <select class="item control" name="newfield">'
item_name[filter_apply]="Filtern"
item_name[filter_cancel]="Filter löschen"
item_name[newcard]="Neuen Eintrag anlegen"
+item_name[course_attendance]="Kursteilnahme"
l10n() {
[ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1"
done
echo ' </div>'
echo ''
+echo ' <div class="section">'
+echo ' <span class="sectitle">'$(l10n course_attendance)'</span>'
+sed -rn 's:(.*)\t'$id'$:\1:p' "$_DATA/mappings/attendance" |while read each; do
+ cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")"
+ echo ' <a class="item attendance" href="/?page=courses#'$each'">'$cname'</a>'
+done
+echo ' </div>'
+echo ''
echo ' <div class="section control">'
echo ' <a class="item control" href="?action=edit_attendee&card='${id}'">'$(l10n edit)'</a>'
echo ' <a class="item control" href="?export=vcard&card='${id}'">'$(l10n vcf_export)'</a>'