2 # Copyright 2011 Paul Haensch
3 # This file is part of Busy
5 # Busy is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # Busy is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Busy. If not, see <http://www.gnu.org/licenses/>.
18 #info="$(egrep -o '(^|&)i=[0-9]{10}_[0-9]{3}(&|$)' <<<"${QUERY_STRING}" |tr -d '&i=')"
19 [ "$HTTPS" = "on" ] && PROTO=https || proto=http
22 $ACL_CREATETASK || echo "Location: ${proto}://${HTTP_HOST}/?p=Error&i=noaccess\n\n"
23 $ACL_CREATETASK || exit 0
25 info="$(sed -r 's:(^|.*&)i=(.*)|.*:\2:;s:&.*::' <<<"${QUERY_STRING}")"
27 [ -z "$info" ] && info="$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
28 descfile="../Tasks/$info.meta"
29 commfile="../Tasks/$info.comment.$(date +%s)_$(apg -M N -a 1 -n 1 -m 3 -x 3)"
31 [ -f "../Tasks/$info.lock" ] && rm "../Wiki/$info.lock"
32 anchor=$(ls ../Tasks |grep -A2 $info |grep '.meta$' |tail -n1 |cut -d. -f1)
34 if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
35 (head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
36 if (egrep -xq 'headline=.+' <<<"${line}"); then
37 headline="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
38 headline="$(echo -e "${headline}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
39 elif (egrep -xq 'status=.+' <<<"${line}"); then
40 taskstatus="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
41 taskstatus="$(echo -e "${taskstatus}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
42 elif (egrep -xq 'section=.+' <<<"${line}"); then
43 section="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
44 section="$(echo -e "${section}" |sed 's/\t/ /g;s/\r//g;s/\\/\\\\/g' |head -n1)"
45 elif (egrep -xq 'description=.+' <<<"${line}"); then
46 description="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
47 description="$(echo -e "${description}" |sed 's/\r//g;s/\\/\\\\/g')"
48 elif (egrep -xq 'comm=.+' <<<"${line}"); then
49 comment="$(cut -d= -f2- <<<"${line}" |sed 's/+/ /g;s/%/\\x/g')"
50 comment="$(echo -e "${comment}" |sed 's/\r//g;s/\\/\\\\/g')"
51 elif (egrep -xq 'cancel=.+' <<<"${line}"); then
57 if [ -z "$cancel" -a -n "$comment" ]; then
58 touch "../Tasks/$info"
59 echo -e "author=${REMOTE_USER}" > "$commfile"
60 echo -e "${comment}" >> "$commfile"
61 echo -n "Location: ${proto}://${HTTP_HOST}/?p=Tasks&i=$info\n\n"
62 elif [ -z "$cancel" -a -n "$description" ]; then
63 touch "../Tasks/$info"
64 echo -e "headline=${headline}" > "$descfile"
65 echo -e "status=${taskstatus}" >> "$descfile"
66 echo -e "section=${section}" >> "$descfile"
67 echo -e "${description}" >> "../Tasks/$info"
68 echo -n "Location: ${proto}://${HTTP_HOST}/?p=Tasks#$anchor\n\n"
69 elif [ -n "$cancel" ]; then
70 echo -n "Location: ${proto}://${HTTP_HOST}/?p=Tasks#$anchor\n\n"