You are here

function asset_access in Asset 5.2

One-stop asset access control

Related topics

6 calls to asset_access()
asset_add in ./asset.module
Present an asset submission form or a set of links to such forms.
asset_delete in ./asset.module
Delete an asset.
asset_form in ./asset.module
Generate the asset add/edit form array.
asset_menu in ./asset.module
Implementation of hook_menu().
asset_wizard_main in ./asset_wizard.module

... See full list

File

./asset.module, line 242
Main module.

Code

function asset_access($op, $asset = NULL) {
  global $user;

  // Convert the asset to an object if necessary:
  if ($op != 'create') {
    $asset = (object) $asset;
  }
  if (user_access('administer assets')) {
    return TRUE;
  }
  $types = asset_get_types();
  switch ($op) {
    case 'create':
      $type = $types[$asset];
      return user_access('create ' . $type->name . ' assets');
    case 'view':
      return user_access('browse assets');
    case 'update':
    case 'delete':
      $type = $types[$asset->type];
      return user_access('edit ' . $type->name . ' assets');
  }
  return FALSE;
}