Skip to content

Instantly share code, notes, and snippets.

@joshuaadickerson
Last active December 17, 2015 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuaadickerson/5552134 to your computer and use it in GitHub Desktop.
Save joshuaadickerson/5552134 to your computer and use it in GitHub Desktop.
<?php
/**
* Check if a user can see a board based on the board groups
* A PHP equivalent to {query_see_board}
*
* @param array $board_groups
* @param array $board_deny_groups (optional)
* @return boolean
*/
function canSeeBoard($board_groups, $board_deny_groups = array())
{
global $user_info, $modSettings;
if ($user_info['is_admin'])
return true;
// If the user is a member of any of these groups, send them packin'
if (!empty($modSettings['deny_boards_access']) && !empty($board_deny_groups) && array_intersect($board_deny_groups, $user_info['groups']) != array())
return false;
// If anything matches, they are okay
return array_intersect($board_groups, $user_info['groups']) != array();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment