You are here

function views_attach_user in Views attach 7.2

Same name and namespace in other branches
  1. 6.2 views_attach.module \views_attach_user()
  2. 6 views_attach.module \views_attach_user()

Implementation of hook_user().

File

./views_attach.module, line 55

Code

function views_attach_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'view':
      $views = views_attach_get_user_views($category);
      foreach ($views as $info) {
        $view = views_get_view($info['name']);
        $view
          ->set_display($info['display']);
        if ($view
          ->access($info['display'])) {
          $view->current_account = $account;
          $result = $view
            ->execute_display($info['display']);
          if (!empty($result)) {
            $account->content[$view->name . '_' . $info['display']] = array(
              '#type' => 'user_profile_category',
              '#weight' => $view->display_handler
                ->get_option('weight'),
              '#title' => $view
                ->get_title(),
            );
            $account->content[$view->name . '_' . $info['display']]['content'] = array(
              '#type' => 'markup',
              '#value' => $result,
            );
          }
        }
      }
  }
}