Go to the documentation of this file.00001 <?php
00002
00013 class views_plugin_row_user_view extends views_plugin_row {
00014 var $base_table = 'users';
00015 var $base_field = 'uid';
00016
00017
00018 var $users = array();
00019
00020 function option_definition() {
00021 $options = parent::option_definition();
00022 $options['view_mode'] = array('default' => 'full');
00023
00024 return $options;
00025 }
00026
00027 function options_form(&$form, &$form_state) {
00028 parent::options_form($form, $form_state);
00029
00030 $options = $this->options_form_summary_options();
00031 $form['view_mode'] = array(
00032 '#type' => 'select',
00033 '#options' => $options,
00034 '#title' => t('View mode'),
00035 '#default_value' => $this->options['view_mode'],
00036 );
00037 $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')));
00038 }
00039
00040
00044 function options_form_summary_options() {
00045 $entity_info = entity_get_info('user');
00046 $options = array();
00047 if (!empty($entity_info['view modes'])) {
00048 foreach ($entity_info['view modes'] as $mode => $settings) {
00049 $options[$mode] = $settings['label'];
00050 }
00051 }
00052 if (empty($options)) {
00053 $options = array(
00054 'full' => t('User account')
00055 );
00056 }
00057
00058 return $options;
00059 }
00060
00061 function summary_title() {
00062 $options = $this->options_form_summary_options();
00063 return check_plain($options[$this->options['view_mode']]);
00064 }
00065
00066 function pre_render($values) {
00067 $uids = array();
00068 foreach ($values as $row) {
00069 $uids[] = $row->{$this->field_alias};
00070 }
00071 $this->users = user_load_multiple($uids);
00072 }
00073
00074 function render($row) {
00075 $account = $this->users[$row->{$this->field_alias}];
00076 $account->view = $this->view;
00077 $build = user_view($account, $this->options['view_mode']);
00078
00079 return drupal_render($build);
00080 }
00081 }