You are here

function views_pdf_rules_action_save in Views PDF 8

Same name and namespace in other branches
  1. 6 views_pdf.rules.inc \views_pdf_rules_action_save()
  2. 7.3 views_pdf.rules.inc \views_pdf_rules_action_save()
  3. 7 views_pdf.rules.inc \views_pdf_rules_action_save()
  4. 7.2 views_pdf.rules.inc \views_pdf_rules_action_save()

Implements hook_rules_action_save().

File

./views_pdf.rules.inc, line 65
Rules integration of the mimemail and the PDF Views module.

Code

function views_pdf_rules_action_save($views_pdf, $arguments, $path) {
  $splits = explode(':', $views_pdf);
  $view_id = $splits[0];
  $display_id = $splits[1];
  if (!empty($view_id)) {
    $view = views_get_view($view_id);
    $view
      ->set_arguments(explode("\n", $arguments));

    // Try to get pdf display.
    if (!$view
      ->set_display($display_id)) {

      // Try the display type.
      if (!$view
        ->set_display('pdf_1')) {

        // There is definitly no pdf display.
        return;
      }
    }
    $view
      ->pre_execute();
    foreach ($view->display as $id => $display) {
      if ($display->display_plugin == 'pdf' && isset($display->handler)) {
        $display->handler
          ->execute($path, 'F');
      }
    }
  }
}