You are here

function panels_uid_context in Panels 6.2

Same name and namespace in other branches
  1. 5.2 arguments/uid.inc \panels_uid_context()

Discover if this argument gives us the user we crave.

1 string reference to 'panels_uid_context'
panels_uid_panels_arguments in arguments/uid.inc
@file arguments/uid.inc

File

arguments/uid.inc, line 29
arguments/uid.inc

Code

function panels_uid_context($arg = NULL, $conf = NULL, $empty = FALSE) {

  // If unset it wants a generic, unfilled context.
  if ($empty) {
    return panels_context_create_empty('user');
  }

  // FIXME: The code designed to handle a numeric id for loading is probably
  // pretty much cruft by now, and SHOULD be removed pending some more thorough
  // testing & thinking.
  if (!is_numeric($arg)) {
    if (is_object($arg) && !empty($arg->uid)) {
      return panels_context_create('user', $arg);
    }
    else {
      return PANELS_ARG_IS_BAD;
    }
  }

  // FIXME: Pertaining to the above note; we should never make it this far
  // anymore in D6.
  $user = user_load(array(
    'uid' => $arg,
  ));
  if (!$user) {
    return PANELS_ARG_IS_BAD;
  }
  return panels_context_create('user', $user);
}