esac |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:'
}
+list_attendance() {
+ id="$1"
+ sed -rn 's:'$id'\t(.+)$:\1:p' "$_DATA/mappings/attendance" |while read each; do
+ n_last="$( sed -rn 's:^N(;.+)*\:([^;]*;){0} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
+ n_first="$( sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
+ n_middle="$(sed -rn 's:^N(;.+)*\:([^;]*;){2} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
+ n_pre="$( sed -rn 's:^N(;.+)*\:([^;]*;){3} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
+ n_post="$( sed -rn 's:^N(;.+)*\:([^;]*;){4} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
+ byear="$( sed -rn 's:^BDAY(;.+)*\:([0-9]{4})(-[0-9][0-9]){2}.*$:\2:p' "$_DATA/vcard/$each")"
+ #aname="${n_pre} ${n_first} ${n_middle} ${n_last} ${n_post} (*${byear})"
+ aname="${n_pre} ${n_first} ${n_middle} ${n_last} ${n_post}"
+ echo "$each $aname" |tr -d '\r'
+ done
+}
+
+course_mail() {
+ id="$1"
+ coursemail=""
+ sed -rn 's:'$id'\t(.+)$:\1:p' "$_DATA/mappings/attendance" |while read each; do
+ coursemail="$coursemail$(sed -rn 's:^EMAIL(;.+)*\:(.+)\r$:\2,:p' "$_DATA/vcard/$each")"
+ done
+ echo "$coursemail"
+}
+
ics_parse() {
tr -d '\n' <"$1" |sed -r 's:\r ::g;s:\r:\n:g' |tr -d '\r' \
| sed -r 's:^([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:key="\1"\nvalue="\3"\ntag=\2:g' \
echo ' <div class="section attendance">'
echo ' <span class="sectitle">'$(l10n course_attendance)'</span>'
-sed -rn 's:'$id'\t(.+)$:\1:p' "$_DATA/mappings/attendance" |while read each; do
- n_last="$( sed -rn 's:^N(;.+)*\:([^;]*;){0} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
- n_first="$( sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
- n_middle="$(sed -rn 's:^N(;.+)*\:([^;]*;){2} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
- n_pre="$( sed -rn 's:^N(;.+)*\:([^;]*;){3} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
- n_post="$( sed -rn 's:^N(;.+)*\:([^;]*;){4} *([^;]*).*$:\3:p' "$_DATA/vcard/$each")"
- aname="${n_pre} ${n_first} ${n_middle} ${n_last} ${n_post}"
- echo ' <a class="attendance" href="/?page=attendees#'$each'">'$aname'</a>'
-
- coursemail="$coursemail$(sed -rn 's:^EMAIL(;.+)*\:(.+)\r$:\2,:p' "$_DATA/vcard/$each")"
-done
+list_attendance "$id" |sort -k 2 |sed -r 's:^([^ ]+) (.*)$:<a class="attendance" href="/?page=attendees#\1">\2</a>:'
echo ' </div>'
echo ' <div class="section control">'
echo ' <a class="item control" href="?action=edit_course&course='${id}'">'$(l10n edit)'</a>'
echo ' <a class="item control" href="?export=ical&course='${id}'">'$(l10n ics_export)'</a>'
-echo ' <a class="item control" href="mailto:zack@vuesch.org?bcc='$coursemail'">'$(l10n course_mail)'</a>'
+echo ' <a class="item control" href="mailto:zack@vuesch.org?bcc='$(course_mail "$id")'">'$(l10n course_mail)'</a>'
echo ' </div>'
echo '<input type="hidden" name="UID" value="'$values["UID"]'"/>'
echo '</form>'