]> git.plutz.net Git - confetti/blobdiff - cards/edit_card.sh
merge from cgilite
[confetti] / cards / edit_card.sh
similarity index 57%
rename from actions/filter_card.sh
rename to cards/edit_card.sh
index cc0f9127e404fbbaf52ba752ad97d4545dc70ddc..4239cc5968c03b5e58d11a96d0e0ae22f68de41f 100755 (executable)
@@ -1,6 +1,6 @@
-#!/bin/zsh
+#!/bin/sh
 
-# Copyright 2014, 2017 Paul Hänsch
+# Copyright 2019 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-cgi_post
+locktimeout=900
+. "$_EXEC"/session_lock.sh
 
-if [ "${_POST[choice]}" = new_filter ]; then
-  filter="$(
-    for n in filter{0..100}; do
-      # [ -z "${_POST[$n]:+x}" ] && break
-      printf %s "${_POST[$n]}"
-    done \
-    | sed -r 's;\|+;\|;g; s;\^+;\^;g; s;:\|;:;g; :X; s;\^[^:]*:\^;\^;g; /\^[^:]*:\^/bX; s;^\^;;; s;\^[^:]*:$;;;'
-  )"
-  printf 'Location: ?p=cards&order=%s&filter=%s\n\n' "${_POST[order]}" "$filter"
+card="$(GET card |PATH)"
+cardfile="$_DATA/vcard/${card##*/}"
+filter="$(REF f)"
+order="$(REF o)"
+
+if tempfile="$(SLOCK "$cardfile" "$locktimeout")"; then
+  REDIRECT "/cards/?o=${order}&f=${filter}&e=${card}"
+elif [ -f "$tempfile" ]; then
+  SET_COOKIE session message="SESSLOCK"
+  REDIRECT "/cards/?o=${order}&f=${filter}#${card}"
 else
-  printf 'Location: ?p=cards\n\n'
+  SET_COOKIE session message="EDITLOCK"
+  REDIRECT "/cards/?o=${order}&f=${filter}#${card}"
 fi