You are here

function ad_adaccess in Advertisement 6

Same name and namespace in other branches
  1. 5 ad.module \ad_adaccess()

Determine whether the user has a given privilege.

Parameters

$ad: Node object or aid of advertisement.

$permission: Special Ad owners permission which should be checked (such as 'manage owners')

$account: User object, which are accessing the ad or current user by default.

11 calls to ad_adaccess()
ad_form in ./ad.module
Implementation of hook_form().
ad_html_node_form in html/ad_html.module
Adapi helper function for displaying a node form.
ad_image_adapi in image/ad_image.module
Implementation of hook_adapi().
ad_notify_confirm_delete_validate in notify/ad_notify.module
Validate that the selected notification can be deleted.
ad_notify_overview_form in notify/ad_notify.module
Notification overview form.

... See full list

3 string references to 'ad_adaccess'
ad_menu in ./ad.module
Implementation of hook_menu().
ad_notify_menu in notify/ad_notify.module
Implementation of hook_menu().
ad_owners_menu in owners/ad_owners.module
Implementation of hook_menu().

File

./ad.module, line 1128
An advertising system for Drupal powered websites.

Code

function ad_adaccess($ad, $permission, $account = NULL) {
  global $user;
  static $permissions = array();
  if (!isset($account)) {
    $account = $user;
  }

  // User #1 has all privileges:
  if ($account->uid == 1) {
    return TRUE;
  }

  // If you have administer permissions, you have all permissions.
  if (user_access('administer advertisements', $account)) {
    return TRUE;
  }

  // Handle ad owners access
  if (module_exists('ad_owners')) {
    return ad_owners_adaccess($ad, $permission, $account);
  }
  return FALSE;
}