You are here

function farm_plan_add_access in farmOS 7

Access callback: Checks whether the user has permission to add a plan.

Parameters

object|null $account: The user account.

Return value

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

1 string reference to 'farm_plan_add_access'
farm_plan_menu in modules/farm/farm_plan/farm_plan.module
Implements hook_menu().

File

modules/farm/farm_plan/farm_plan.module, line 499
Farm plan - A farm plan entity type.

Code

function farm_plan_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 plan types to see if the user has access.
  $types = farm_plan_types();
  foreach ($types as $type) {
    if (farm_plan_access('create', $type->type, $account)) {
      return TRUE;
    }
  }

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