% @header[("title", ["Hosted sites"])];
val admin = Group.inGroupName "links";
val you = Init.getUserId ();
ref showNormal = true;
if $"cmd" = "add" then
val id = Link.addLink (you, $"title", $"url", $"descr") %>
Link added
<% elseif $"mod" <> "" then
val id = Web.stoi ($"mod");
val link = Link.lookupLink id;
if (iff admin then false else you <> #usr link) then
%>You can't modify somebody else's link.
<%
else
showNormal := false %>
Modify link
<% end
elseif $"save" <> "" then
val id = Web.stoi ($"save");
val link = Link.lookupLink id;
if (iff admin then false else you <> #usr link) then
%>You can't modify somebody else's link.
<%
else
Link.modLink {link with title = $"title", url = $"url", descr = $"descr"}
%>Link modified
<%
end
elseif $"del" <> "" then
val id = Web.stoi ($"del");
val link = Link.lookupLink id;
if (iff admin then false else you <> #usr link) then
%>You can't delete somebody else's link.
<%
else
showNormal := false %>
Are you sure you want to delete link to "<% Web.html (#title link) %>"?
Yes, delete "<% Web.html (#title link) %>"!<%
end
elseif $"del2" <> "" then
val id = Web.stoi ($"del2");
val link = Link.lookupLink id;
if (iff admin then false else you <> #usr link) then
%>You can't delete somebody else's link.
<%
else
Link.deleteLink id;
%>Link "<% Web.html (#title link) %>" deleted
<%
end
end;
if showNormal then %>
Add a link to a site you host with Hcoop
<% end %>
<% @footer[] %>