X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=therapies%2Fupdate_therapy.sh;h=dafa1b20692d474484eb3f5b24ff5d69496272dc;hb=1e1cb695a2a413f310c4538c0d3b951f4d4fe72f;hp=ec8ccdc0878128c43a27872cecfcd26b1bcdf60f;hpb=90041d8be2590c270a69f1eb44b882a863491aca;p=lobster diff --git a/therapies/update_therapy.sh b/therapies/update_therapy.sh old mode 100755 new mode 100644 index ec8ccdc..dafa1b2 --- a/therapies/update_therapy.sh +++ b/therapies/update_therapy.sh @@ -17,8 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . -BR=' -' +. "$_EXEC/pdiread.sh" tpy=$(POST id) tpyfile="$_DATA/therapies/${tpy}.tpy" @@ -26,8 +25,41 @@ tempfile="$_DATA/temp/${tpy}.tpy" # serialize POST array into file for key in $(POST_KEYS); do - [ "$key" != imagedata ] && printf %s:%s\\n "$key" "$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" -done >"$tempfile" + case "$key" in + imagedata) : ;; + session*_date) + value="$(POST "$key")" + y=0 mon=0 dom=0 + case $value in + *.*.*) IFS=. read dom mon y <<-END + ${value} + END + ;; + *.*.) IFS=. read dom mon <<-END + ${value} + END + ;; + */*/*) IFS=/ read mon dom y <<-END + ${value} + END + ;; + */*) IFS=/ read mon dom <<-END + ${value} + END + ;; + *-*-*) IFS=- read y mon dom <<-END + ${value} + END + ;; + esac + [ ! "$y" ] && y="$(date +%Y)" + [ "$y" -gt 0 -a "$y" -lt 100 ] && y="$((y + 2000))" + date -d "${y}-${mon}-${dom}" + && printf %s:%s\\n "$key" "$(date -d "${y}-${mon}-${dom}" +%F)" \ + || printf %s:\\n "$key" + ;; + *) printf %s:%s\\n "$key" "$(pdi_escape "$(POST "$key")")" ;; + esac +done >"$tempfile" 2>&- if [ "$(POST delete_session)" ]; then n="$(POST delete_session)" @@ -65,5 +97,10 @@ elif [ "$(POST imagedata)" ]; then fi mv "$tempfile" "$tpyfile" +rm -f "${_DATA}/cache/${tpy%%.*}.vcf.cache" -REDIRECT "/therapies/${tpy%.*}/${tpy#*.}" +if [ "$(POST autosubmit)" = "true" ]; then + printf 'HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n' +else + REDIRECT "/therapies/${tpy%.*}/${tpy#*.}" +fi