| 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") %> |
| 10 | <h3>Link added</h3> |
| 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 |
| 16 | %><h3>You can't modify somebody else's link.</h3><% |
| 17 | else |
| 18 | showNormal := false %> |
| 19 | |
| 20 | <h3>Modify link</h3> |
| 21 | |
| 22 | <form action="link" method="post"> |
| 23 | <input type="hidden" name="save" value="<% id %>"> |
| 24 | <table class="blanks"> |
| 25 | <tr> <td>Title:</td> <td><input name="title" value="<% Web.html (#title link) %>"></td> </tr> |
| 26 | <tr> <td>URL:</td> <td><input name="url" value="<% Web.html (#url link) %>"></td> </tr> |
| 27 | <tr> <td>Description:</td> <td><input name="descr" value="<% Web.html (#descr link) %>"></td> </tr> |
| 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 |
| 37 | %><h3>You can't modify somebody else's link.</h3><% |
| 38 | else |
| 39 | Link.modLink {link with title = $"title", url = $"url", descr = $"descr"} |
| 40 | %><h3>Link modified</h3><% |
| 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 |
| 47 | %><h3>You can't delete somebody else's link.</h3><% |
| 48 | else |
| 49 | showNormal := false %> |
| 50 | <h3>Are you sure you want to delete link to "<% Web.html (#title link) %>"?</h3> |
| 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 |
| 58 | %><h3>You can't delete somebody else's link.</h3><% |
| 59 | else |
| 60 | Link.deleteLink id; |
| 61 | %><h3>Link "<% Web.html (#title link) %>" deleted</h3><% |
| 62 | end |
| 63 | end; |
| 64 | |
| 65 | if showNormal then %> |
| 66 | |
| 67 | <table> |
| 68 | <% foreach (name, link) in Link.listLinks () do %> |
| 69 | <tr> <td><a href="<% Web.html (#url link) %>"><% Web.html (#title link) %></a></td> |
| 70 | <td><% Web.html (#descr link) %></td> |
| 71 | <td>(<a href="user?id=<% #usr link %>"><% name %></a>)</td> |
| 72 | <% if (iff admin then true else you = #usr link) then %> |
| 73 | <td><a href="link?mod=<% #id link %>">[Modify]</a> <a href="link?del=<% #id link %>">[Delete]</a></td> |
| 74 | <% end %> |
| 75 | </tr> |
| 76 | <% end %> |
| 77 | </table> |
| 78 | |
| 79 | <h3>Add a link to a site you host with Hcoop</h3> |
| 80 | |
| 81 | <form action="link" method="post"> |
| 82 | <input type="hidden" name="cmd" value="add"> |
| 83 | <table class="blanks"> |
| 84 | <tr> <td>Title:</td> <td><input name="title"></td> </tr> |
| 85 | <tr> <td>URL:</td> <td><input name="url" value="http://"></td> </tr> |
| 86 | <tr> <td>Description:</td> <td><input name="descr"></td> </tr> |
| 87 | <tr> <td><input type="submit" value="Add"></td> </t> |
| 88 | </table> |
| 89 | </form> |
| 90 | |
| 91 | <% end %> |
| 92 | |
| 93 | <% @footer[] %> |