function pay::access in Pay 6        
                          
                  
                        Same name and namespace in other branches
- 7 includes/handlers/pay.inc \pay::access()
File
 
   - includes/handlers/pay.inc, line 346
- The base class for the Payment API.
Class
  
  - pay 
- @file
The base class for the Payment API.
Code
function access($activity, $account = NULL) {
  if (!$account) {
    global $user;
    $account = $user;
  }
  
  if (!is_array($this->permissions)) {
    return TRUE;
  }
  if (is_array($this->permissions) && ($perm = $this->permissions[$activity])) {
    foreach ($perm as $key => $status) {
      if (!$status) {
        continue;
      }
      
      if ($key == 'owner' && $this->uid) {
        if ($account->uid == $this->uid) {
          return TRUE;
        }
      }
      
      if ($key == 'all') {
        return TRUE;
      }
      
      if (substr($key, 0, 11) == 'permission:') {
        if (user_access(substr($key, 11), $account)) {
          return TRUE;
        }
      }
      
      if (substr($key, 0, 5) == 'role:') {
        if (isset($account->roles[substr($key, 5)])) {
          return TRUE;
        }
      }
    }
  }
  
  return FALSE;
}