Commit | Line | Data |
---|---|---|
88a858ea AC |
1 | <% @header[("title", ["Hosted sites"])]; |
2 | ||
3 | val admin = Group.inGroupName "links"; | |
4 | val you = Init.getUserId (); | |
5 | ||
6 | ref showNormal = true; | |
7 | ||
8 | if $"cmd" = "add" then | |
9 | val id = Link.addLink (you, $"title", $"url", $"descr") %> | |
b6dd1aaf | 10 | <h3>Link added</h3> |
88a858ea AC |
11 | |
12 | <% elseif $"mod" <> "" then | |
13 | val id = Web.stoi ($"mod"); | |
14 | val link = Link.lookupLink id; | |
15 | if (iff admin then false else you <> #usr link) then | |
b6dd1aaf | 16 | %><h3>You can't modify somebody else's link.</h3><% |
88a858ea AC |
17 | else |
18 | showNormal := false %> | |
19 | ||
b6dd1aaf | 20 | <h3>Modify link</h3> |
88a858ea | 21 | |
a4ccdb5e | 22 | <form action="link" method="post"> |
88a858ea | 23 | <input type="hidden" name="save" value="<% id %>"> |
b6dd1aaf | 24 | <table class="blanks"> |
10e55875 CE |
25 | <tr> <td>Title:</td> <td><input name="title" value="<% Web.html (#title link) %>" required="required"></td> </tr> |
26 | <tr> <td>URL:</td> <td><input name="url" value="<% Web.html (#url link) %>" type="url" required="required"></td> </tr> | |
27 | <tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr link) %>" required="required"></td> </tr> | |
88a858ea AC |
28 | <tr> <td><input type="submit" value="Save"></td> </t> |
29 | </table> | |
30 | </form> | |
31 | <% end | |
32 | ||
33 | elseif $"save" <> "" then | |
34 | val id = Web.stoi ($"save"); | |
35 | val link = Link.lookupLink id; | |
36 | if (iff admin then false else you <> #usr link) then | |
b6dd1aaf | 37 | %><h3>You can't modify somebody else's link.</h3><% |
88a858ea AC |
38 | else |
39 | Link.modLink {link with title = $"title", url = $"url", descr = $"descr"} | |
b6dd1aaf | 40 | %><h3>Link modified</h3><% |
88a858ea AC |
41 | end |
42 | ||
43 | elseif $"del" <> "" then | |
44 | val id = Web.stoi ($"del"); | |
45 | val link = Link.lookupLink id; | |
46 | if (iff admin then false else you <> #usr link) then | |
b6dd1aaf | 47 | %><h3>You can't delete somebody else's link.</h3><% |
88a858ea AC |
48 | else |
49 | showNormal := false %> | |
b6dd1aaf | 50 | <h3>Are you sure you want to delete link to "<% Web.html (#title link) %>"?</h3> |
88a858ea AC |
51 | <a href="link?del2=<% id %>">Yes, delete "<% Web.html (#title link) %>"!</a><% |
52 | end | |
53 | ||
54 | elseif $"del2" <> "" then | |
55 | val id = Web.stoi ($"del2"); | |
56 | val link = Link.lookupLink id; | |
57 | if (iff admin then false else you <> #usr link) then | |
b6dd1aaf | 58 | %><h3>You can't delete somebody else's link.</h3><% |
88a858ea AC |
59 | else |
60 | Link.deleteLink id; | |
b6dd1aaf | 61 | %><h3>Link "<% Web.html (#title link) %>" deleted</h3><% |
88a858ea AC |
62 | end |
63 | end; | |
64 | ||
65 | if showNormal then %> | |
66 | ||
b6dd1aaf | 67 | <h3>Add a link to a site you host with Hcoop</h3> |
88a858ea | 68 | |
a4ccdb5e | 69 | <form action="link" method="post"> |
88a858ea | 70 | <input type="hidden" name="cmd" value="add"> |
b6dd1aaf | 71 | <table class="blanks"> |
10e55875 CE |
72 | <tr> <td>Title:</td> <td><input name="title" required="required"></td> </tr> |
73 | <tr> <td>URL:</td> <td><input name="url" value="http://" type="url" required="required"></td> </tr> | |
74 | <tr> <td>Description:</td> <td><input name="descr" required="required"></td> </tr> | |
88a858ea AC |
75 | <tr> <td><input type="submit" value="Add"></td> </t> |
76 | </table> | |
77 | </form> | |
78 | ||
b6392a52 CE |
79 | <table> |
80 | <% foreach (name, link) in Link.listLinks () do %> | |
81 | <tr> <td><a href="<% Web.html (#url link) %>"><% Web.html (#title link) %></a></td> | |
82 | <td><% Web.html (#descr link) %></td> | |
83 | <td>(<a href="user?id=<% #usr link %>"><% name %></a>)</td> | |
84 | <% if (iff admin then true else you = #usr link) then %> | |
85 | <td><a href="link?mod=<% #id link %>">[Modify]</a> <a href="link?del=<% #id link %>">[Delete]</a></td> | |
86 | <% end %> | |
87 | </tr> | |
88 | <% end %> | |
89 | </table> | |
90 | ||
88a858ea AC |
91 | <% end %> |
92 | ||
93 | <% @footer[] %> |