99import org .labkey .api .module .Module ;
1010import org .labkey .api .query .FieldKey ;
1111import org .labkey .api .security .User ;
12+ import org .labkey .api .security .permissions .ReadPermission ;
13+ import org .labkey .api .view .UnauthorizedException ;
14+ import org .labkey .mcc .MccManager ;
1215
1316import java .util .Date ;
1417import java .util .HashMap ;
@@ -68,9 +71,15 @@ public String getMessageBodyHTML(Container c, User u)
6871 StringBuilder msg = new StringBuilder ();
6972 Date now = new Date ();
7073
71- doParentSexCheck (c , u , msg );
72- doU24AssignedCheck (c , u , msg );
73- doMissingIdCheck (c , u , msg );
74+ Container mccData = MccManager .get ().getMCCContainer (c );
75+ if (!mccData .hasPermission (u , ReadPermission .class ))
76+ {
77+ throw new UnauthorizedException ("User does not have read permission on folder: " + mccData .getPath ());
78+ }
79+
80+ doParentSexCheck (mccData , u , msg );
81+ doU24AssignedCheck (mccData , u , msg );
82+ doMissingIdCheck (mccData , u , msg );
7483
7584 //since we dont want to trigger an email if there's no alerts, conditionally append the title
7685 if (msg .length () > 0 )
@@ -83,7 +92,7 @@ public String getMessageBodyHTML(Container c, User u)
8392
8493 protected void doMissingIdCheck (final Container c , User u , final StringBuilder msg )
8594 {
86- TableInfo ti = getStudySchema (c , u ).getTable ("aggregatedDemographics" );
95+ TableInfo ti = getUserSchemaByName (c , u , "mcc" ).getTable ("aggregatedDemographics" );
8796
8897 SimpleFilter filter = new SimpleFilter (FieldKey .fromString ("Id" ), null , CompareType .ISBLANK );
8998 TableSelector ts = new TableSelector (ti , filter , null );
0 commit comments