-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathremove-file.rsp
44 lines (41 loc) · 1.02 KB
/
remove-file.rsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<%
alpha: charset [#"a" - #"z"]
if any [
validate/full [
id integer! *
file - *
]
all [
positive? request/content/id
empty? ticket: get-raw-ticket request/content/id
]
not parse file: request/content/file [some alpha]
][
response/redirect "view-tickets.rsp"
]
params: request/content
if any [
all [
positive? params/id
session/content/user-role = 'reporter
session/content/user-id <> ticket/17 ; ticket's owner allowed to edit
]
all [
positive? params/id
session/content/user-role = 'reporter
session/content/user-id = ticket/17 ; ticket's owner is current user
ticket/10 = 6 ; dismissed ticket can't be edited by owner (Reporter)
]
][
deny-access
]
file: to file! join file %.att
either negative? params/id [
remove-each f any [session/content/files []][f/2 = file]
][
remove-file params/id file
]
target: join file %-small.png
attempt [rename join %public/files/ target join target %.deleted]
attempt [rename join %public/files/ file join file %.deleted]
%>