From: Adam Chlipala Date: Wed, 4 May 2005 04:00:49 +0000 (+0000) Subject: Adding users from applications X-Git-Url: http://git.hcoop.net/hcoop/portal.git/commitdiff_plain/98a5f121f24a6899a57472005e0d0cdf1559fbd2 Adding users from applications --- diff --git a/app.sig b/app.sig index eb29c68..d4c0a66 100644 --- a/app.sig +++ b/app.sig @@ -14,7 +14,7 @@ sig msg : string } val lookupApp : int -> app - val listPending : unit -> app list + val listApps : status -> app list val votes : int -> (int * string) list val vote : int * int -> unit @@ -22,4 +22,6 @@ sig val deny : int * string -> bool val approve : int * string -> bool + val add : int -> unit + val abortAdd : int -> unit end \ No newline at end of file diff --git a/app.sml b/app.sml index a62c042..5b6a87f 100644 --- a/app.sml +++ b/app.sml @@ -51,10 +51,10 @@ fun lookupApp id = SOME row => mkAppRow row | NONE => raise Fail "Membership application not found" -fun listPending () = +fun listApps status = C.map (getDb ()) mkAppRow ($`SELECT id, name, rname, email, forward, uses, other, passwd, status, applied, confirmed, decided, msg FROM MemberApp - WHERE status = 1 + WHERE status = ^(statusToSql status) ORDER BY applied`) fun mkVoteRow [id, name] = (C.intFromSql id, C.stringFromSql name) @@ -106,4 +106,14 @@ fun approve (app, msg) = OS.Process.isSuccess (Mail.mclose mail) end +fun add app = + ignore (C.dml (getDb ()) ($`UPDATE MemberApp + SET status = 3 + WHERE id = ^(C.intToSql app)`)) + +fun abortAdd app = + ignore (C.dml (getDb ()) ($`UPDATE MemberApp + SET status = 2 + WHERE id = ^(C.intToSql app)`)) + end \ No newline at end of file diff --git a/apps.mlt b/apps.mlt index adec3b6..4fe9a28 100644 --- a/apps.mlt +++ b/apps.mlt @@ -48,12 +48,82 @@ elseif $"approve2" <> "" then else %>

Application approved

<% end +elseif $"cmd" = "approved" then + showNormal := false + + %>

Pending applications

<% + + foreach appl in App.listApps App.ACCEPTED do %> +


