commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / views / modules / user / views_plugin_row_user_view.inc
1 <?php
2
3 /**
4 * @file
5 * Contains the user view row plugin.
6 */
7
8 /**
9 * A row plugin which renders a user via user_view.
10 *
11 * @ingroup views_row_plugins
12 */
13 class views_plugin_row_user_view extends views_plugin_row {
14 var $base_table = 'users';
15 var $base_field = 'uid';
16
17 // Store the users to be used for pre_render.
18 var $users = array();
19
20 function option_definition() {
21 $options = parent::option_definition();
22 $options['view_mode'] = array('default' => 'full');
23
24 return $options;
25 }
26
27 function options_form(&$form, &$form_state) {
28 parent::options_form($form, $form_state);
29
30 $options = $this->options_form_summary_options();
31 $form['view_mode'] = array(
32 '#type' => 'select',
33 '#options' => $options,
34 '#title' => t('View mode'),
35 '#default_value' => $this->options['view_mode'],
36 );
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')));
38 }
39
40
41 /**
42 * Return the main options, which are shown in the summary title.
43 */
44 function options_form_summary_options() {
45 $entity_info = entity_get_info('user');
46 $options = array();
47 if (!empty($entity_info['view modes'])) {
48 foreach ($entity_info['view modes'] as $mode => $settings) {
49 $options[$mode] = $settings['label'];
50 }
51 }
52 if (empty($options)) {
53 $options = array(
54 'full' => t('User account')
55 );
56 }
57
58 return $options;
59 }
60
61 function summary_title() {
62 $options = $this->options_form_summary_options();
63 return check_plain($options[$this->options['view_mode']]);
64 }
65
66 function pre_render($values) {
67 $uids = array();
68 foreach ($values as $row) {
69 $uids[] = $row->{$this->field_alias};
70 }
71 $this->users = user_load_multiple($uids);
72 }
73
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']);
78
79 return drupal_render($build);
80 }
81 }