Reports for figuring out which accounts to freeze or boot; most of new SSL request...
[bpt/portal.git] / domain.mlt
1 <% @header [("title", ["Domain set-up requests"])];
2
3 val admin = Group.inGroupName "server";
4
5 if $"req" <> "" then
6 val dom = $"req";
7 if not (Util.validDomain dom) then
8 %><h3>Invalid domain name</h3><%
9 elseif String.isPrefix "www." dom and $"want_www" = "" then
10 val base = String.extract (dom, 4, NONE)
11 %><h3>Are you sure you want to request a domain that begins with "www."?</h3>
12 <p>You probably meant to request <tt><% base %></tt> instead, which would grant you the ability to configure <tt><% dom %></tt> as well. Unless you've registered <tt><% dom %></tt> directly with your registrar, you will be unable to configure it without the right to set nameservers for <tt><% base %></tt>.</p>
13 <p><a href="?req=<% Web.urlEncode dom %>&want_www=1&msg=<% Web.urlEncode ($"msg") %>">Yes, go ahead and place the request!</a></p><%
14 else
15 val id = Domain.add (Init.getUserId(), dom, $"msg");
16 if not (Domain.notifyNew id) then
17 %><h3>Error sending e-mail notification</h3><%
18 end
19 %><h3>Request added</h3><%
20 end
21
22 elseif $"cmd" = "open" then
23 %><h3>Open requests</h3>
24 <a href="domain?cmd=list">List all requests</a><%
25
26 foreach (name, req) in Domain.listOpen () do %>
27 <br><hr><br>
28 <table class="blanks">
29 <tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
30 <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
31 <tr> <td>Domain:</td> <td><a href="<% Util.whoisUrl (#data req) %>"><% #data req %></a></td> </tr>
32 <tr> <td>Reason:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr>
33 </table>
34
35 <% if admin then %>
36 <br>
37 <a href="domain?mod=<% #id req %>">[Modify]</a>
38 <a href="domain?del=<% #id req %>">[Delete]</a><br>
39 To set up, run: <tt>domtool-admin grant <% name %> domain <% #data req %></tt>
40 <% end %>
41
42 <% end
43
44 elseif $"cmd" = "list" then
45 %><h3>All requests</h3><%
46
47 foreach (name, req) in Domain.list () do %>
48 <br><hr><br>
49 <table class="blanks">
50 <tr> <td>By:</td> <td colspan="2"><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
51 <tr> <td>Time:</td> <td colspan="2"><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
52 <tr> <td>Domain:</td> <td><a href="<% Util.whoisUrl (#data req) %>"><% #data req %></a></td> </tr>
53 <tr> <td>Reason:</td> <td colspan="2"><% Web.html (#msg req) %></td> </tr>
54 </table>
55
56 <% if admin then %>
57 <br>
58 <a href="domain?mod=<% #id req %>">[Modify]</a>
59 <a href="domain?del=<% #id req %>">[Delete]</a>
60 <% end %>
61
62 <% end
63
64 elseif $"mod" <> "" then
65 Group.requireGroupName "server";
66 val id = Web.stoi ($"mod");
67 val req = Domain.lookup id;
68 val user = Init.lookupUser (#usr req) %>
69 <h3>Handle request</h3>
70
71 <form action="domain" method="post">
72 <input type="hidden" name="save" value="<% id %>">
73 <table class="blanks">
74 <tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
75 <tr> <td>Time:</td> <td><% #stamp req %> (<% Util.diffFromNow (#stamp req) %> ago)</td> </tr>
76 <tr> <td>Status</b>:</td> <td><select name="status">
77 <option value="0"<% if #status req = Domain.NEW then %> selected<% end %>>New</option>
78 <option value="1"<% if #status req = Domain.INSTALLED then %> selected<% end %>>Installed</option>
79 <option value="2"<% if #status req = Domain.REJECTED then %> selected<% end %>>Rejected</option>
80 </select></td> </tr>
81 <tr> <td>Domain:</td> <td><input name="dom" value="<% #data req %>"></td> </tr>
82 <tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr>
83 <tr> <td><input type="submit" value="Save"></td> </tr>
84 </table>
85 </form>
86
87 <% elseif $"save" <> "" then
88 Group.requireGroupName "server";
89 val id = Web.stoi ($"save");
90 val req = Domain.lookup id;
91 val oldStatus = #status req;
92 val newStatus = Domain.statusFromInt (Web.stoi ($"status"));
93 Domain.modify {req with data = $"dom", msg = $"msg", status = newStatus};
94 if oldStatus <> newStatus then
95 if not (Domain.notifyMod (oldStatus, newStatus, Init.getUserName(), id)) then
96 %><h3>Error sending e-mail notification</h3><%
97 end
98 end
99 %><h3>Request modified</h3>
100 Back to: <a href="domain?cmd=open">open requests</a>, <a href="domain?cmd=list">all requests</a>
101
102 <% elseif $"del" <> "" then
103 Group.requireGroupName "server";
104 val id = Web.stoi ($"del");
105 val req = Domain.lookup id;
106 val user = Init.lookupUser (#usr req)
107 %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3>
108 <a href="domain?del2=<% id %>">Yes, I'm sure!</a>
109
110 <% elseif $"del2" <> "" then
111 Group.requireGroupName "server";
112 val id = Web.stoi ($"del2");
113 Domain.delete id
114 %><h3>Request deleted</b><h3>
115 Back to: <a href="domain?cmd=open">open requests</a>, <a href="domain?cmd=list">all requests</a>
116
117 <% else %>
118
119 <h3>Request new domain</h3>
120
121 Enter the full Internet domain name that you own and would like set up here. We don't do domain registration, so it is your responsibility to register this name with your registrar of choice before submitting it here. The "Reason" field is optional.
122
123 <form action="domain" method="post">
124 <table class="blanks">
125 <tr> <td>Domain:</td> <td><input name="req"></td> </tr>
126 <tr> <td>Reason:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr>
127 <tr> <td><input type="submit" value="Request"></td> </tr>
128 </table>
129 </form>
130
131 <% end %>
132
133 <% @footer[] %>