]> git.plutz.net Git - lobster/blobdiff - therapies/update_therapy.sh
Merge commit '8456138268c26b78936c0c2b22a7cc6ab9a7dd14' into cgilite
[lobster] / therapies / update_therapy.sh
index 406f4f983ca809d53bb94e13c2f559bc36440869..dafa1b20692d474484eb3f5b24ff5d69496272dc 100755 (executable)
@@ -17,8 +17,7 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-BR='
-'
+. "$_EXEC/pdiread.sh"
 tpy=$(POST id)
 
 tpyfile="$_DATA/therapies/${tpy}.tpy"
@@ -27,9 +26,9 @@ tempfile="$_DATA/temp/${tpy}.tpy"
 # serialize POST array into file
 for key in $(POST_KEYS); do
   case "$key" in
-    imagedata) true ;;
+    imagedata) : ;;
     session*_date)
-      value="$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')"
+      value="$(POST "$key")"
       y=0 mon=0 dom=0
       case $value in
         *.*.*) IFS=. read dom mon y <<-END
@@ -58,9 +57,9 @@ for key in $(POST_KEYS); do
       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" "$(POST "$key" |sed ':X;N;$!bX; s;\n;\\n;g;')" ;;
+    *) printf %s:%s\\n "$key" "$(pdi_escape "$(POST "$key")")" ;;
   esac
-done >"$tempfile"
+done >"$tempfile" 2>&-
 
 if [ "$(POST delete_session)" ]; then
   n="$(POST delete_session)"
@@ -100,4 +99,8 @@ 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