payment: note that Stripe has instituted an additional 1% fee for non-US cards
[hcoop/portal.git] / link.mlt
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) %>" 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>
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 <h3>Add a link to a site you host with Hcoop</h3>
68
69 <form action="link" method="post">
70 <input type="hidden" name="cmd" value="add">
71 <table class="blanks">
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>
75 <tr> <td><input type="submit" value="Add"></td> </t>
76 </table>
77 </form>
78
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
91 <% end %>
92
93 <% @footer[] %>