cvsimport
[hcoop/zz_old/portal.git] / ip.mlt
CommitLineData
047812d5 1<% @header [("title", ["IP address requests"])];
2
3val admin = Group.inGroupName "server";
4
5val nodeNum = case $"node" of
6 "" => 2
7 | node => Web.stoi node;
8
9if $"new" <> "" then
10 val port = Web.stoi ($"port");
11 val msg = $"msg";
12
13 %>Are you sure you want to ask for an IP address with port <% port %> free on machine <% Init.nodeName nodeNum %>?<br><br>
14 <a href="ip?node=<% nodeNum %>&req=<% port %>&msg=<% Web.urlEncode msg %>">Yes, I want to request that.</a>
15
16<% elseif $"req" <> "" then
d6e189f0 17 val id = Ip.add {usr = Init.getUserId (), node = nodeNum, data = $"req", msg = $"msg"};
047812d5 18 if not (Ip.notifyNew id) then
19 %><h3>Error sending e-mail notification</h3><%
20 end
21 %><h3>Request added</h3><%
22
23elseif $"cmd" = "open" then
24 %><h3>Open requests</h3>
25 <a href="ip?cmd=list">List all requests</a><%
26
27 foreach (name, req) in Ip.listOpen () do %>
28<br><hr><br>
29<table class="blanks">
30<tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
31<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
32<tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
33<tr> <td>Port:</td> <td><% #data req %></td> </tr>
34<tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
35</table>
36
37<% if admin then %>
38 <br>
39 <a href="ip?mod=<% #id req %>">[Modify]</a>
40 <a href="ip?del=<% #id req %>">[Delete]</a><br>
41 To install, run: <i>tell adamc what text to put here</i>.
42<% end %>
43
44<% end
45
46elseif $"cmd" = "list" then
47 %><h3>All requests</h3><%
48
49 foreach (name, req) in Ip.list () do %>
50<br><hr><br>
51<table class="blanks">
52<tr> <td>By:</td> <td><a href="user?id=<% #usr req %>"><% name %></a></td> </tr>
53<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
54<tr> <td>Node:</td> <td><% Web.html (Init.nodeName (#node req)) %></td> </tr>
55<tr> <td>Port:</td> <td><% #data req %></td> </tr>
56<tr> <td>Reason:</td> <td><% Web.html (#msg req) %></td> </tr>
57</table>
58
59<% if admin then %>
60 <br>
61 <a href="ip?mod=<% #id req %>">[Modify]</a>
62 <a href="ip?del=<% #id req %>">[Delete]</a>
63<% end %>
64
65<% end
66
67elseif $"mod" <> "" then
68 Group.requireGroupName "server";
69 val id = Web.stoi ($"mod");
70 val req = Ip.lookup id;
71 val user = Init.lookupUser (#usr req) %>
72<h3>Handle request</h3>
73
74<form method="post">
75<input type="hidden" name="save" value="<% id %>">
76<table class="blanks">
77<tr> <td>Requestor:</td> <td><a href="user?id=<% #usr req %>"><% #name user %></a></td> </tr>
78<tr> <td>Time:</td> <td><% #stamp req %></td> </tr>
79<tr> <td>Node:</td> <td><select name="node">
80<% foreach node in Init.listNodes () do %>
81 <option value="<% #id node %>"<% if #id node = #node req then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
82<% end %>
83</select>
84<tr> <td>Status:</td> <td><select name="status">
85 <option value="0"<% if #status req = Ip.NEW then %> selected<% end %>>New</option>
86 <option value="1"<% if #status req = Ip.INSTALLED then %> selected<% end %>>Installed</option>
87 <option value="2"<% if #status req = Ip.REJECTED then %> selected<% end %>>Rejected</option>
88</select></td> </tr>
89<tr> <td>Port:</td> <td><input name="port" size="6" value="<% Web.html (#data req) %>"></td> </tr>
90<tr> <td>Message:</td> <td><textarea name="msg" rows="10" cols="80" wrap="soft"><% Web.html (#msg req) %></textarea></td> </tr>
91<tr> <td><input type="submit" value="Save"></td> </tr>
92</table>
93</form>
94
95<% elseif $"save" <> "" then
96 Group.requireGroupName "server";
97 val id = Web.stoi ($"save");
98 val node = Web.stoi ($"node");
99 val req = Ip.lookup id;
100 val oldStatus = #status req;
101 val newStatus = Ip.statusFromInt (Web.stoi ($"status"));
102 Ip.modify {req with node = node, data = $"port", msg = $"msg", status = newStatus};
103 if oldStatus <> newStatus then
104 if not (Ip.notifyMod {old = oldStatus, new = newStatus, changer = Init.getUserName(), req = id}) then
105 %><h3>Error sending e-mail notification</h3><%
106 end
107 end
108 %><h3>Request modified</h3>
109 Back to: <a href="ip?cmd=open">open requests</a>, <a href="ip?cmd=list">all requests</a>
110
111<% elseif $"del" <> "" then
112 Group.requireGroupName "server";
113 val id = Web.stoi ($"del");
114 val req = Ip.lookup id;
115 val user = Init.lookupUser (#usr req)
116 %><h3>Are you sure you want to delete request by <% #name user %> for <tt><% #data req %></tt>?</h3>
117 <a href="ip?del2=<% id %>">Yes, I'm sure!</a>
118
119<% elseif $"del2" <> "" then
120 Group.requireGroupName "server";
121 val id = Web.stoi ($"del2");
122 Ip.delete id
123 %><h3>Request deleted</b><h3>
124 Back to: <a href="ip?cmd=open">open requests</a>, <a href="ip?cmd=list">all requests</a>
125
126<% else %>
127
128<h3>Request an IP address</h3>
129
130<p>Use this form to request use of a particular port. If your request is granted, you will be assigned rights to your port on a particular IP address. The most common use of this form is to ask for an IP address to use with an SSL virtual web host. We will grant requests in very few other cases. Try to use free ports on the base IP address of one of the machines on which we grant member log-in.</p>
131
132<form method="post">
133<input type="hidden" name="new" value="1">
134<table class="blanks">
135<tr> <td>Machine:</td> <td><select name="node">
136<% foreach node in Init.listNodes () do %>
137 <option value="<% #id node %>"<% if #id node = nodeNum then %> selected<% end %>><% Web.html (#name node) %> (<% Web.html (#descr node) %>; Debian <% Web.html (#debian node) %>)</option>
138<% end %>
139</select></td></tr>
140<tr> <td>Port#:</td> <td><input name="port" size="6" value="443"></td> </tr>
141<tr> <td>Reason:</td> <td><textarea name="msg" rows="5" cols="80" wrap="soft"></textarea></td> </tr>
142<tr> <td><input type="submit" value="Request"></td> </tr>
143</table>
144</form>
145
146<% end %>
147
148<% @footer[] %>