X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=courses%2Fedit_course.sh;fp=courses%2Fedit_course.sh;h=523534486723feafe08f67197825591ae81aa3a3;hp=1841e056b00ffc5038b9c4751bf041dfb4edc1d5;hb=009e9158a9241258da11b1b5c582f8176b0b7e0f;hpb=203fc5d63ba59a30688bac00c98d199cb08a8f30 diff --git a/courses/edit_course.sh b/courses/edit_course.sh index 1841e05..5235344 100755 --- a/courses/edit_course.sh +++ b/courses/edit_course.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 Paul Hänsch +# Copyright 2014, 2019, 2020 Paul Hänsch # # This file is part of Confetti. # @@ -17,6 +17,18 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . -course="${_GET[course]}" +locktimeout=900 +. "$_EXEC"/session_lock.sh -echo -n "Location: ?p=courses&edit=$course\n\n" +course="$(GET course |PATH)" +coursefile="$_DATA/courses/${course##*/}" + +if tempfile="$(SLOCK "$coursefile" "$locktimeout")"; then + REDIRECT "/courses/?e=${course}" +elif [ -f "$tempfile" ]; then + SET_COOKIE session message="SESSLOCK" + REDIRECT "/courses/#${course}" +else + SET_COOKIE session message="EDITLOCK" + REDIRECT "/courses/#${course}" +fi