support for maniupulating vcard categories
[confetti] / templates / edit_card.sh
index b3af045..741a312 100755 (executable)
@@ -27,6 +27,16 @@ check_gen() {
 check_a() {
   egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked
 }
+check_c() {
+  for n in CATEGORIES CATEGORIES{0..100}; do
+    if [ -n "${values[$n]+x}" ]; then
+      [ "${values[$n]}" = "$1" ] && setchecked && break
+    else
+      break
+    fi
+  done
+}
+
 teltype() {
   cat <<-EOF
        <select class="item phonetype" name="phonetype">
@@ -141,6 +151,11 @@ if [ "$PROFILE" = circus ]; then
            printf '<label><input type="checkbox" name="attendance" value="%s" %s/>%s</label>' \
              "$(attribsafe "$each")" "$(check_a "$each")" "$(htmlsafe "$cname")"
          done)
+          <h3>$(l10n CATEGORIES)</h3>
+          $(list_categories |while read each; do
+            printf '<label><input type="checkbox" name="CATEGORIES" value="%s" %s/>%s</label>' \
+              "$(attribsafe "$each")" "$(check_c "$each")" "$(htmlsafe "$each")"
+          done)
        </div>
        END_HTML
 elif [ "$PROFILE" = medical ]; then