+ + + + + + + + + +
Received: <% #applied appl %>
Approved by: <% + ref first = true; + ref found = false; + foreach (id, name) in App.votes (#id appl) do + if first then + first := false + else + %>, <% + end + %><% name %><% + end %>
Username: <% #name appl %>
Real name: <% Web.html (#rname appl) %>
E-mail address: <% #email appl %>
Forward e-mail? <% if #forward appl then %>yes<% else %>no<% end %>
Proposed uses: <% Web.htmlNl (#uses appl) %>
Other information: <% Web.htmlNl (#other appl) %>
+ + <% if root then %> + Add this member.
+ <% end + end +elseif $"add" <> "" then + Group.requireGroupNum 0; + showNormal := false; + val id = Web.stoi ($"add"); + val appl = App.lookupApp id; + App.add id %> + +First, create this UNIX user: +
adduser <% #name appl %> "<% #rname appl %>"<% if #forward appl then %>" <% #email appl %>"<% end %>
+ +
+ + + + + + + + + +
Name:
Real name:
Funded by:
Initial transaction amount:
Initial transaction description:
Subscribe to hcoop-announce
Groups:
+
+ +Abort adding this member + +<% elseif $"abort" <> "" then + App.abortAdd (Web.stoi ($"abort")) + %>

Aborted

<% + end %> <% if showNormal then %>

Pending applications

-<% foreach appl in App.listPending () do %> +<% foreach appl in App.listApps App.PENDING do %>


@@ -81,7 +151,7 @@ end %>
Received: <% #applied appl %>
<% if board then %> - Add this member.
+ Approve this member.
Deny this application. <% end %> <% end diff --git a/init.sig b/init.sig index 8821b99..ea1c8ca 100644 --- a/init.sig +++ b/init.sig @@ -35,4 +35,6 @@ signature INIT = sig val getUser : unit -> user val getUserId : unit -> int val getUserName : unit -> string + + val dateString : unit -> string end \ No newline at end of file diff --git a/init.sml b/init.sml index f62f9bc..12092b4 100644 --- a/init.sml +++ b/init.sml @@ -109,4 +109,9 @@ fun userNameToId name = SOME [id] => SOME (C.intFromSql id) | _ => NONE +fun dateString () = + case C.oneRow (getDb ()) "SELECT CURRENT_DATE" of + [d] => C.stringFromSql d + | r => rowError ("dateString", r) + end \ No newline at end of file diff --git a/mailman/Makefile b/mailman/Makefile index e99f98d..938fef1 100644 --- a/mailman/Makefile +++ b/mailman/Makefile @@ -1,2 +1,2 @@ -portalsub: +portalsub: portalsub.sml mlton portalsub.sml \ No newline at end of file diff --git a/mailman/portalsub.sml b/mailman/portalsub.sml index f781964..562a74b 100644 --- a/mailman/portalsub.sml +++ b/mailman/portalsub.sml @@ -29,7 +29,7 @@ fun validEmail s = fun main () = case CommandLine.arguments () of [list, cmd, addr] => - if list <> "hcoop-discuss" andalso list <> "hcoop-misc" then + if list <> "hcoop-discuss" andalso list <> "hcoop-misc" andalso list <> "hcoop-announce" then (print "Bad mailing list name\n"; OS.Process.failure) else if not (validEmail addr) then @@ -47,7 +47,10 @@ fun main () = else OS.Process.system (String.concat ["echo ", addr, " | /usr/sbin/add_members -r - ", list]) | "rm" => - if isMember (list, addr) then + if list = "hcoop-announce" then + (print "You can't remove anyone from hcoop-announce.\n"; + OS.Process.failure) + else if isMember (list, addr) then OS.Process.system (String.concat ["/usr/sbin/remove_members ", list, " ", addr]) else OS.Process.success diff --git a/support.sml b/support.sml index 701737b..84c0744 100644 --- a/support.sml +++ b/support.sml @@ -261,7 +261,9 @@ fun writeRecipients (mail, iss : issue, cat : category, noName) = FROM WebUser JOIN Membership ON (usr = id AND grp = ^(C.intToSql (#grp cat)))` else $`SELECT name - FROM WebUser JOIN SupSubscription ON (usr = id AND cat = ^(C.intToSql (#id cat)))` + FROM WebUser JOIN SupSubscription ON (usr = id AND cat = ^(C.intToSql (#id cat))) + UNION SELECT name + FROM WebUser JOIN Membership ON (usr = id AND grp = ^(C.intToSql (#grp cat)))` fun doOne [name] = let diff --git a/users.mlt b/users.mlt index 6dc4ce8..000efa5 100644 --- a/users.mlt +++ b/users.mlt @@ -17,7 +17,20 @@ if $"cmd" = "Create" then | s => Web.stoi s); val id = Init.addUser ($"name", $"rname", bal); - Group.addToGroups (id, map Web.stoi (Web.getMultiParam "grp")) %> + Group.addToGroups (id, map Web.stoi (Web.getMultiParam "grp")); + + if $"amount" <> "" then + val amount = Web.stor ($"amount"); + val trn = Money.addTransaction ($"descr", amount, Init.dateString ()); + Money.addCharge {trn = trn, usr = id, amount = amount}; + Money.applyCharges trn + end; + + if $"subscribe" = "on" then + if not (Pref.subscribe ("hcoop-announce", $"name" ^ "@hcoop.net")) then + %>

Error subscribing to hcoop-announce

<% + end + end %>

Member added

<% end end @@ -71,6 +84,9 @@ elseif $"mod" <> "" then <% end %> + Initial transaction amount: + Initial transaction description: + Subscribe to hcoop-announce Groups: