Allow board members to view roll call
authorClinton Ebadi <clinton@unknownlamer.org>
Thu, 17 Jan 2013 07:57:28 +0000 (02:57 -0500)
committerClinton Ebadi <clinton@unknownlamer.org>
Thu, 17 Jan 2013 07:57:28 +0000 (02:57 -0500)
group.sig
group.sml
roll.mlt

index 64e315d..101a961 100644 (file)
--- a/group.sig
+++ b/group.sig
@@ -28,4 +28,5 @@ sig
     (* These raise Access if the check fails *)
     val requireGroupNum : int -> unit
     val requireGroupName : string -> unit
+    val requireAnyGroupName : string list -> unit
 end
index 75f412a..afab84f 100644 (file)
--- a/group.sml
+++ b/group.sml
@@ -144,6 +144,12 @@ fun requireGroupName grp =
     else
        raise Access ("You aren't a member of group \"" ^ grp ^ "\"")
 
+fun requireAnyGroupName groups =
+    if List.exists (fn grp => inGroupName grp) groups then
+       ()
+    else
+       raise Access ("You aren't a member of any groups \"" ^ String.concatWith ", " groups ^ "\"")
+
 fun validGroupName name =
     size name <= 10
     andalso CharVector.all Char.isAlphaNum name
index 2d396aa..8945697 100644 (file)
--- a/roll.mlt
+++ b/roll.mlt
@@ -19,7 +19,7 @@ if $"cmd" = "respond" then
                %><h3>Incorrect code!</h3><%
        end
 elseif $"cmd" = "add" then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
        val title = $"title";
        val msg = $"msg";
        if title = "" then
@@ -31,7 +31,7 @@ elseif $"cmd" = "add" then
        end
 
 elseif $"mod" <> "" then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
        showNormal := false;
        val rc = Roll.lookupRollCall (Web.stoi ($"mod")) %>
 <h3>Modify roll call</h3>
@@ -46,7 +46,7 @@ elseif $"mod" <> "" then
 </form>
 
 <% elseif $"cmd" = "Save" then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
        val rc = Roll.lookupRollCall (Web.stoi ($"id"));
 
        val title = $"title";
@@ -60,20 +60,20 @@ elseif $"mod" <> "" then
        end
 
 elseif $"del" <> "" then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
        showNormal := false;
        val rc = Roll.lookupRollCall (Web.stoi ($"del")) %>
        <h3>Are you sure you want to delete roll call "<a href="roll?view=<% #id rc %>"><% Web.html (#title rc) %></a>"?</h3>
        <a href="roll?del2=<% $"del" %>">Yes, delete <% Web.html (#title rc) %>!</a>
 
 <% elseif $"del2" <> "" then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
        val rc = Roll.lookupRollCall (Web.stoi ($"del2"));
        Roll.deleteRollCall (Web.stoi ($"del2")) %>
        <h3><% Web.html (#title rc) %> deleted!</h3>
 
 <% elseif $"cmd" = "mailall" then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
        showNormal := false;
        ref first = true %>
 
@@ -87,13 +87,13 @@ elseif $"del" <> "" then
 end %>">Mail everyone!</a>
 
 <% elseif $"view" <> "" then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
        val id = Web.stoi ($"view");
        viewingCall := SOME id
 end;
 
 if showNormal then
-       Group.requireGroupNum 0;
+       Group.requireAnyGroupName ["root", "board"];
 
        switch viewingCall of
                  NONE => %>