user_load

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

modules/user/user.module, строка 140

Версии
5 – 6
user_load($array = array())

Загружает объект пользователя.

Параметры

$array Ассоциативный массив аттрибутов пользователя, таких как имя пользователя, email, и т.д. (например array('uid' => 123, 'name' => 'veronika')).

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

Полностью загруженный объект пользователя или FALSE, если пользователь не может быть загружен.

▾ 28 функции вызывают user_load()

comment_form_add_preview in modules/comment/comment.module
Конструктор формы; Формирует и проверяет форму предпросмотра комментария.
comment_validate in modules/comment/comment.module
Проверка данных комментария.
install_configure_form_submit in ./install.php
Form API submit for the site configuration form.
node_preview in modules/node/node.pages.inc
Generate a node preview.
node_submit in modules/node/node.module
Подготавливает ноду к записи и делает возможным вносить изменния другими модулями.
node_validate in modules/node/node.module
Perform validation checks on the given node.
profile_block in modules/profile/profile.module
Реализация hook_block().
profile_browse in modules/profile/profile.pages.inc
Menu callback; display a list of user information.
statistics_user_tracker in modules/statistics/statistics.pages.inc
system_send_email_action in modules/system/system.module
Implementation of a configurable Drupal action. Sends an email.
user_authenticate in modules/user/user.module
Try to log in the user locally.
user_category_load in modules/user/user.module
Return a user object after checking if any profile category in the path exists.
user_delete in modules/user/user.module
Удаляет пользователя.
user_external_load in modules/user/user.module
user_external_login_register in modules/user/user.module
Helper function for authentication modules. Either login in or registers the current user, based on username. Either way, the global $user object is populated based on $name.
user_load_self in modules/user/user.module
user_multiple_role_edit in modules/user/user.module
Callback function for admin mass adding/deleting a user role.
user_pass_reset in modules/user/user.pages.inc
Menu callback; process one time login link and redirects to the user page on success.
user_pass_validate in modules/user/user.pages.inc
user_save in modules/user/user.module
Сохраняет изменения аккаунта пользователя либо добавляет нового пользователя.
user_uid_optional_load in modules/user/user.module
user_user_operations_block in modules/user/user.module
Административная функция для массовой блокировки пользователей.
user_user_operations_unblock in modules/user/user.module
Callback function for admin mass unblocking users.
_comment_form_submit in modules/comment/comment.module
Prepare a comment for submission.
_trigger_normalize_comment_context in modules/trigger/trigger.module
When an action is called in a context that does not match its type, the object that the action expects must be retrieved. For example, when an action that works on nodes is called during the comment hook, the node object is not available since the...
_trigger_normalize_node_context in modules/trigger/trigger.module
When an action is called in a context that does not match its type, the object that the action expects must be retrieved. For example, when an action that works on users is called during the node hook, the user object is not available since the node...
_update_cron_notify in modules/update/update.fetch.inc
Perform any notifications that should be done once cron fetches new data.
_user_edit_submit in modules/user/user.module

Код

<?php
function user_load($array = array()) {
  // Dynamically compose a SQL query:
  $query = array();
  $params = array();

  if (is_numeric($array)) {
    $array = array('uid' => $array);
  }
  elseif (!is_array($array)) {
    return FALSE;
  }

  foreach ($array as $key => $value) {
    if ($key == 'uid' || $key == 'status') {
      $query[] = "$key = %d";
      $params[] = $value;
    }
    else if ($key == 'pass') {
      $query[] = "pass = '%s'";
      $params[] = md5($value);
    }
    else {
      $query[]= "LOWER($key) = LOWER('%s')";
      $params[] = $value;
    }
  }
  $result = db_query('SELECT * FROM {users} u WHERE '. implode(' AND ', $query), $params);

  if ($user = db_fetch_object($result)) {
    $user = drupal_unpack($user);

    $user->roles = array();
    if ($user->uid) {
      $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
    }
    else {
      $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
    }
    $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid);
    while ($role = db_fetch_object($result)) {
      $user->roles[$role->rid] = $role->name;
    }
    user_module_invoke('load', $array, $user);
  }
  else {
    $user = FALSE;
  }

  return $user;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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