| 1 | <% @header [("title", ["Membership applications"])]; |
| 2 | |
| 3 | val you = Init.getUserId (); |
| 4 | val board = Group.inGroupName "board"; |
| 5 | val root = Group.inGroupNum 0; |
| 6 | |
| 7 | ref showNormal = true; |
| 8 | |
| 9 | if $"show" <> "" then |
| 10 | showNormal := false; |
| 11 | val usr = Web.stoi ($"show"); |
| 12 | val user = Init.lookupUser usr; |
| 13 | val appl = App.lookupApp (#app user) %> |
| 14 | |
| 15 | <table class="blanks"> |
| 16 | <tr> <td>Received:</td> <td><% #applied appl %></td> </tr> |
| 17 | <tr> <td>Approved by:</td> <td><% |
| 18 | ref first = true; |
| 19 | ref found = false; |
| 20 | val votes = App.votes (#id appl); |
| 21 | foreach (id, name) in votes do |
| 22 | if first then |
| 23 | first := false |
| 24 | else |
| 25 | %>, <% |
| 26 | end |
| 27 | %><a href="user?id=<% id %>"><% name %></a><% |
| 28 | if id = you then |
| 29 | found := true |
| 30 | %> <a href="apps?unvote=<% #id appl %>">[Unvote]</a><% |
| 31 | end |
| 32 | end %> <% if (iff board then not found else false) then %><a href="apps?vote=<% #id appl %>">[Vote]</a><% end %></td> </tr> |
| 33 | <tr> <td>Username:</td> <td><% #name appl %></td> </tr> |
| 34 | <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr> |
| 35 | <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr> |
| 36 | <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr> |
| 37 | <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr> |
| 38 | </table> |
| 39 | <% elseif $"vote" <> "" then |
| 40 | Group.requireGroupName "board"; |
| 41 | App.vote (you, Web.stoi ($"vote")) |
| 42 | %><h3>Vote registered</h3><% |
| 43 | elseif $"unvote" <> "" then |
| 44 | Group.requireGroupName "board"; |
| 45 | App.unvote (you, Web.stoi ($"unvote")) |
| 46 | %><h3>Unvote registered</h3><% |
| 47 | elseif $"deny" <> "" then |
| 48 | showNormal := false; |
| 49 | val appl = App.lookupApp (Web.stoi ($"deny")) |
| 50 | %><h3>Deny application for <% #name appl %></h3> |
| 51 | <form action="apps" method="post"> |
| 52 | <input type="hidden" name="deny2" value="<% $"deny" %>"> |
| 53 | <b>Reason</b>:<br> |
| 54 | <textarea name="msg" rows="5" cols="80" wrap="soft"></textarea><br> |
| 55 | <input type="submit" value="Submit"> |
| 56 | </form><% |
| 57 | elseif $"deny2" <> "" then |
| 58 | Group.requireGroupName "board"; |
| 59 | if not (App.deny (Web.stoi ($"deny2"), $"msg")) then |
| 60 | %><h3>Error denying application</h3><% |
| 61 | else |
| 62 | %><h3>Application denied</h3><% |
| 63 | end |
| 64 | elseif $"approve" <> "" then |
| 65 | showNormal := false; |
| 66 | val appl = App.lookupApp (Web.stoi ($"approve")) |
| 67 | %><h3>Approve application for <% #name appl %></h3> |
| 68 | <form action="apps" method="post"> |
| 69 | <input type="hidden" name="approve2" value="<% $"approve" %>"> |
| 70 | <b>Message</b> (will be added at the end of <tt>~hcoop/portal/welcome.txt</tt>, so you might want to include some introductory text):<br> |
| 71 | <textarea name="msg" rows="5" cols="80" wrap="soft"></textarea><br> |
| 72 | <input type="submit" value="Submit"> |
| 73 | </form><% |
| 74 | elseif $"approve2" <> "" then |
| 75 | Group.requireGroupName "board"; |
| 76 | if not (App.approve (Web.stoi ($"approve2"), $"msg")) then |
| 77 | %><h3>Error approving application</h3><% |
| 78 | else |
| 79 | %><h3>Application approved</h3><% |
| 80 | end |
| 81 | elseif $"cmd" = "approved" then |
| 82 | showNormal := false |
| 83 | |
| 84 | %><h3>Pending applications</h3><% |
| 85 | |
| 86 | foreach appl in App.listApps App.ACCEPTED do %> |
| 87 | <br><hr><br> |
| 88 | <table class="blanks"> |
| 89 | <tr> <td>Received:</td> <td><% #applied appl %></td> </tr> |
| 90 | <tr> <td>Approved by:</td> <td><% |
| 91 | ref first = true; |
| 92 | ref found = false; |
| 93 | foreach (id, name) in App.votes (#id appl) do |
| 94 | if first then |
| 95 | first := false |
| 96 | else |
| 97 | %>, <% |
| 98 | end |
| 99 | %><a href="user?id=<% id %>"><% name %></a><% |
| 100 | end %> </td> </tr> |
| 101 | <tr> <td>Username:</td> <td><% #name appl %></td> </tr> |
| 102 | <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr> |
| 103 | <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr> |
| 104 | <% switch #paypal appl of |
| 105 | SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr> |
| 106 | <% end; |
| 107 | switch #checkout appl of |
| 108 | SOME s => %><tr> <td>Google Checkout:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr> |
| 109 | <% end %> |
| 110 | <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr> |
| 111 | <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr> |
| 112 | <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr> |
| 113 | </table> |
| 114 | |
| 115 | <% if root then %> |
| 116 | <a href="apps?add=<% #id appl %>">Add this member.</a><br> |
| 117 | <% end |
| 118 | end |
| 119 | elseif $"add" <> "" then |
| 120 | Group.requireGroupNum 0; |
| 121 | showNormal := false; |
| 122 | val id = Web.stoi ($"add"); |
| 123 | val appl = App.lookupApp id; |
| 124 | App.add id %> |
| 125 | |
| 126 | First, run this on deleuze: |
| 127 | <blockquote><tt>new-user <% #name appl %> "<% #rname appl %>"<% if #forward appl then %> "<% #email appl %>"<% end %></tt></blockquote> |
| 128 | |
| 129 | <form action="users" method="post"> |
| 130 | <input type="hidden" name="app" value="<% #id appl %>"> |
| 131 | <table class="blanks"> |
| 132 | <tr> <td>Name:</td> <td><input name="name" value="<% Web.html (#name appl) %>"></td> </tr> |
| 133 | <tr> <td>Real name:</td> <td><input name="rname" value="<% Web.html (#rname appl) %>"></td> </tr> |
| 134 | <tr> <td>Funded by:</td> <td><select name="bal"> |
| 135 | <option value="">A new balance</option> |
| 136 | <% foreach bal in Balance.listBalances () do %> |
| 137 | <option value="<% #id bal %>"><% Web.html (#name bal) %></option> |
| 138 | <% end %> |
| 139 | </select></td></tr> |
| 140 | <tr> <td>Initial transaction amount:</td> <td><input name="amount"></td> </tr> |
| 141 | <tr> <td>Initial transaction description:</td> <td><input name="descr"></td> </tr> |
| 142 | <!--tr> <td><input type="checkbox" name="subscribe" checked></td> <td>Subscribe to hcoop-announce</td> </tr--> |
| 143 | <tr> <td>Groups:</td> <td><select name="grp" size="5" multiple> |
| 144 | <% foreach group in Group.listGroups () do %> |
| 145 | <option value="<% #id group %>"<% if #name group = "paying" then %> selected<% end %>><% Web.html (#name group) %></option> |
| 146 | <% end %> |
| 147 | </select></td></tr> |
| 148 | <tr> <td><input type="submit" name="cmd" value="Create"></td> </tr> |
| 149 | </table> |
| 150 | </form> |
| 151 | |
| 152 | <a href="apps?abort=<% #id appl %>">Abort adding this member</a> |
| 153 | |
| 154 | <% elseif $"abort" <> "" then |
| 155 | App.abortAdd (Web.stoi ($"abort")) |
| 156 | %><h3>Aborted</h3><% |
| 157 | |
| 158 | end %> |
| 159 | |
| 160 | <% if showNormal then %> |
| 161 | <h3>Pending applications</h3> |
| 162 | |
| 163 | <% foreach appl in App.listApps App.PENDING do %> |
| 164 | <br><hr><br> |
| 165 | <table class="blanks"> |
| 166 | <tr> <td>Received:</td> <td><% #applied appl %></td> </tr> |
| 167 | <tr> <td>Approved by:</td> <td><% |
| 168 | ref first = true; |
| 169 | ref found = false; |
| 170 | val votes = App.votes (#id appl); |
| 171 | foreach (id, name) in votes do |
| 172 | if first then |
| 173 | first := false |
| 174 | else |
| 175 | %>, <% |
| 176 | end |
| 177 | %><a href="user?id=<% id %>"><% name %></a><% |
| 178 | if id = you then |
| 179 | found := true |
| 180 | %> <a href="apps?unvote=<% #id appl %>">[Unvote]</a><% |
| 181 | end |
| 182 | end %> <% if (iff board then not found else false) then %><a href="apps?vote=<% #id appl %>">[Vote]</a><% end %></td> </tr> |
| 183 | <tr> <td>Username:</td> <td><% #name appl %></td> </tr> |
| 184 | <tr> <td>Real name:</td> <td><% Web.html (#rname appl) %></td> </tr> |
| 185 | <tr> <td>E-mail address:</td> <td><a href="mailto:<% #email appl %>"><% #email appl %></a></td> </tr> |
| 186 | <% switch #paypal appl of |
| 187 | SOME s => %><tr> <td>PayPal:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr> |
| 188 | <% end; |
| 189 | switch #checkout appl of |
| 190 | SOME s => %><tr> <td>Google Checkout:</td> <td><a href="mailto:<% s %>"><% s %></a></td> </tr> |
| 191 | <% end %> |
| 192 | <tr> <td>Forward e-mail?</td> <td><% if #forward appl then %>yes<% else %>no<% end %></td> </tr> |
| 193 | <tr> <td>Proposed uses:</td> <td><% Web.htmlNl (#uses appl) %></td> </tr> |
| 194 | <tr> <td>Other information:</td> <td><% Web.htmlNl (#other appl) %></td> </tr> |
| 195 | </table> |
| 196 | |
| 197 | <% if board then %> |
| 198 | <% if length votes >= 2 then %><a href="apps?approve=<% #id appl %>">Approve this member.</a><br><% end %> |
| 199 | <a href="apps?deny=<% #id appl %>">Deny this application.</a> |
| 200 | <% end %> |
| 201 | <% end |
| 202 | end %> |
| 203 | |
| 204 | <% @footer[] %> |