You are here

function _views_send_get_field_value_from_views_row in Views Send 7

Gets the field value from a result row in a view - rendered value (default), plain text or array with mail addresses.

Return value

See description.

3 calls to _views_send_get_field_value_from_views_row()
views_send_config_form_validate in ./views_send.module
Validation callback for the "configure" step.
views_send_confirm_form in ./views_send.module
Multistep form callback for the "confirm" step. Allows the user to preview the whole message before sending it.
views_send_queue_mail in ./views_send.module
Assembles the email and queues it for sending.

File

./views_send.module, line 70
The Views Send module.

Code

function _views_send_get_field_value_from_views_row($view, $row_id, $field_id, $type = '') {
  if (strpos($field_id, 'custom_text') === 0) {

    // Handle the special case for custom text fields.
    $field_id = str_replace('custom_text', 'nothing', $field_id);
  }
  $rendered_field = $view->style_plugin
    ->get_field($row_id, $field_id);
  if ($type == 'plain_text') {

    // Removing HTML tags. Used for names in headers, not body.
    $result = strip_tags($rendered_field);
  }
  elseif ($type == 'mail') {

    // Removing HTML tags and entities. Used for e-mail addresses in headers, not body.
    $result = explode(',', decode_entities(strip_tags($rendered_field)));
    $result = array_map('trim', $result);
  }
  else {
    $result = $rendered_field;
  }
  return $result;
}