@@ -796,21 +796,29 @@ public function countMyGroups($where =[]) {
796
796
return $ data === false ? 0 : $ data ->Count ;
797
797
}
798
798
799
- public function checkPermission ($ userID ,$ groupID ,$ permissions = null , $ fullMatch = false ){
800
- if (is_array ($ permissions )) {
801
- return $ this ->isMemberOfGroup ($ userID ,$ groupID ) && GDN ::session ()->checkPermission (
802
- $ permissions ,$ fullMatch );
803
- } else if (is_string ($ permissions )) {
804
- return $ this ->isMemberOfGroup ($ userID ,$ groupID ) && GDN ::session ()->checkPermission (
805
- [$ permissions ],$ fullMatch );
806
- }
807
-
808
- return $ this ->isMemberOfGroup ($ userID ,$ groupID ) || GDN ::session ()->checkPermission ([
809
- GroupsPlugin::GROUPS_GROUP_ADD_PERMISSION ,
810
- GroupsPlugin::GROUPS_CATEGORY_MANAGE_PERMISSION ,
811
- GroupsPlugin::GROUPS_MODERATION_MANAGE_PERMISSION ,
812
- GroupsPlugin::GROUPS_EMAIL_INVITATIONS_PERMISSION
813
- ],$ fullMatch );
799
+ public function checkPermission ($ userID ,$ groupID ,$ categoryID = null , $ permissionCategoryID = null , $ permissions = null , $ fullMatch = true ){
800
+ // Check access to a category
801
+ $ result = false ;
802
+ if ($ this ->isMemberOfGroup ($ userID ,$ groupID )) {
803
+ if ($ permissions == null ) {
804
+ $ result = true ;
805
+ } else {
806
+ $ result = Gdn::session ()->checkPermission ($ permissions , $ fullMatch , 'Category ' , $ permissionCategoryID )
807
+ || Gdn::session ()->checkPermission ($ permissions , $ fullMatch , 'Category ' , $ categoryID );
808
+ }
809
+ } else {
810
+ // User is not a group member, checking admin group permissions
811
+ if ( GDN ::session ()->checkPermission ([
812
+ GroupsPlugin::GROUPS_GROUP_ADD_PERMISSION ,
813
+ GroupsPlugin::GROUPS_CATEGORY_MANAGE_PERMISSION ,
814
+ GroupsPlugin::GROUPS_MODERATION_MANAGE_PERMISSION ,
815
+ GroupsPlugin::GROUPS_EMAIL_INVITATIONS_PERMISSION
816
+ ], false )) {
817
+ $ result = Gdn::session ()->checkPermission ($ permissions , $ fullMatch , 'Category ' , $ permissionCategoryID )
818
+ || Gdn::session ()->checkPermission ($ permissions , $ fullMatch , 'Category ' , $ categoryID );;
819
+ }
820
+ }
821
+ return $ result ;
814
822
}
815
823
816
824
/**
0 commit comments