]> git.plutz.net Git - confetti/blobdiff - cards/update_card.sh
portable sed usage
[confetti] / cards / update_card.sh
index 7896beb5011d3cee5892b9d6c099a8693d34caa3..4ae9c19dc3426eac411779585d9712f6d5ca5b74 100755 (executable)
@@ -1,6 +1,6 @@
-#!/bin/zsh
+#!/bin/sh
 
 
-# Copyright 2014, 2016, 2019, 2020 Paul Hänsch
+# Copyright 2014, 2016, 2019, 2020, 2021 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
 #
 # This file is part of Confetti.
 # 
@@ -65,6 +65,7 @@ vcf_escape(){
 vcf="$(pdi_load "$cardfile")"
 
 vcf="$(pdi_update_value "$vcf" N 1 "$(vcf_escape "$(POST 1N)" "$(POST 2N)" "$(POST 3N)" "$(POST 4N)" "$(POST 5N)")")"
 vcf="$(pdi_load "$cardfile")"
 
 vcf="$(pdi_update_value "$vcf" N 1 "$(vcf_escape "$(POST 1N)" "$(POST 2N)" "$(POST 3N)" "$(POST 4N)" "$(POST 5N)")")"
+vcf="$(printf '%s\n' "$vcf" |sed -E "/^CATEGORIES;[^:]*:.*$/d")"
 
 for field in $(POST_KEYS |grep -xE '[A-Z][A-Z0-9-]*'); do
   for cnt in $(seq 1 $(POST_COUNT "$field")); do
 
 for field in $(POST_KEYS |grep -xE '[A-Z][A-Z0-9-]*'); do
   for cnt in $(seq 1 $(POST_COUNT "$field")); do
@@ -104,14 +105,14 @@ case "$action" in
   update)
     if LOCK "$attfile"; then
       grep -F "        ${card}" "$attfile" |while read course junk; do
   update)
     if LOCK "$attfile"; then
       grep -F "        ${card}" "$attfile" |while read course junk; do
-        touch "$_DATA/courses/${course}"
+        touch "$_DATA/ical/${course}"
       done
       done
-      sed -i -r "/^.+  ${card}\$/d" "$attfile"
+      sed -i -E "/^.+  ${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
       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}"
+        touch "$_DATA/ical/${course}"
       done
       RELEASE "$attfile"
     else
       done
       RELEASE "$attfile"
     else
@@ -131,6 +132,15 @@ case "$action" in
   delete)
     rm "$cardfile"
     RELEASE_SLOCK "$cardfile"
   delete)
     rm "$cardfile"
     RELEASE_SLOCK "$cardfile"
+    if LOCK "$attfile"; then
+      grep -F "        ${card}" "$attfile" |while read course junk; do
+        touch "$_DATA/ical/${course}"
+      done
+      sed -i -E "/^.+  ${card}\$/d" "$attfile"
+      RELEASE "$attfile"
+    else
+      SET_COOKIE 0 message="COULD NOT UPDATE COURSE MAPPINGS"
+    fi
     REDIRECT "/cards/?o=${order}&f=${filter}"
     ;;
 esac
     REDIRECT "/cards/?o=${order}&f=${filter}"
     ;;
 esac