]> git.plutz.net Git - lobster/commitdiff
edit course attendees form course display
authorpaul <paul@plutz.net>
Wed, 12 Mar 2014 16:15:07 +0000 (16:15 +0000)
committerpaul <paul@plutz.net>
Wed, 12 Mar 2014 16:15:07 +0000 (16:15 +0000)
svn path=/trunk/; revision=41

pages/courses.sh
templates/edit_course.sh

index c0aab02520dcff39991c2e54b4ac6f30f86ff266..ea708e93b164c8c9d5c35e8c26c4c6c363343e52 100755 (executable)
@@ -2,6 +2,14 @@
 
 [ -z "$_GET[\"order\"]" ] && _GET["order"]=DOW
 
+listcards() {
+  ls -1 ${_DATA}/vcard/*vcf 2>/dev/null |while read file; do
+    fn=$(sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$file")
+    echo "$fn\t$file"
+  done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:'
+}
+
+
 listcourses() {
   case "$_GET[\"filtertype\"]" in
     *) ls -1 ${_DATA}/ical/*ics 2>/dev/null
index ff932a1d5150e6e7461edc9d5d8f6b25d6bcb79f..ea5e88d0b957857b022b3366e79250bcad4295a4 100755 (executable)
@@ -132,6 +132,21 @@ done
 echo '    </select>'
 echo '  </div>'
 
+echo '  <div class="section select_attendance">'
+echo '    <span class="sectitle">'$(l10n course_attendance)'</span>'
+echo '    <select class="item attendance" name="attendance" multiple="multiple">'
+listcards |while read card; do
+  cfile="$_DATA/vcard/$card"
+  aname=$(sed -rn 's:^N(;[^"\:]+|;"[^"]+")*\:([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\5 \3 \4 \2 \6:p' "$cfile" \
+          |sed -r 's:,: :;s:\;: :g;s: +: :g' \
+          |tr -d '\r'
+         )
+  selected=$(sed -rn "s:^$id\t$card\$:selected=\"selected\":p" $_DATA/mappings/attendance)
+  echo '    <option value="'$card'" '$selected'>'$aname'</option>'
+done
+echo '    </select>'
+echo '  </div>'
+
 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">'