Intranet site has multiple webform-enabled content types. When adding a "Webform has name" condition to a rule only nodes of the "webform" content type are listed.

function webform_rules_get_webforms() {
  $result = db_query("SELECT nid, title FROM {node} WHERE type = :type", array(
    ':type' => 'webform',
  ));

Shouldn't the query in function webform_rules_get_webforms search for all webform-enabled content types?

I have not done much Drupal coding, so I hesitate to submit a patch, but the following db_select code (lifted from "webform_mollom_form_list") which uses the stored variable 'webform_node_types' is working for me.

function webform_rules_get_webforms() {
  $webform_types = webform_variable_get('webform_node_types');
  $result = db_select('node', 'n')
    ->fields('n', array('nid', 'title'))
    ->condition('n.type', $webform_types, 'IN')
    ->execute();

  $options = array();
  foreach ($result as $record) {
    $options["webform-client-form-{$record->nid}"] = $record->title;
  }
  return $options;
}
CommentFileSizeAuthor
#2 webform_issue.png124.58 KBborngunners

Comments

stborchert’s picture

Status: Active » Fixed

Thanks for the hint.
Slightly modified and committed to 6.x-1.x and 7.x-1.x.

borngunners’s picture

StatusFileSize
new124.58 KB

I have an issue with my webform after upgrading to the latest version 6.x. Before upgrading there was no issue with the get function now I am missing the name of the departments. Instead of showing the name of the department, it shows the key value. A developer did the webform and I have no idea what he did and what needed to be changed to correct the issue. Below is the code and I have attached a sample image of the issue that I am having:

<?php
/*
  for now, this is for a specific webform.  Later it might be the basis for a more general script that can be reused
  this code is included by php a snippet embedded in a the Meet the Staff node.
  $nid is hard-coded in the snippet....
  $sid is passed in GET if user wants to see data for a single staff person
  if sid was passed, add and AND clause to the sql
*/
if($_GET['sid']){
        $and_clause=' AND s.sid=%d ';
        $sid=$_GET['sid'];
}
//we're using the tables from the webforms module
$query=    'SELECT s.*, sd.cid, sd.no, sd.data, c.name
                                                FROM {webform_submitted_data} as sd
                                                LEFT JOIN {webform_component} as c on sd.nid = c.nid AND sd.cid=c.cid
                                                LEFT JOIN {webform_submissions} as s on sd.sid = s.sid
                                                WHERE s.nid = %d '.$and_clause.' ORDER BY nid, sid, sd.cid ';

$result = db_query($query, $nid, $sid); //2nd param will be ignored if not referenced in query
if ($row = db_fetch_object($result)) {
  while ($row) {
    $data[$row->sid][]=$row;
    $row = db_fetch_object($result);
  }
}
// data is displayed by display order first, then within that by a token made of lname.fname, so build a 3-level array accordingly
// NEW: data is sorted by by department first, then within that by display order then within that by a token made of lname.fname, so build a 3-level array a$

foreach ($data as $sid_key=>$sid_array){
        foreach ($sid_array as $sid_row){
                        if ($sid_row->name=='Dept'){
                                $dept=$sid_row->data;
                        }
                        if ($sid_row->name=='Display order'){
                                $display_order=$sid_row->data;
                        }
                        if ($sid_row->name=='Lname'){
                                $lname=$sid_row->data;
                        }
                        if ($sid_row->name=='Fname'){
                                $fname=$sid_row->data;
                        }
                        $temp_array[]=$sid_row;
        }
        if(!$display_order){$display_order=9999;}//input display order will be 2-digit int, so set to high if none entered
        $alpha_sort_token=strtolower($lname.$fname);
        $sorted_data[$dept][$display_order][$alpha_sort_token]=$temp_array;
        unset ($temp_array, $display_order, $alpha_sort_token);
}

ksort ($sorted_data);                           //sort top array by key, which is the Dept (str)


foreach($sorted_data as $k1=>$v1){
        print '<div class="meet_staff_list_dept_header">'.$k1.'</div>';
        ksort($v1);                                                             //sort each sub-array by key ($display_order)
        foreach ($v1 as $k2=>$v2){
        ksort($v2);                                 //sort each sub-sub-array by the next key ($alpha_sort_token)
        foreach ($v2 as $k3=>$v3){
            ksort ($v3);
            foreach($v3 as $k4=>$v4){
                $one_staffer['sid']= $v4->sid;
                $one_staffer[$v4->name]= $v4->data;
            }
            print '<div class="meet_staff_list_item">';
            print '  <div class="meet_staff_list_item_header">';
            print "<span class=\"meet_staff_list_name\"><a href=\"?sid=".$one_staffer['sid']."\">".$one_staffer['Fname']." ".$one_staffer['Lname']."</a></sp$
            print '</div>';
            if($sid){
                print '<br><div class="meet_staff_list_item_detail">';
                print '<strong>Joined UHC: </strong>';
                print $one_staffer['Joined UHC']."<br />\n";
                print '<br><strong>Education: </strong><br>';
                print str_replace("\n",'<br>',$one_staffer['Education'])."<br />\n";
                print '<br><strong>Professional Specialty/Interest: </strong><br>';
                print str_replace("\n",'<br>',$one_staffer['Professional Specialty/Interest'])."<br />\n";
                if($one_staffer['What I like']){
                print '<br><strong>What I like about working at UHC: </strong><br>';
                print str_replace("\n",'<br>',$one_staffer['What I like'])."<br />\n";
                }
                print '<br><div class="meet_staff_back_link"><a href="?sid=">&lt; &lt; Back to Full List</a></div>';
                print '  </div>';

            }
            print '</div>';
        }
        }
}

?>
stborchert’s picture

@borngunners: please ask in the Webform issue queue (http://drupal.org/project/issues/webform). This has nothing to do with a) this issue here and b) Webform Rules in general.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.