function views_content_user_from_view_context

Return a new context based on an existing context.

1 string reference to 'views_content_user_from_view_context'
user_from_view.inc in views_content/plugins/relationships/user_from_view.inc
Plugin to provide an relationship handler for user from term.

File

views_content/plugins/relationships/user_from_view.inc, line 26

Code

function views_content_user_from_view_context($context, $conf, $placeholder = FALSE) {
    // If unset it wants a generic, unfilled context, which is just NULL.
    if (empty($context->data) || $placeholder) {
        return ctools_context_create_empty('user', NULL);
    }
    $view = views_content_context_get_view($context);
    // Ensure the view executes, but we don't need its output.
    views_content_context_get_output($context);
    $row = intval($conf['row']) - 1;
    if (isset($view->result[$row])) {
        $uid = $view->result[$row]->{$view->base_field};
        if ($uid) {
            $user = user_load($uid);
            return ctools_context_create('user', $user);
        }
    }
    return ctools_context_create_empty('user', NULL);
}