You are here

function fillpdf_token_values in FillPDF 6

File

./webform_tokens.inc, line 4

Code

function fillpdf_token_values($type, $object = NULL, $options = array()) {

  // When making PDFs with fillpdf, this function is called twice, once with $type = 'node' and $object a node object, and once with $type = 'global' and $object = null. During node display, this function is only called once with $type = 'global' */
  //  static $tokens = array();
  //  static $run_once=false;if($run_once)return $tokens;$run_once=true;
  switch ($type) {

    //    case 'global':
    case 'webform':
      $submission = $object;
      $tokens['webform-meta-nid'] = $submission->nid;
      $tokens['webform-meta-sid'] = $submission->sid;
      $tokens['webform-meta-uid'] = $submission->uid;
      $tokens['webform-meta-remote_addr'] = $submission->remote_addr;
      $tokens['webform-meta-submitted'] = $submission->submitted;
      $fields = array();
      $q = db_query('SELECT cid, form_key, type, extra FROM {webform_component} WHERE nid = %d', $submission->nid);
      while ($component = db_fetch_array($q)) {

        // initialize empty fields, so they don't show as [webform-val-text_field] in the pdf
        if (!is_array($submission->data[$component['cid']])) {
          $submission->data[$component['cid']] = array();
        }

        // add cid, form_key, etc along with ['value']
        $submission->data[$component['cid']] += $component;
      }
      $tokens += _fillpdf_get_tokens_from_components($submission);

      // modify the submission
      return $tokens;
  }
}