You are here

function ad_status_array in Advertisement 6.2

Same name and namespace in other branches
  1. 5.2 ad.module \ad_status_array()
  2. 5 ad.module \ad_status_array()
  3. 6.3 ad.module \ad_status_array()
  4. 6 ad.module \ad_status_array()
  5. 7 ad.module \ad_status_array()

Return an array with all status values user has permission to set. A user with 'administer advertisements' permission can update any status.

2 calls to ad_status_array()
ad_form in ./ad.module
Implementation of hook_form().
theme_ad_status_display in ./ad.module
Display the status of the currently viewed ad.

File

./ad.module, line 346

Code

function ad_status_array($aid = 0, $status = NULL) {
  $permissions = array();

  // mark status as pending
  if (user_access('administer advertisements') || $status == 'pending' || $status == NULL || ad_permission($aid, 'set status as pending')) {
    $permissions['pending'] = t('This advertisement is currently waiting for administrative approval.');
  }

  // mark status from pending to approved
  if (user_access('administer advertisements') || $status == 'approved' || $status == 'pending' && ad_permission($aid, 'set status from pending to approved')) {
    $permissions['approved'] = t('This advertisement has been approved and is currently waiting to be activated.');
  }

  // mark status as active (from pending, approved, or offline)
  if (user_access('administer advertisements') || $status == 'active' || $status == 'approved' && ad_permission($aid, 'set status from approved to active') || $status == 'offline' && ad_permission($aid, 'set status from offline to active')) {
    $permissions['active'] = t('This advertisement is actively being displayed.');
  }

  // mark status as offline (from pending, approved, or active)
  if (user_access('administer advertisements') || $status == 'offline' || $status == 'approved' && ad_permission($aid, 'set status from approved to offline') || $status == 'active' && ad_permission($aid, 'set status from active to offline')) {
    $permissions['offline'] = t('This advertisement has been temporarily disabled by its owner and is not currently being displayed.');
  }

  // mark status as expired (from active or offline)
  if (user_access('administer advertisements') || $status == 'expired' || $status == 'active' && ad_permission($aid, 'set status from active to expired') || $status == 'offline' && ad_permission($aid, 'set status from offline to expired')) {
    $permissions['expired'] = t('This advertisement has expired and is no longer being displayed.');
  }

  // mark status as denied (from pending or any)
  if (user_access('administer advertisements') || $status == 'denied' || $status == 'pending' && ad_permission($aid, 'set status from pending to denied') || ad_permission($aid, 'set status as denied')) {
    $permissions['denied'] = t('This advertisement was refused by the site administrator and will not be displayed.');
  }
  return $permissions;
}