]> git.plutz.net Git - confetti/blobdiff - courses/new_course.sh
merge from cgilite
[confetti] / courses / new_course.sh
similarity index 51%
rename from templates/prescriptions.html.sh
rename to courses/new_course.sh
index c4ef19addc060da015f8db7c6954aaebd23a38f1..362752dbb2a70cdd8deb1ec87cac38c1524374fd 100755 (executable)
@@ -1,4 +1,6 @@
-# Copyright 2016 Paul Hänsch
+#!/bin/sh
+
+# Copyright 2014, 2021 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/>. 
 
-client="${_GET[client]}"
-edit="${_GET[edit]}"
-[ -n "$edit" ] && client="${edit%.*.mpx}.vcf"
-
-cat <<EOF
-
-<div id="${card}" class="card">$(view_card "$client")</div>
-
-<!--h1>$(l10n prescriptions_current)</h1-->
-
-<div class="newprescription">
-  <form action="?action=new_prescription" method="POST">
-    <input type="hidden" name="client" value="$client">
-    <button type="submit">$(l10n newprescription)</button>
-  </form>
-</div>
-EOF
-
-list_prescriptions "$client" |grep -q "$edit" || edit_prescription "$edit"
-
-list_prescriptions "$client" \
-|while read pre; do 
-  [ "$pre" = "$edit" ] \
-  && edit_prescription "$pre" \
-  || view_prescription "$pre"
-done
-
-#<!--h1>$(l10n prescriptions_past)</h1-->
-
-# vi:set filetype=html:
+locktimeout=900
+. "$_EXEC"/session_lock.sh
+
+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)"
+
+coursefile="$_DATA/ical/$course"
+
+if tempfile="$(SLOCK "$coursefile")"; then
+  cat >"$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 "/courses/?e=${course}"
+else
+  SET_COOKIE session message="EDITLOCK"
+  REDIRECT "/courses/"
+fi