You are here

function ad_permission in Advertisement 5.2

Same name and namespace in other branches
  1. 6.3 ad.module \ad_permission()
  2. 6.2 ad.module \ad_permission()
  3. 7 ad.module \ad_permission()
  4. 7.2 ad.module \ad_permission()

Stub for ad_permission module, used to determine whether the user has a given privilege. If the ad_permission module is not enabled, all permissions are granted.

13 calls to ad_permission()
ad_click_history in ./ad.module
Display click history for advertisemet, if user has necessary permission.
ad_form in ./ad.module
Drupal _form hook.
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
Adapi implementation.
ad_notify_confirm_delete_validate in notify/ad_notify.module
Validate that the selected notification can be deleted.

... See full list

1 string reference to 'ad_permission'
ad_operations_callback in ./ad.module
Callback function for admin mass approving ads. TODO: Update activated and expired when appropriate. TODO: Publish/unpublish nodes when appropriate.

File

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

Code

function ad_permission($aid, $string, $account = NULL) {
  global $user;
  $access = FALSE;

  // by default, check permission for current user
  if (is_null($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;
  }

  // invoke ad_permission module to determine users access
  if (module_exists('ad_permission') && function_exists('ad_permission_check')) {
    $access = ad_permission_check($aid, $string, $account);
  }
  else {
    if (in_array($string, array(
      'access statistics',
      'access click history',
    ))) {
      $access = TRUE;
    }
  }

  // with no ad_permission module, all other permissions are denied unless user
  // has 'administer advertisements' permission
  return $access;
}