You are here

function webform_content_type_render in Total Control Admin Dashboard 6.2

Run-time rendering of the body of the block.

Parameters

$subtype:

$conf: Configuration as done at admin time.

$args:

$context: Context - in this case we don't have any.

Return value

An object with at least title and content members.

1 string reference to 'webform_content_type_render'
webform.inc in plugins/content_types/webform.inc
nodequeue.inc

File

plugins/content_types/webform.inc, line 64
nodequeue.inc

Code

function webform_content_type_render($subtype, $conf, $args, $context) {
  $items = array();

  //Check for Webform module.
  if (module_exists('webform')) {

    // Get webforms.
    $webform_types = webform_variable_get('webform_node_types');
    $nodes = array();
    if ($webform_types) {
      $placeholders = implode(', ', array_fill(0, count($webform_types), "'%s'"));
      $result = db_query(db_rewrite_sql("SELECT n.*, r.* FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid WHERE n.type IN ({$placeholders})", 'n', 'nid', $webform_types), $webform_types);
      while ($node = db_fetch_object($result)) {
        $nodes[] = $node;
      }
    }
    $options = array(
      'query' => array(
        'destination' => 'admin/dashboard',
      ),
    );
    $header = array(
      array(
        'data' => t('Title'),
        'field' => 'title',
        'sort' => 'asc',
      ),
      array(
        'data' => t('Submissions'),
        'field' => 'size',
      ),
      array(
        'data' => t('Operations'),
      ),
    );
    $rows = array();
    foreach ($nodes as $node) {

      // Count query.
      $query = 'SELECT count(*) FROM {webform_submissions} WHERE nid = %d AND is_draft = 0';
      $count = db_result(db_query($query, array(
        $node->nid,
      )));
      $operations = array(
        l(t('Configure'), "node/{$node->nid}/webform", $options),
        l(t('View results'), "node/{$node->nid}/webform-results/table", $options),
      );
      $rows[] = array(
        array(
          'class' => 'webform-title',
          'data' => l($node->title, 'node/' . $node->nid),
        ),
        array(
          'class' => 'webform-no-subs',
          'data' => $count == 0 ? t('No submissions') : $count,
        ),
        array(
          'class' => 'webform-operation',
          'data' => implode(' | ', $operations),
        ),
      );
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('There are no nodequeues to display.'),
        'colspan' => 3,
      ),
    );
  }
  if (user_access('administer nodequeue')) {
    $link = l(t('Nodequeue administration'), 'admin/content/nodequeue');
  }
  $block = new stdClass();
  $block->module = t('total_control');
  $block->title = t('Administer Webforms');
  $block->content = theme('total_control_admin_table', $header, $rows, $link);
  return $block;
}