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