/[drupal]/contributions/modules/votingapi/votingapi.admin.inc
ViewVC logotype

Diff of /contributions/modules/votingapi/votingapi.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.3.2.1, Wed Jul 1 07:26:12 2009 UTC revision 1.1.2.3.2.2, Mon Jul 20 22:24:45 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: votingapi.admin.inc,v 1.1.2.3 2009/05/26 03:50:00 eaton Exp $  // $Id: votingapi.admin.inc,v 1.1.2.3.2.1 2009/07/01 07:26:12 eaton Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 39  function votingapi_settings_form($form_s Line 39  function votingapi_settings_form($form_s
39   * Developer tool to generate dummy votes.   * Developer tool to generate dummy votes.
40   */   */
41  function votingapi_generate_votes_form() {  function votingapi_generate_votes_form() {
   $types = node_get_types();  
   foreach ($types as $type) {  
     $options[$type->type] = t($type->name);  
   }  
   
42    $form['node_types'] = array(    $form['node_types'] = array(
43      '#type' => 'checkboxes',      '#type' => 'checkboxes',
44      '#title' => t('Which node types should receive votes?'),      '#title' => t('Which node types should receive votes?'),
45      '#options' => $options,      '#options' => node_type_get_names(),
46      '#default_value' => array_keys($options),      '#default_value' => array_keys(node_type_get_names()),
47    );    );
48    
49    $form['vote_type'] = array(    $form['vote_type'] = array(
# Line 88  function votingapi_generate_votes($node_ Line 83  function votingapi_generate_votes($node_
83    module_load_include('inc', 'devel_generate');    module_load_include('inc', 'devel_generate');
84    
85    if ($kill_votes) {    if ($kill_votes) {
86      db_query("TRUNCATE TABLE {votingapi_vote}");      db_truncate('votingapi_vote');
87      db_query("TRUNCATE TABLE {votingapi_cache}");      db_truncate('votingapi_cache');
88    }    }
89    
90    $uids = devel_get_users();    $uids = devel_get_users();
91    $nids = array();  
92      $results = db_select('node', 'n')
93    $sql  = "SELECT n.nid, n.created FROM {node} n ";      ->fields('n', array('nid', 'created'))
94    $sql .= "WHERE n.type IN (" . db_placeholders($node_types, 'varchar') . ") ";      ->condition('n.type', $node_types, 'IN')
95    $sql .= "ORDER BY n.created DESC";      ->execute();
   
   $results = db_query($sql, $node_types);  
   while ($node = db_fetch_array($results)) {  
     $nids[$node['nid']] = $node['created'];  
   }  
96    
97    foreach ($nids as $nid => $timestamp) {    foreach ($results as $node) {
98      _votingapi_cast_votes($nid, $timestamp, $uids, $vote_type);      _votingapi_cast_votes($node->nid, $node->created, $uids, $vote_type);
99    }    }
100  }  }
101    

Legend:
Removed from v.1.1.2.3.2.1  
changed lines
  Added in v.1.1.2.3.2.2

  ViewVC Help
Powered by ViewVC 1.1.2