You are here

public function AuthcacheFlagFlagFragment::check in Authenticated User Page Caching (Authcache) 7.2

Check whether the user has access to the given fragment.

Parameters

object $account: The user account to check.

string $key: The key for the fragment to be checked.

var $subject: The result of the loader function for the given key. If no AuthcacheP13nFragmentLoader is associated with this fragment, subject is equal to key.

array $context: Additional run-time per-request context (key-value pairs).

Return value

bool Return TRUE when the user has access, FALSE otherwise.

Overrides AuthcacheP13nFragmentAccessInterface::check

File

modules/authcache_flag/includes/AuthcacheFlagFlagFragment.inc, line 39
Defines a personalization fragment for retrieving flags. on a node.

Class

AuthcacheFlagFlagFragment
Personalization fragment for retrieving flags.

Code

public function check($account, $entity_id, $flag, $context) {
  if (!$flag
    ->access($entity_id) && (!$flag
    ->is_flagged($entity_id) || !$flag
    ->access($entity_id, 'flag'))) {

    // User has no permission to use this flag.
    return FALSE;
  }
  else {
    return TRUE;
  }
}