[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/webform/views/ -> webform_handler_field_submission_count.inc (source)

   1  <?php
   2  // $Id: webform_handler_field_submission_count.inc,v 1.3.2.1 2010/03/03 02:51:31 quicksketch Exp $
   3  
   4  /**
   5  * @file
   6  * Views handler to display the number of submissions in a webform.
   7  */
   8  
   9  /**
  10   * Field handler to present the submission count of a node to the user.
  11   */
  12  class webform_handler_field_submission_count extends views_handler_field {
  13    function construct() {
  14      parent::construct();
  15      $this->count_type = $this->definition['count_type'];
  16  
  17      if ($this->count_type == 'node') {
  18        $this->additional_fields['nid'] = 'nid';
  19      }
  20      elseif ($this->count_type == 'users') {
  21        $this->additional_fields['uid'] = 'uid';
  22      }
  23    }
  24  
  25    function option_definition() {
  26      $options = parent::option_definition();
  27      $options['label'] = array('default' => '# of Submissions', 'translatable' => TRUE);
  28      return $options;
  29    }
  30  
  31    function query() {
  32      $this->ensure_my_table();
  33      $this->add_additional_fields();
  34    }
  35  
  36    function render($values) {
  37      global $user;
  38  
  39      if ($this->count_type == 'node') {
  40        module_load_include('inc', 'webform', 'includes/webform.submissions');
  41        $node = node_load($values->{$this->aliases['nid']});
  42        if (webform_results_access($node, 'access all webform results')) {
  43          $count = webform_get_submission_count($node->nid);
  44          $output = l($count, "node/$node->nid/webform-results");
  45        }
  46        else {
  47          $count = webform_get_submission_count($node->nid, $user->uid);
  48          $output = l($count, "node/$node->nid/submissions");
  49        }
  50      }
  51      elseif ($this->count_type == 'users') {
  52        $sql = "SELECT COUNT(sid) FROM {webform_submissions} WHERE uid = %d";
  53        $output = db_result(db_query($sql, $values->{$this->aliases['uid']}));
  54      }
  55  
  56      return $output;
  57    }
  58  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7