]> git.plutz.net Git - lobster/blobdiff - therapies/update_therapy.sh
quick fix: put temp file into lock, should switch to session_lock functions
[lobster] / therapies / update_therapy.sh
index bb3901fbe21f66d3cbf6ecafb87d39e9ff1afc68..e084e6ddc9e7dfe361e625f44c541fdf62fd2cda 100755 (executable)
 tpy="$(POST id)"
 
 tpyfile="$_DATA/therapies/${tpy}.tpy"
-tempfile="$_DATA/temp/${tpy}.tpy"
+tempfile="$_DATA/lock/${tpy}.$$.tpy"
 
 if [ "$(POST tid)" != "$(transid "$tpyfile")" ]; then
   if [ "$(POST autosubmit)" = "true" ]; then
     printf 'Status: 409 Conflict\r\nContent-Length: 0\r\n\r\n'
     exit 0
   else
-    SET_COOKIE session message="TRANSACTION CONFLICT"
+    SET_COOKIE session message="TRANSACTION_CONFLICT"
+    REDIRECT "/therapies/${tpy%.*}/${tpy#*.}"
+  fi
+fi
+
+if [ "$(POST formend)" != "formend" ]; then
+  if [ "$(POST autosubmit)" = "true" ]; then
+    printf 'Status: 409 Conflict\r\nContent-Length: 0\r\n\r\n'
+    exit 0
+  else
+    SET_COOKIE session message="INCOMPLETE_SUBMIT"
     REDIRECT "/therapies/${tpy%.*}/${tpy#*.}"
   fi
 fi
@@ -36,7 +46,7 @@ fi
 # serialize POST array into file
 for key in $(POST_KEYS); do
   case "$key" in
-    imagedata|tid) : ;;
+    imagedata|tid|formend) : ;;
     session*_date)
       value="$(POST "$key")"
       y=0 mon=0 dom=0
@@ -115,6 +125,8 @@ if [ "$(POST autosubmit)" = "true" ]; then
   msg="$(transid "$tpyfile")"
   printf 'HTTP/1.1 200 OK\r\nContent-Length: %i\r\n\r\n%s' \
          "${#msg}" "${msg}"
+elif [ "$(POST vcfreturn)" ]; then
+  REDIRECT "/cards/#${tpy%.*}.vcf"
 else
   REDIRECT "/therapies/${tpy%.*}/${tpy#*.}"
 fi