function ctools_context_create_user

It's important to remember that $conf is optional here, because contexts are not always created from the UI.

1 string reference to 'ctools_context_create_user'
user.inc in plugins/contexts/user.inc
Plugin to provide a user context.

File

plugins/contexts/user.inc, line 33

Code

function ctools_context_create_user($empty, $data = NULL, $conf = FALSE) {
    $context = new ctools_context(array(
        'entity:user',
        'entity',
        'user',
    ));
    $context->plugin = 'user';
    if ($empty) {
        return $context;
    }
    if ($conf) {
        if ($data['type'] == 'current') {
            global $user;
            if (user_is_logged_in()) {
                $data = user_load($user->uid);
                $data->logged_in_user = TRUE;
            }
            else {
                $data = drupal_anonymous_user();
            }
        }
        else {
            $data = user_load($data['uid']);
        }
    }
    // Load entity if the data provided is a numeric value. This kind of data is
    // passed by some relationships.
    if (is_numeric($data)) {
        $data = user_load($data);
    }
    if (!empty($data)) {
        $context->data = $data;
        $context->title = isset($data->name) ? $data->name : t('Anonymous');
        $context->argument = $data->uid;
        return $context;
    }
}