You are here

function facebook_publication_access in Facebook Autopost 7

Determines whether the given user has access to a Facebook publication.

Parameters

string $op: The operation being performed. One of 'view', 'update', 'create', 'delete' or just 'edit' (being the same as 'create' or 'update').

FacebookPublicationEntity $publication: (optional) A Facebook publication to check access for. If nothing is given, access for all publications is determined.

object $account: The user to check for. Leave it to NULL to check for the global user.

Return value

bool Whether access is allowed or not.

See also

hook_facebook_publication_access()

fb_autopost_entity_facebook_publication_access()

2 string references to 'facebook_publication_access'
fb_autopost_entity_entity_info in fb_autopost_entity/fb_autopost_entity.module
Implements hook_entity_info().
fb_autopost_entity_menu in fb_autopost_entity/fb_autopost_entity.module
Implements hook_menu().

File

fb_autopost_entity/fb_autopost_entity.module, line 331
Module implementation file

Code

function facebook_publication_access($op, $publication = NULL, $account = NULL) {
  if (user_access('administer facebook publications', $account)) {
    return TRUE;
  }
  if ($op == 'create' || $op == 'update') {
    $op = 'edit';
  }

  // Allow modules to grant / deny access.
  $access = module_invoke_all('facebook_publication_access', $op, $publication, $account);

  // Only grant access if at least one module granted access and no one denied
  // access.
  if (in_array(FALSE, $access, TRUE)) {
    return FALSE;
  }
  elseif (in_array(TRUE, $access, TRUE)) {
    return TRUE;
  }
  return FALSE;
}