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

Definition of views_handler_field_user_mail.

File

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