5 * Contains the user view row plugin.
9 * A row plugin which renders a user via user_view.
11 * @ingroup views_row_plugins
13 class views_plugin_row_user_view extends views_plugin_row {
14 var $base_table = 'users';
15 var $base_field = 'uid';
17 // Store the users to be used for pre_render.
20 function option_definition() {
21 $options = parent::option_definition();
22 $options['view_mode'] = array('default' => 'full');
27 function options_form(&$form, &$form_state) {
28 parent::options_form($form, $form_state);
30 $options = $this->options_form_summary_options();
31 $form['view_mode'] = array(
33 '#options' => $options,
34 '#title' => t('View mode'),
35 '#default_value' => $this->options['view_mode'],
37 $form['help']['#markup'] = t("Display the user with standard user view. It might be necessary to add a user-profile.tpl.php in your themes template folder, because the default <a href=\"@user-profile-api-link\">user-profile</a>e template don't show the username per default.", array('@user-profile-api-link' => url('http://api.drupal.org/api/drupal/modules--user--user-profile.tpl.php/7')));
42 * Return the main options, which are shown in the summary title.
44 function options_form_summary_options() {
45 $entity_info = entity_get_info('user');
47 if (!empty($entity_info['view modes'])) {
48 foreach ($entity_info['view modes'] as $mode => $settings) {
49 $options[$mode] = $settings['label'];
52 if (empty($options)) {
54 'full' => t('User account')
61 function summary_title() {
62 $options = $this->options_form_summary_options();
63 return check_plain($options[$this->options['view_mode']]);
66 function pre_render($values) {
68 foreach ($values as $row) {
69 $uids[] = $row->{$this->field_alias};
71 $this->users = user_load_multiple($uids);
74 function render($row) {
75 $account = $this->users[$row->{$this->field_alias}];
76 $account->view = $this->view;
77 $build = user_view($account, $this->options['view_mode']);
79 return drupal_render($build);