You are here

function farm_asset_add_access in farmOS 7

Access callback: Checks whether the user has permission to add an asset.

Parameters

object|null $account: The user account.

Return value

bool TRUE if the user has add permission, otherwise FALSE.

1 string reference to 'farm_asset_add_access'
farm_asset_menu in modules/farm/farm_asset/farm_asset.module
Implements hook_menu().

File

modules/farm/farm_asset/farm_asset.module, line 638
Farm asset - A farm asset entity type.

Code

function farm_asset_add_access($account = NULL) {

  // If no user object is supplied, the access check is for the current user.
  if (empty($account)) {
    global $user;
    $account = $user;
  }

  // Check each of the asset types to see if the user has access.
  $types = farm_asset_types();
  foreach ($types as $type) {
    if (farm_asset_access('create', $type->type, $account)) {
      return TRUE;
    }
  }

  // If all else fails, deny access.
  return FALSE;
}