-Member data
- - Summarize these with publicly accessible static pages
-
Specific requests
- Join, with display of pending applications for all members to read
-
-Manage mailing list subscriptions
\ No newline at end of file
--- /dev/null
+portalsub
\ No newline at end of file
--- /dev/null
+portalsub:
+ mlton portalsub.sml
\ No newline at end of file
--- /dev/null
+fun isMember (list, addr) =
+ let
+ val proc = Unix.execute ("/usr/sbin/find_member", ["-l", list, addr])
+ in
+ (case TextIO.inputLine (Unix.textInstreamOf proc) of
+ NONE => false
+ | _ => true)
+ before ignore (Unix.reap proc)
+ end
+
+fun isIdent ch = Char.isLower ch orelse Char.isDigit ch
+
+fun validHost s =
+ size s > 0 andalso size s < 20 andalso List.all isIdent (String.explode s)
+
+fun validDomain s =
+ size s > 0 andalso size s < 100 andalso List.all validHost (String.fields (fn ch => ch = #".") s)
+
+fun validEmailUser s =
+ size s > 0 andalso size s < 50 andalso List.all
+ (fn ch => Char.isAlphaNum ch orelse ch = #"." orelse ch = #"_" orelse ch = #"-" orelse ch = #"+")
+ (String.explode s)
+
+fun validEmail s =
+ (case String.fields (fn ch => ch = #"@") s of
+ [user, host] => validEmailUser user andalso validDomain host
+ | _ => false)
+
+fun main () =
+ case CommandLine.arguments () of
+ [list, cmd, addr] =>
+ if list <> "hcoop-discuss" andalso list <> "hcoop-misc" then
+ (print "Bad mailing list name\n";
+ OS.Process.failure)
+ else if not (validEmail addr) then
+ (print "Invalid e-mail address\n";
+ OS.Process.failure)
+ else (case cmd of
+ "check" =>
+ if isMember (list, addr) then
+ OS.Process.success
+ else
+ OS.Process.failure
+ | "add" =>
+ if isMember (list, addr) then
+ OS.Process.success
+ else
+ OS.Process.system (String.concat ["echo ", addr, " | /usr/sbin/add_members -r - ", list])
+ | "rm" =>
+ if isMember (list, addr) then
+ OS.Process.system (String.concat ["/usr/sbin/remove_members ", list, " ", addr])
+ else
+ OS.Process.success
+ | _ => (print ("Invalid command " ^ cmd ^ "\n");
+ OS.Process.failure))
+ | _ => (print "Bad command-line arguments\n";
+ OS.Process.failure)
+
+val _ = OS.Process.exit (main ())
\ No newline at end of file
<% val you = Init.getUserId ();
+val yourname = Init.getUserName ();
+val youremail = yourname ^ "@hcoop.net";
@header [("title", ["Member preferences"])];
Pref.setDirectory you
else
Pref.unsetDirectory you
- end
+ end;
+
+ if not (iff $"discuss" = "on" then
+ Pref.subscribe ("hcoop-discuss", youremail)
+ else
+ Pref.unsubscribe ("hcoop-discuss", youremail)) then
+ %><h3><b>Error setting <tt>hcoop-discuss</tt> status</b></h3><%
+ end;
+
+ if not (iff $"misc" = "on" then
+ Pref.subscribe ("hcoop-misc", youremail)
+ else
+ Pref.unsubscribe ("hcoop-misc", youremail)) then
+ %><h3><b>Error setting <tt>hcoop-misc</tt> status</b></h3><%
+ end;
%><h3><b>Preferences updated</b></h3><%
end %>
<form action="pref">
<input type="hidden" name="cmd" value="mod">
<table>
-<tr> <td align="right"><input type="checkbox" name="dir"<% if Pref.hasDirectory you then %> checked<% end %>></td> <td>Include me in the public member directory</td> </tr>
+<tr> <td align="right"><input type="checkbox" name="dir"<% if Pref.hasDirectory you then %> checked<% end %>></td> <td>Include me in the public member directory.</td> </tr>
+<tr> <td align="right"><input type="checkbox" name="discuss"<% if Pref.subscribed ("hcoop-discuss", youremail) then %> checked<% end %>></td> <td>Include me on the <tt>hcoop-discuss</tt> mailing list. <i>(On-topic discussion and sporadically high volume)</i></td> </tr>
+<tr> <td align="right"><input type="checkbox" name="misc"<% if Pref.subscribed ("hcoop-misc", youremail) then %> checked<% end %>></td> <td>Include me on the <tt>hcoop-misc</tt> mailing list. <i>(Off-topic)</i></td> </tr>
<tr> <td><input type="submit" value="Save"></td> </tr>
</table>
val hasDirectory : int -> bool
val setDirectory : int -> unit
val unsetDirectory : int -> unit
+
+ val subscribed : string * string -> bool
+ val subscribe : string * string -> bool
+ val unsubscribe : string * string -> bool
end
\ No newline at end of file
fun unsetDirectory usr =
ignore (C.dml (getDb ()) ($`DELETE FROM DirectoryPref WHERE usr = ^(C.intToSql usr)`))
+fun subscribed (list, address) = OS.Process.isSuccess (OS.Process.system (String.concat
+ ["/usr/bin/sudo /usr/local/bin/portalsub ",
+ list,
+ " check ",
+ address]))
+
+fun subscribe (list, address) = OS.Process.isSuccess (OS.Process.system (String.concat
+ ["/usr/bin/sudo /usr/local/bin/portalsub ",
+ list,
+ " add ",
+ address]))
+
+fun unsubscribe (list, address) = OS.Process.isSuccess (OS.Process.system (String.concat
+ ["/usr/bin/sudo /usr/local/bin/portalsub ",
+ list,
+ " rm ",
+ address]))
+
end
\ No newline at end of file