count_type = $this->definition['count_type']; if ($this->count_type == 'node') { $this->additional_fields['nid'] = 'nid'; } elseif ($this->count_type == 'users') { $this->additional_fields['uid'] = 'uid'; } } function option_definition() { $options = parent::option_definition(); $options['label'] = array('default' => '# of Submissions', 'translatable' => TRUE); return $options; } function query() { $this->ensure_my_table(); $this->add_additional_fields(); } function render($values) { global $user; $output = NULL; if ($this->count_type == 'node' && in_array($node->type, webform_variable_get('webform_node_types'))) { module_load_include('inc', 'webform', 'includes/webform.submissions'); $node = node_load($values->{$this->aliases['nid']}); if (webform_results_access($node, $user)) { $count = webform_get_submission_count($node->nid); $output = l($count, "node/$node->nid/webform-results"); } else { $count = webform_get_submission_count($node->nid, $user->uid); $output = l($count, "node/$node->nid/submissions"); } } elseif ($this->count_type == 'users') { $sql = "SELECT COUNT(sid) FROM {webform_submissions} WHERE uid = %d"; $output = db_result(db_query($sql, $values->{$this->aliases['uid']})); } return $output; } }