views_handler_field_user_mail.inc

  1. 3.x modules/user/views_handler_field_user_mail.inc
  2. 2.x modules/user/views_handler_field_user_mail.inc

File

modules/user/views_handler_field_user_mail.inc
View source
  1. <?php
  2. /**
  3. * Field handler to provide acess control for the email field
  4. */
  5. class views_handler_field_user_mail extends views_handler_field_user {
  6. function option_definition() {
  7. $options = parent::option_definition();
  8. $options['link_to_user'] = array('default' => 'mailto');
  9. return $options;
  10. }
  11. function options_form(&$form, &$form_state) {
  12. parent::options_form($form, $form_state);
  13. $form['link_to_user'] = array(
  14. '#title' => t('Link this field'),
  15. '#type' => 'radios',
  16. '#options' => array(
  17. 0 => t('No link'),
  18. 'user' => t('To the user'),
  19. 'mailto' => t("With a mailto:"),
  20. ),
  21. '#default_value' => $this->options['link_to_user'],
  22. );
  23. }
  24. function render($values) {
  25. if ($this->options['link_to_user'] == 'mailto') {
  26. return l($values->{$this->field_alias}, "mailto:" . $values->{$this->field_alias});
  27. }
  28. return $this->render_link(check_plain($values->{$this->field_alias}), $values);
  29. }
  30. }