_node_access_where_sql

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/node/node.module, строка 2094

Версии
5
_node_access_where_sql($op = 'view', $node_access_alias = 'na', $uid = NULL)
6
_node_access_where_sql($op = 'view', $node_access_alias = 'na', $account = NULL)

Generate an SQL where clause for use in fetching a node listing.

Параметры

$op The operation that must be allowed to return a node.

$node_access_alias If the node_access table has been given an SQL alias other than the default 'na', that must be passed here.

$account The user object for the user performing the operation. If omitted, the current user is used.

Возвращаемое значение

An SQL where clause.

Связанные темы

Код

<?php
function _node_access_where_sql($op = 'view', $node_access_alias = 'na', $account = NULL) {
  if (user_access('administer nodes')) {
    return;
  }

  $grants = array();
  foreach (node_access_grants($op, $account) as $realm => $gids) {
    foreach ($gids as $gid) {
      $grants[] = "($node_access_alias.gid = $gid AND $node_access_alias.realm = '$realm')";
    }
  }

  $grants_sql = '';
  if (count($grants)) {
    $grants_sql = 'AND ('. implode(' OR ', $grants) .')';
  }

  $sql = "$node_access_alias.grant_$op >= 1 $grants_sql";
  return $sql;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему