X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;ds=inline;f=courses%2Fnew_course.sh;h=36de913dcf290b93fd802a7e7ba99a9dc31e53d4;hb=efd5370cddd0cfc4a0e94e7f4ec1792abb7259c6;hp=4f97d4aadc94d3144135ad6854efeecd1871d1e0;hpb=5ab459e666f2526f671fe222cd1646a4e6798b27;p=confetti
diff --git a/courses/new_course.sh b/courses/new_course.sh
index 4f97d4a..36de913 100755
--- a/courses/new_course.sh
+++ b/courses/new_course.sh
@@ -1,6 +1,6 @@
-#!/bin/zsh
+#!/bin/sh
-# Copyright 2014 Paul Hänsch
+# Copyright 2014, 2021 Paul Hänsch
#
# This file is part of Confetti.
#
@@ -17,30 +17,35 @@
# You should have received a copy of the GNU Affero General Public License
# along with Confetti. If not, see .
-cgi_post
+locktimeout=900
+. "$_EXEC"/session_lock.sh
-uid=$(uuidgenerator)
+uid="$(timeid)$(randomid)" # 32 Octets UID, starting with timestamp
course="${uid}.ics"
-tzid=$(cat /etc/timezone)
-tstamp=$(TZ="$tzid" date +%Y%m%dT%H%M%S)
+tzid="$(cat /etc/timezone)"
+tstamp="$(TZ="$tzid" date +%Y%m%dT%H%M%S)"
-tempfile="$_DATA/temp/$course"
+coursefile="$_DATA/ical/$course"
-cat >"$tempfile" <"$tempfile" <<-EOF
+ BEGIN:VCALENDAR
+ VERSION:2.0
+ PRODID:Berlin RAW Confetti
+ BEGIN:VEVENT
+ UID:$uid
+ DTSTAMP:TZID=${tzid}:${tstamp}
+ DTSTART:TZID=${tzid}:${tstamp}
+ DURATION:
+ RRULE:
+ SUMMARY:
+ COMMENT:
+ END:VEVENT
+ END:VCARD
+ EOF
+ REDIRECT "${_BASE}/courses/?e=${course}"
+else
+ SET_COOKIE session message="EDITLOCK"
+ REDIRECT "${_BASE}/courses/"
+fi