You are here

function hosting_client_access in Hosting 5

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

File

client/hosting_client.module, line 40

Code

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

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