| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file 5 * Views handler to display the number of submissions in a webform. 6 */ 7 8 /** 9 * Field handler to present the submission count of a node to the user. 10 */ 11 class webform_handler_field_submission_count extends views_handler_field { 12 function construct() { 13 parent::construct(); 14 $this->count_type = $this->definition['count_type']; 15 16 if ($this->count_type == 'node') { 17 $this->additional_fields['nid'] = 'nid'; 18 $this->additional_fields['type'] = 'type'; 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 $output = NULL; 40 if ($this->count_type == 'node' && in_array($values->{$this->aliases['type']}, webform_variable_get('webform_node_types'))) { 41 module_load_include('inc', 'webform', 'includes/webform.submissions'); 42 $node = node_load($values->{$this->aliases['nid']}); 43 if (webform_results_access($node, $user)) { 44 $count = webform_get_submission_count($node->nid); 45 $output = l($count, "node/$node->nid/webform-results"); 46 } 47 else { 48 $count = webform_get_submission_count($node->nid, $user->uid); 49 $output = l($count, "node/$node->nid/submissions"); 50 } 51 } 52 elseif ($this->count_type == 'users') { 53 $sql = "SELECT COUNT(sid) FROM {webform_submissions} WHERE uid = %d"; 54 $output = db_result(db_query($sql, $values->{$this->aliases['uid']})); 55 } 56 57 return $output; 58 } 59 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |