function party_hat_party_hat_ctools_access_check in Party 7
Same name and namespace in other branches
- 8.2 modules/party_hat/plugins/access/party_hat.inc \party_hat_party_hat_ctools_access_check()
Check for access.
This plugin returns true if a party has ATLEAST ONE of the specified hats. It does not require the party to have all of them.
1 string reference to 'party_hat_party_hat_ctools_access_check'
- party_hat.inc in modules/
party_hat/ plugins/ access/ party_hat.inc - Plugin to provide access control based upon hat context.
File
- modules/
party_hat/ plugins/ access/ party_hat.inc, line 50 - Plugin to provide access control based upon hat context.
Code
function party_hat_party_hat_ctools_access_check($conf, $context) {
// As far as I know there should always be a context at this point, but this
// is safe.
if (empty($context) || empty($context->data)) {
return FALSE;
}
// Get the hats.
if (!isset($conf['hat_name'])) {
return FALSE;
}
$return = FALSE;
$hats = array_filter($conf['hat_name']);
$party_hats = party_hat_get_hats($context->data);
$intersect = array_intersect($hats, array_keys($party_hats));
// If the party has any hats that are also in the conf array, return true.
if (!empty($intersect)) {
$return = TRUE;
}
return $return;
}