]> git.plutz.net Git - confetti/blobdiff - courses/edit_course.sh
merge from cgilite
[confetti] / courses / edit_course.sh
similarity index 60%
rename from actions/new_course.sh
rename to courses/edit_course.sh
index 4f97d4aadc94d3144135ad6854efeecd1871d1e0..3c0c54fc9dee25db23b6eb5fe0a4d5075865099e 100755 (executable)
@@ -1,6 +1,6 @@
-#!/bin/zsh
+#!/bin/sh
 
 
-# Copyright 2014 Paul Hänsch
+# Copyright 2014, 2019, 2020 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
 #
 # 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/>. 
 
 # 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
 
 
-uid=$(uuidgenerator)
-course="${uid}.ics"
+course="$(GET course |PATH)"
+coursefile="$_DATA/ical/${course##*/}"
 
 
-tzid=$(cat /etc/timezone)
-tstamp=$(TZ="$tzid" date +%Y%m%dT%H%M%S)
-
-tempfile="$_DATA/temp/$course"
-
-cat >"$tempfile" <<EOF
-BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:Berlin RAW Confetti
-BEGIN:VEVENT
-UID:$uid
-DTSTAMP:TZID=${tzid}:${tstamp}
-DTSTART:
-DURATION:
-RRULE:
-SUMMARY:
-COMMENT:
-END:VEVENT
-END:VCARD
-EOF
-
-echo -n "Location: ?p=courses&edit=$course\n\n"
+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