cvsimport
[hcoop/zz_old/portal.git] / roll.mlt
CommitLineData
add44c00 1<% @header [("title", ["Roll call!"])];
2
3val you = Init.getUserId ();
4
5ref viewingCall = NONE;
6ref showNormal = true;
7
8if $"cmd" = "respond" then
9 showNormal := false;
10
11 val rol = Web.stoi ($"rol");
12 val code = $"code";
13 val rc = Roll.lookupEntry (rol, you);
14
15 if code = #code rc then
16 Roll.respond (rol, you);
1fe415e0 17 %><h3>Your response has been saved. Thank you!</h3><%
add44c00 18 else
1fe415e0 19 %><h3>Incorrect code!</h3><%
add44c00 20 end
21elseif $"cmd" = "add" then
22 Group.requireGroupNum 0;
23 val title = $"title";
24 val msg = $"msg";
25 if title = "" then
1fe415e0 26 %><h3>Your roll call must have a title.</h3><%
add44c00 27 else
28 val id = Roll.addRollCall (title, msg);
29 viewingCall := SOME id;
1fe415e0 30 %><h3>Roll call added!</h3><%
add44c00 31 end
32
33elseif $"mod" <> "" then
34 Group.requireGroupNum 0;
35 showNormal := false;
36 val rc = Roll.lookupRollCall (Web.stoi ($"mod")) %>
1fe415e0 37<h3>Modify roll call</h3>
add44c00 38
39<form action="roll" method="post">
40<input type="hidden" name="id" value="<% $"mod" %>">
1fe415e0 41<table class="blanks">
42<tr> <td>Title:</td> <td><input name="title" value="<% Web.html (#title rc) %>"></td> </tr>
43<tr> <td>Message:</td> <td><textarea name="msg" wrap="soft" rows="5" cols="80"><% Web.html (#msg rc) %></textarea></td> </tr>
add44c00 44<tr> <td><input type="submit" name="cmd" value="Save"></td> </tr>
45</table>
46</form>
47
48<% elseif $"cmd" = "Save" then
49 Group.requireGroupNum 0;
50 val rc = Roll.lookupRollCall (Web.stoi ($"id"));
51
52 val title = $"title";
53 val msg = $"msg";
54 if title = "" then
1fe415e0 55 %><h3>Your rol call must have a title.</h3><%
add44c00 56 else
57 Roll.modRollCall {rc with title = title, msg = msg};
58 viewingCall := SOME (#id rc);
1fe415e0 59 %><h3>Roll call saved.</h3><%
add44c00 60 end
61
62elseif $"del" <> "" then
63 Group.requireGroupNum 0;
64 showNormal := false;
65 val rc = Roll.lookupRollCall (Web.stoi ($"del")) %>
1fe415e0 66 <h3>Are you sure you want to delete roll call "<a href="roll?view=<% #id rc %>"><% Web.html (#title rc) %></a>"?</h3>
add44c00 67 <a href="roll?del2=<% $"del" %>">Yes, delete <% Web.html (#title rc) %>!</a>
68
69<% elseif $"del2" <> "" then
70 Group.requireGroupNum 0;
71 val rc = Roll.lookupRollCall (Web.stoi ($"del2"));
72 Roll.deleteRollCall (Web.stoi ($"del2")) %>
1fe415e0 73 <h3><% Web.html (#title rc) %> deleted!</h3>
add44c00 74
75<% elseif $"cmd" = "mailall" then
76 Group.requireGroupNum 0;
77 showNormal := false;
78 ref first = true %>
79
80<a href="mailto:<% foreach uname in Roll.activeUsernames () do
81 if first then
82 first := false
83 else
84 %>,<%
85 end
86 uname; Init.emailSuffix
87end %>">Mail everyone!</a>
88
89<% elseif $"view" <> "" then
90 Group.requireGroupNum 0;
91 val id = Web.stoi ($"view");
92 viewingCall := SOME id
93end;
94
95if showNormal then
96 Group.requireGroupNum 0;
97
98 switch viewingCall of
99 NONE => %>
1fe415e0 100<h3>Existing roll calls</h3>
add44c00 101
102<% foreach rc in Roll.listRollCalls () do %>
103<li> <a href="roll?view=<% #id rc %>"><% Web.html (#title rc) %></a> (<% #started rc %>)</li>
104<% end %>
105
1fe415e0 106<h3>New roll call</h3>
add44c00 107
108<form action="roll" method="post">
109<input type="hidden" name="cmd" value="add">
1fe415e0 110<table class="blanks">
111<tr> <td>Title:</td> <td><input name="title"></td> </tr>
112<tr> <td>Message:</td> <td><textarea name="msg" wrap="soft" rows="5" cols="80"></textarea></td> </tr>
add44c00 113<tr> <td><input type="submit" value="Create"></td> </tr>
114</table>
115</form>
116
117<a href="roll?cmd=mailall">Mail everyone! (provides mailto: link)</a>
118
119<% | SOME id =>
120 val rc = Roll.lookupRollCall id %>
1fe415e0 121 <h3>Roll call "<% Web.html (#title rc) %>"</h3>
122 <table border="0" class="blanks">
123 <tr> <td>Started:</td> <td><% #started rc %></td> </tr>
124 <tr> <td>Message:</td> <td><% Web.htmlNl (#msg rc) %></td> </tr>
add44c00 125 </table>
126 [ <a href="roll?mod=<% id %>">Modify</a> | <a href="roll?del=<% id %>">Delete</a> ]<br>
127
128<% val (didnt, did) = Roll.listEntries id %>
129
1fe415e0 130<h2>Didn't respond yet:</h2>
add44c00 131<% foreach (usr, ent) in didnt do %>
132<li> <a href="user?id=<% #id usr %>"><% Web.html (#name usr) %></a></li>
133<% end %>
134
1fe415e0 135<h2>Responded:</h2>
add44c00 136<% foreach (usr, ent) in did do %>
137<li> <a href="user?id=<% #id usr %>"><% Web.html (#name usr) %></a> (<%
138 switch #responded ent of SOME st => st end %>)</li>
139<% end %>
140
141<% end
142end %>
143
144<% @footer[] %>