You are here

function hosting_client_access in Hosting 6.2

Same name and namespace in other branches
  1. 5 client/hosting_client.module \hosting_client_access()

Implementation of hook_access().

File

client/hosting_client.module, line 72

Code

function hosting_client_access($op, $node, $account) {
  if (!hosting_feature('client')) {

    // multiple client support has been disabled for this site.
    return FALSE;
  }
  if (user_access('administer clients', $account)) {
    return TRUE;
  }
  else {
    switch ($op) {
      case 'create':
        return user_access('create client', $account);
        break;
      case 'view':
        return user_access('view client', $account) && db_fetch_array(db_query("SELECT user FROM {hosting_client_user} WHERE user=%d and client=%d", $account->uid, $node->nid));
      case 'update':
        if (user_access('edit own client', $account) && $account->uid == $node->uid) {
          return TRUE;
        }
        break;
      case 'delete':
        if (user_access('delete own client', $account) && $account->uid == $node->uid) {
          return TRUE;
        }
        break;
      default:
        break;
    }
  }
}