• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

modules/user/views_handler_field_user_link.inc

00001 <?php
00007 class views_handler_field_user_link extends views_handler_field {
00008   function construct() {
00009     parent::construct();
00010     $this->additional_fields['uid'] = 'uid';
00011   }
00012 
00013   function option_definition() {
00014     $options = parent::option_definition();
00015     $options['text'] = array('default' => '', 'translatable' => TRUE);
00016     return $options;
00017   }
00018 
00019   function options_form(&$form, &$form_state) {
00020     $form['text'] = array(
00021       '#type' => 'textfield',
00022       '#title' => t('Text to display'),
00023       '#default_value' => $this->options['text'],
00024     );
00025     parent::options_form($form, $form_state);
00026   }
00027 
00028   // An example of field level access control.
00029   function access() {
00030     return user_access('access user profiles');
00031   }
00032 
00033   function query() {
00034     $this->ensure_my_table();
00035     $this->add_additional_fields();
00036   }
00037 
00038   function render($values) {
00039     $value = $this->get_value($values, 'uid');
00040     return $this->render_link($this->sanitize_value($value), $values);
00041   }
00042 
00043   function render_link($data, $values) {
00044     $text = !empty($this->options['text']) ? $this->options['text'] : t('view');
00045 
00046     $this->options['alter']['make_link'] = TRUE;
00047     $this->options['alter']['path'] = "user/" . $data;
00048 
00049     return $text;
00050   }
00051 
00052 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1