You are here

function feeds_access in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 feeds.module \feeds_access()
  2. 6 feeds.module \feeds_access()
  3. 7 feeds.module \feeds_access()

Menu access callback.

Parameters

string $action: The action to be performed. Possible values are:

  • import;
  • clear;
  • unlock.

object|string $param: Node object or FeedsImporter id.

Return value

bool True if access is granted. False otherwise.

Related topics

1 call to feeds_access()
feeds_file_download in ./feeds.module
Implements hook_file_download().
1 string reference to 'feeds_access'
feeds_menu in ./feeds.module
Implements hook_menu().

File

./feeds.module, line 536
Feeds - basic API functions and hook implementations.

Code

function feeds_access($action, $param) {
  if (!in_array($action, array(
    'import',
    'clear',
    'unlock',
  ))) {

    // If $action is not one of the supported actions, we return access denied.
    return FALSE;
  }
  $importer_id = FALSE;
  if (is_string($param)) {
    $importer_id = $param;
  }
  elseif ($param instanceof FeedsImporter) {
    $importer_id = $param->id;
  }
  elseif ($param->type) {
    $importer_id = feeds_get_importer_id($param->type);
  }

  // Check for permissions if feed id is present, otherwise return FALSE.
  if ($importer_id) {
    if (user_access('administer feeds') || user_access("{$action} {$importer_id} feeds")) {
      return TRUE;
    }
  }
  return FALSE;
}