? decisions_code_format_a.patch
Index: decisions.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/decisions/decisions.install,v
retrieving revision 1.30
diff -u -p -r1.30 decisions.install
--- decisions.install	3 Feb 2010 17:42:43 -0000	1.30
+++ decisions.install	4 Feb 2010 16:45:03 -0000
@@ -8,119 +8,124 @@
 
 // $Id: decisions.install,v 1.30 2010/02/03 17:42:43 anarcat Exp $
 
+
 /**
  * Implementation of hook_install().
  */
 function decisions_schema() {
   $schema['decisions'] = array(
     'fields' => array(
-         'nid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10'),
-         'mode' => array('type' => 'varchar', 'length' => '32', 'not null' => TRUE),
-         'quorum_abs' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
-         'quorum_percent' => array('type' => 'float', 'unsigned' => TRUE, 'length' => '32', 'not null' => TRUE, 'default' => '0'),
-         'uselist' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'default' => 0, 'disp-width' => '4'),
-         'active' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'default' => 1, 'disp-width' => '4'),
-         'runtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
-         'maxchoices' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
-         'algorithm' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
-         'showvotes' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'disp-width' => '4'),
-         'startdate' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
-         'randomize' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'default' => 1, 'disp-width' => '4'),
-         ),
+      'nid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10'),
+      'mode' => array('type' => 'varchar', 'length' => '32', 'not null' => TRUE),
+      'quorum_abs' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+      'quorum_percent' => array('type' => 'float', 'unsigned' => TRUE, 'length' => '32', 'not null' => TRUE, 'default' => '0'),
+      'uselist' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'default' => 0, 'disp-width' => '4'),
+      'active' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'default' => 1, 'disp-width' => '4'),
+      'runtime' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'maxchoices' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+      'algorithm' => array('type' => 'varchar', 'length' => '100', 'not null' => FALSE),
+      'showvotes' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'disp-width' => '4'),
+      'startdate' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'disp-width' => '10'),
+      'randomize' => array('type' => 'int', 'size' => 'tiny', 'not null' => FALSE, 'default' => 1, 'disp-width' => '4'),
+    ),
     'primary key' => array('nid'),
   );
 
   $schema['decisions_electoral_list'] = array(
     'fields' => array(
-         'nid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10'),
-         'uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10')),
+      'nid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10'),
+      'uid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10'),
+    ),
     'primary key' => array('nid', 'uid'),
   );
 
   $schema['decisions_choices'] = array(
     'fields' => array(
-         'nid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10'),
-         'label' => array('type' => 'text', 'not null' => TRUE),
-         'vote_offset' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '2')),
+      'nid' => array('type' => 'int', 'not null' => TRUE, 'disp-width' => '10'),
+      'label' => array('type' => 'text', 'not null' => TRUE),
+      'vote_offset' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '2'),
+    ),
     'primary key' => array('nid', 'vote_offset'),
     'indexes' => array(
-         'vote_offset' => array('vote_offset')),
+      'vote_offset' => array('vote_offset'),
+    ),
   );
   return $schema;
 }
+
 function decisions_install() {
   drupal_install_schema('decisions');
 }
 
 function decisions_update_1() {
-  switch ($GLOBALS['db_type']) {         
-  case 'mysql':          
-  case 'mysqli':
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN showvotes TINYINT DEFAULT '1'");
-    break;
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN showvotes TINYINT DEFAULT '1'");
+      break;
   }
   return $items;
 }
 
 function decisions_update_2() {
   switch ($GLOBALS['db_type']) {
-  case 'mysql':
-  case 'mysqli':
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN active TINYINT DEFAULT '1'");
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN runtime INT UNSIGNED DEFAULT '0'");
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN maxchoices INT UNSIGNED");
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN algorithm VARCHAR(255)");
-    $items[] = update_sql('UPDATE {decisions} SET maxchoices=1 WHERE mode="poll" AND maxchoices is null');
-    $items[] = update_sql("UPDATE {decisions} SET algorithm='runoff' WHERE mode='runoff'");
-    $items[] = update_sql("UPDATE {decisions} SET mode='ranking' WHERE mode='runoff'");
-    $items[] = update_sql("ALTER TABLE {decisions_options} CHANGE COLUMN opttext chtext text");
-    $items[] = update_sql("ALTER TABLE {decisions_options} CHANGE COLUMN optorder chorder int(2)");
-    $items[] = update_sql("RENAME TABLE {decisions_options} TO {decisions_choices}");
-    break;
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN active TINYINT DEFAULT '1'");
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN runtime INT UNSIGNED DEFAULT '0'");
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN maxchoices INT UNSIGNED");
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN algorithm VARCHAR(255)");
+      $items[] = update_sql('UPDATE {decisions} SET maxchoices=1 WHERE mode="poll" AND maxchoices is null');
+      $items[] = update_sql("UPDATE {decisions} SET algorithm='runoff' WHERE mode='runoff'");
+      $items[] = update_sql("UPDATE {decisions} SET mode='ranking' WHERE mode='runoff'");
+      $items[] = update_sql("ALTER TABLE {decisions_options} CHANGE COLUMN opttext chtext text");
+      $items[] = update_sql("ALTER TABLE {decisions_options} CHANGE COLUMN optorder chorder int(2)");
+      $items[] = update_sql("RENAME TABLE {decisions_options} TO {decisions_choices}");
+      break;
   }
   return $items;
 }
 
 function decisions_update_3() {
   switch ($GLOBALS['db_type']) {
-  case 'mysql':
-  case 'mysqli':
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN startdate INT unsigned");
-    $items[] = update_sql("ALTER TABLE {decisions_choices} CHANGE COLUMN chtext `label` text NOT NULL");
-    $items[] = update_sql("ALTER TABLE {decisions_choices} CHANGE COLUMN chorder `vote_offset` int(2) default NULL");
-    break;
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN startdate INT unsigned");
+      $items[] = update_sql("ALTER TABLE {decisions_choices} CHANGE COLUMN chtext `label` text NOT NULL");
+      $items[] = update_sql("ALTER TABLE {decisions_choices} CHANGE COLUMN chorder `vote_offset` int(2) default NULL");
+      break;
   }
   return $items;
 }
 
 function decisions_update_4() {
   switch ($GLOBALS['db_type']) {
-  case 'mysql':
-  case 'mysqli':
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN `uselist` tinyint default '0'");
-    break;
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN `uselist` tinyint default '0'");
+      break;
   }
   return $items;
 }
 
 function decisions_update_5() {
   switch ($GLOBALS['db_type']) {
-  case 'mysql':
-  case 'mysqli':
-    $items[] = update_sql("ALTER TABLE {decisions} MODIFY `quorum` int(10) NOT NULL AFTER mode");
-    $items[] = update_sql("ALTER TABLE {decisions} CHANGE COLUMN quorum `quorum_abs` int(10) unsigned NOT NULL default '0'");
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN quorum_percent float unsigned NOT NULL default '0' AFTER quorum_abs");
-    break;
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("ALTER TABLE {decisions} MODIFY `quorum` int(10) NOT NULL AFTER mode");
+      $items[] = update_sql("ALTER TABLE {decisions} CHANGE COLUMN quorum `quorum_abs` int(10) unsigned NOT NULL default '0'");
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN quorum_percent float unsigned NOT NULL default '0' AFTER quorum_abs");
+      break;
   }
   return $items;
 }
 
 function decisions_update_6000() {
   switch ($GLOBALS['db_type']) {
-  case 'mysql':
-  case 'mysqli':
-    $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN `randomize` tinyint default '0'");
-    break;
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("ALTER TABLE {decisions} ADD COLUMN `randomize` tinyint default '0'");
+      break;
   }
   return $items;
 }
@@ -139,3 +144,4 @@ function decisions_uninstall() {
   variable_del('decisions_default_mode');
   variable_del('decisions_default_electoral_list');
 }
+
Index: decisions.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/decisions/decisions.module,v
retrieving revision 1.226
diff -u -p -r1.226 decisions.module
--- decisions.module	3 Feb 2010 02:25:55 -0000	1.226
+++ decisions.module	4 Feb 2010 16:45:05 -0000
@@ -15,12 +15,12 @@
 
 // $Id: decisions.module,v 1.226 2010/02/03 02:25:55 anarcat Exp $
 
+
 define('DECISIONS_DEFAULT_ELECTORAL_LIST', 0);
 // always, aftervote, or afterclose
 define('DECISIONS_DEFAULT_VIEW_RESULTS', 'aftervote');
 define('DECISIONS_RUNTIME_INFINITY', 0);
 
-
 /**
  * hook_init() implementation
  *
@@ -45,6 +45,7 @@ function decisions_access($op, $node, $a
   }
   if ($op == 'update') {
     /* you can update it if you can create it, provided it is your own... */
+
     if (user_access('create decisions', $account) && ($account->uid == $node->uid)) {
       return TRUE;
     }
@@ -61,12 +62,13 @@ function decisions_block($op = 'list', $
   elseif ($op == 'view') {
     if (user_access('view decisions')) {
       switch ($delta) {
-      case 'mostrecent':
-        $block = array('subject' => t('Decisions - Newest'), 'content' => _decisions_block_mostrecent());
-        break;
-      default:
-        $block = array();
-        break;
+        case 'mostrecent':
+          $block = array('subject' => t('Decisions - Newest'), 'content' => _decisions_block_mostrecent());
+          break;
+
+        default:
+          $block = array();
+          break;
       }
     }
   }
@@ -90,8 +92,8 @@ function decisions_cron() {
  */
 function decisions_votingapi_calculate(&$cache, $votes, $content_type, $content_id) {
   if ($content_type == 'decisions') {
-    $node = node_load($content_id);
-    $mode = _decisions_get_mode($node);
+    $node     = node_load($content_id);
+    $mode     = _decisions_get_mode($node);
     $function = "{$mode}_decisions_votingapi_calculate";
     if (function_exists($function)) {
       return call_user_func($function, $node, $cache, $votes, $content_type, $content_id);
@@ -104,8 +106,8 @@ function decisions_votingapi_calculate(&
  */
 function decisions_help($path, $arg) {
   switch ($path) {
-  case 'admin/modules#description':
-    return t('Allow people to reproduce and surpass the kinds of decision-making instances that exist in face-to-face meetings.');
+    case 'admin/modules#description':
+      return t('Allow people to reproduce and surpass the kinds of decision-making instances that exist in face-to-face meetings.');
   }
 }
 
@@ -124,7 +126,7 @@ function decisions_menu() {
     'page arguments' => array('decisions_admin'),
     'access arguments' => array('administer decisions'),
     'type' => MENU_NORMAL_ITEM,
-   );
+  );
 
   $items['node/%node/votes'] = array(
     'title' => 'Votes',
@@ -133,7 +135,7 @@ function decisions_menu() {
     'access callback' => '_decisions_votes_access',
     'access arguments' => array(1, 'inspect all votes'),
     'weight' => 4,
-    'type' => MENU_LOCAL_TASK
+    'type' => MENU_LOCAL_TASK,
   );
   $items['node/%node/results'] = array(
     'title' => 'Results',
@@ -141,8 +143,9 @@ function decisions_menu() {
     'page arguments' => array(1),
     'access callback' => '_decisions_can_view_results',
     'access arguments' => array(1),
-    'weight' => 1, 	 
-    'type' => MENU_LOCAL_TASK);
+    'weight' => 1,
+    'type' => MENU_LOCAL_TASK,
+  );
   $items['node/%node/electoral_list'] = array(
     'title' => 'Electoral list',
     'page callback' => 'decisions_electoral_list_tab',
@@ -150,7 +153,7 @@ function decisions_menu() {
     'access callback' => '_decisions_electoral_list_access',
     'access arguments' => array(1, 'view electoral list'),
     'weight' => 2,
-    'type' => MENU_LOCAL_TASK
+    'type' => MENU_LOCAL_TASK,
   );
   // Allow voters to be removed
   $items['node/%node/remove'] = array(
@@ -194,26 +197,26 @@ function decisions_admin() {
   $enabled = array(0 => t('Disabled'), 1 => t('Enabled'));
 
   $form['main']['decisions_default_electoral_list'] = array(
-                                                            '#type' => 'radios',
-                                                            '#title' => t('Use electoral list by default'),
-                                                            '#description' => t('Use an electoral list by default for new decisions.'),
-                                                            '#default_value' => variable_get('decisions_default_electoral_list', DECISIONS_DEFAULT_ELECTORAL_LIST),
-                                                            '#options' => $enabled,
-                                                            );
+    '#type' => 'radios',
+    '#title' => t('Use electoral list by default'),
+    '#description' => t('Use an electoral list by default for new decisions.'),
+    '#default_value' => variable_get('decisions_default_electoral_list', DECISIONS_DEFAULT_ELECTORAL_LIST),
+    '#options' => $enabled,
+  );
 
   $view_results = array(
-                        'always' => t('Always'),
-                        'aftervote' => t('After user has voted'),
-                        'afterclose' => t('After voting has closed'),
-                        );
+    'always' => t('Always'),
+    'aftervote' => t('After user has voted'),
+    'afterclose' => t('After voting has closed'),
+  );
 
   $form['main']['decisions_view_results'] = array(
-                                                  '#type' => 'radios',
-                                                  '#title' => t('When should results be displayed'),
-                                                  '#description' => t('Determines when users may view the results of the decision.'),
-                                                  '#default_value' => variable_get('decisions_view_results', DECISIONS_DEFAULT_VIEW_RESULTS),
-                                                  '#options' => $view_results,
-                                                  );
+    '#type' => 'radios',
+    '#title' => t('When should results be displayed'),
+    '#description' => t('Determines when users may view the results of the decision.'),
+    '#default_value' => variable_get('decisions_view_results', DECISIONS_DEFAULT_VIEW_RESULTS),
+    '#options' => $view_results,
+  );
 
   return system_settings_form($form);
 }
@@ -221,7 +224,7 @@ function decisions_admin() {
 function decisions_cancel_form($form_state, $nid) {
   $form['node'] = array('#type' => 'hidden', '#value' => $nid);
   $form['submit'] = array('#type' => 'submit', '#value' => t('Cancel your vote'));
-  return $form; 
+  return $form;
 }
 
 function decisions_cancel_form_submit($form, &$form_state) {
@@ -230,8 +233,8 @@ function decisions_cancel_form_submit($f
 
 /*******************/
 /* Theme functions */
-/*******************/
 
+/*******************/
 function decisions_theme($existing, $type, $theme, $path) {
   return array(
     'decisions_view_header' => array('arguments' => array('node' => NULL, 'teaser' => FALSE)),
@@ -240,11 +243,11 @@ function decisions_theme($existing, $typ
     'decisions_status' => array('arguments' => array('message' => NULL)),
     'decisions_morechoices' => array('arguments' => array(), 'decisions_morechoices' => NULL),
     'decisions_view_own_result' => array(),
-    );
+  );
 }
 
 function theme_decisions_view_own_result() {
-  $output = '<div class="decisions-own-result">' . t("Your vote has been recorded.") . '</div>';
+  $output = '<div class="decisions-own-result">'. t("Your vote has been recorded.") .'</div>';
   return $output;
 }
 
@@ -258,12 +261,15 @@ function theme_decisions_view_header($no
   // dates
   $output .= '<div class="decisions-dates">';
   $output .= theme('item_list',
-              array(
-                 t('Current date: @date', array('@date' => format_date(time()))),
-                 t('Opening date: @date', array('@date' => format_date($node->startdate))),
-                 ($node->runtime == DECISIONS_RUNTIME_INFINITY ? 
-                   t('No closing date.') :
-                   t('Closing date: @date', array('@date' => format_date($node->startdate + $node->runtime))))));
+    array(
+      t('Current date: @date', array('@date' => format_date(time()))),
+      t('Opening date: @date', array('@date' => format_date($node->startdate))),
+      ($node->runtime == DECISIONS_RUNTIME_INFINITY ?
+        t('No closing date.') :
+        t('Closing date: @date', array('@date' => format_date($node->startdate + $node->runtime)))
+      ),
+    )
+  );
   $output .= '</div>';
 
   // votes
@@ -271,12 +277,12 @@ function theme_decisions_view_header($no
   $num_voters = _decisions_count_voters($node);
   $output .= '<div class="decisions-votes">';
   $output .= t('@num-voters out of @num-voters-eligible eligible @voters cast their ballot',
-               array(
-                 '@num-voters' => $num_voters,
-                 '@num-voters-eligible' => $num_eligible_voters,
-                 '@voters' => format_plural($num_eligible_voters, 'voter', 'voters')
-               )
-              );
+    array(
+      '@num-voters' => $num_voters,
+      '@num-voters-eligible' => $num_eligible_voters,
+      '@voters' => format_plural($num_eligible_voters, 'voter', 'voters'),
+    )
+  );
   $output .= '</div>';
 
   // quorum
@@ -286,7 +292,7 @@ function theme_decisions_view_header($no
     $output .= t('Quorum: @d', array('@d' => $quorum));
     $output .= '</div>';
   }
-    
+
   $output .= '</div>';
   return $output;
 }
@@ -296,7 +302,7 @@ function theme_decisions_view_header($no
  * themes to make this nicer/different
  */
 function theme_decisions_view_voting($form) {
-  
+
   $render = 'drupal_render';
   if (!function_exists($render)) {
     $render = 'form_render';
@@ -320,10 +326,10 @@ function theme_decisions_view_voting($fo
 function theme_decisions_bar($title, $vote, $total_votes, $max_votes) {
   $output = '<div class="text">'. $title .'</div>';
   $output .= '<div class="bar"><div style="width: '. round(100 * $vote / $max_votes, 0) .'%;" class="foreground"></div></div>';
-  $output .= '<div class="percent">'. round(100 * $vote / $total_votes, 0) .'% ('. format_plural($vote, '1 vote', '@count votes').')</div>';
+  $output .= '<div class="percent">'. round(100 * $vote / $total_votes, 0) .'% ('. format_plural($vote, '1 vote', '@count votes') .')</div>';
   return $output;
 }
- 
+
 /**
  * Outputs a status line.
  */
@@ -331,9 +337,9 @@ function theme_decisions_status($message
   return '<div class="error">'. $message .'</div>';
 }
 
-
 /****************************/
 /* Electoral list functions */
+
 /****************************/
 
 /**
@@ -342,35 +348,34 @@ function theme_decisions_status($message
 function decisions_electoral_list_form($form_state, $nid) {
   $form = array();
   $form['electoral_list'] = array(
-                                  '#type' => 'fieldset',
-                                  '#tree' => TRUE,
-                                  '#title' => t('Administer electoral list'),
-                                  '#collapsible' => TRUE,
-                                  '#weight' => 2,
-                                  '#collapsed' => TRUE,
-                                  );
+    '#type' => 'fieldset',
+    '#tree' => TRUE,
+    '#title' => t('Administer electoral list'),
+    '#collapsible' => TRUE,
+    '#weight' => 2,
+    '#collapsed' => TRUE,
+  );
 
   $form['electoral_list']['add_user'] = array(
-                                              '#type' => 'textfield',
-                                              '#title' => t('Add user'),
-                                              '#size' => 40,
-                                              '#autocomplete_path' => 'user/autocomplete',
-                                              '#description' => t('Add an individual user to the electoral list'),
-                                              );
+    '#type' => 'textfield',
+    '#title' => t('Add user'),
+    '#size' => 40,
+    '#autocomplete_path' => 'user/autocomplete',
+    '#description' => t('Add an individual user to the electoral list'),
+  );
 
   $form['electoral_list']['submit'] = array(
-                                            '#type' => 'submit',
-                                            '#value' => t('Modify electoral list'),
-                                            );
+    '#type' => 'submit',
+    '#value' => t('Modify electoral list'),
+  );
 
   $form['electoral_list']['reset'] = array(
-                                           '#type' => 'button',
-                                           '#value' => t('Reset electoral list'),
-                                           );
+    '#type' => 'button',
+    '#value' => t('Reset electoral list'),
+  );
 
   $form['nid'] = array('#type' => 'hidden', '#value' => $nid);
-  return $form;        
-
+  return $form;
 }
 
 /**
@@ -386,32 +391,32 @@ function decisions_electoral_list_tab() 
     drupal_set_title(check_plain($node->title));
     if (user_access('administer decisions')) {
       $form['electoral_list'] = array(
-                                      '#type' => 'fieldset',
-                                      '#tree' => TRUE,
-                                      '#title' => t('Administer electoral list'),
-                                      '#collapsible' => TRUE,
-                                      '#weight' => 2,
-                                      '#collapsed' => TRUE,
-                                      );
-  	 
+        '#type' => 'fieldset',
+        '#tree' => TRUE,
+        '#title' => t('Administer electoral list'),
+        '#collapsible' => TRUE,
+        '#weight' => 2,
+        '#collapsed' => TRUE,
+      );
+
       $form['electoral_list']['add_user'] = array(
-                                                  '#type' => 'textfield',
-                                                  '#title' => t('Add user'),
-                                                  '#size' => 40,
-                                                  '#autocomplete_path' => 'user/autocomplete',
-                                                  '#description' => t('Add an individual user to the electoral list'),
-                                                  );
-  	 
+        '#type' => 'textfield',
+        '#title' => t('Add user'),
+        '#size' => 40,
+        '#autocomplete_path' => 'user/autocomplete',
+        '#description' => t('Add an individual user to the electoral list'),
+      );
+
       $form['electoral_list']['submit'] = array(
-                                                '#type' => 'submit',
-                                                '#value' => t('Modify electoral list'),
-                                                );
-  	 
+        '#type' => 'submit',
+        '#value' => t('Modify electoral list'),
+      );
+
       $form['electoral_list']['reset'] = array(
-                                               '#type' => 'button',
-                                               '#value' => t('Reset electoral list'),
-                                               );
-  	 
+        '#type' => 'button',
+        '#value' => t('Reset electoral list'),
+      );
+
       $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
       $output .= drupal_get_form('decisions_electoral_list_form', $node->nid);
     }
@@ -419,15 +424,15 @@ function decisions_electoral_list_tab() 
 
     $header[] = array('data' => t('Voter'), 'field' => 'u.name');
 
-    $result = pager_query("SELECT u.uid, u.name FROM {decisions_electoral_list} el LEFT JOIN {users} u ON el.uid = u.uid WHERE el.nid = %d" . tablesort_sql($header), 20, 0, NULL, $node->nid);
+    $result = pager_query("SELECT u.uid, u.name FROM {decisions_electoral_list} el LEFT JOIN {users} u ON el.uid = u.uid WHERE el.nid = %d". tablesort_sql($header), 20, 0, NULL, $node->nid);
     $eligible_voters = array();
     while ($voter = db_fetch_object($result)) {
       $temp = array(theme('username', $voter));
-      
+
       if (user_access('administer decisions')) {
         $temp[] = l(t('remove'), 'node/'. $node->nid .'/remove/'. $voter->uid);
       }
-      
+
       $eligible_voters[] = $temp;
     }
     $output .= theme('table', $header, $eligible_voters);
@@ -452,10 +457,10 @@ function decisions_electoral_list_remove
   else {
     drupal_set_message(t('No user found with a uid of %uid.', array('%uid' => $uid)));
   }
-  
+
   drupal_goto('node/'. $node->nid .'/electoral_list');
 }
-  	 
+
 /**
  * Validate changes to the electoral list
  */
@@ -484,7 +489,7 @@ function decisions_electoral_list_form_v
     return FALSE;
   }
 }
-  	 
+
 /**
  * Submit changes to the electoral list
  */
@@ -501,9 +506,9 @@ function decisions_electoral_list_form_s
   }
 }
 
-
 /***********************************/
 /* Decision-mode related functions */
+
 /***********************************/
 
 /**
@@ -565,7 +570,7 @@ function decisions_voting_form_submit($f
 function decisions_voting_form_validate($form, &$form_state) {
   $node = node_load($form_state['values']['nid']);
   $mode = _decisions_get_mode($node);
-  if (function_exists("{$mode}_decisions_vote_validate") ) {
+  if (function_exists("{$mode}_decisions_vote_validate")) {
     return call_user_func("{$mode}_decisions_vote_validate", $node, $form_state['values']);
   }
   return TRUE;
@@ -579,7 +584,8 @@ function decisions_voting_form_validate(
  */
 function decisions_vote($node, $form_values) {
   $mode = _decisions_get_mode($node);
-  $ok = FALSE; // error by default
+  // error by default
+  $ok = FALSE;
   if (_decisions_eligible($node)) {
     if (function_exists("{$mode}_decisions_vote")) {
       call_user_func("{$mode}_decisions_vote", $node, $form_values);
@@ -602,12 +608,14 @@ function decisions_algorithms($mode) {
     $algs = call_user_func("{$mode}_decisions_algorithms");
     $error = FALSE;
     if (!is_array($algs)) {
-      $error = t('Element returned by the call to function @function is not an array, returning dummy value.', 
-                    array('@function' => "decisions_{$mode}_algorithms"));
+      $error = t('Element returned by the call to function @function is not an array, returning dummy value.',
+        array('@function' => "decisions_{$mode}_algorithms")
+      );
     }
     else if (count($algs) == 0) {
-      $error = t('Array returned by the call to function @function is empty, returning dummy value.', 
-                    array('@function' => "decisions_{$mode}_algorithms"));      
+      $error = t('Array returned by the call to function @function is empty, returning dummy value.',
+        array('@function' => "decisions_{$mode}_algorithms")
+      );
     }
     if ($error) {
       watchdog('decisions', $error, WATCHDOG_WARNING);
@@ -620,9 +628,9 @@ function decisions_algorithms($mode) {
   return $algs;
 }
 
-
 /*************/
 /* Callbacks */
+
 /*************/
 
 /**
@@ -641,7 +649,7 @@ function decisions_cancel($nid) {
       drupal_set_message(t("You are not allowed to cancel an invalid choice."), 'error');
     }
     drupal_goto('node/'. $nid);
-  }       
+  }
   else {
     drupal_not_found();
   }
@@ -678,17 +686,18 @@ function decisions_votes_tab() {
      *
      * XXX: highly MySQL specific
      */
-    $query = 'SELECT u.name, v.uid, v.vote_source, GROUP_CONCAT(DISTINCT CONCAT(v.value,"=>",v.tag) ORDER BY v.value) as votes FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY v.uid' . tablesort_sql($header) . '';
+
+    $query       = 'SELECT u.name, v.uid, v.vote_source, GROUP_CONCAT(DISTINCT CONCAT(v.value,"=>",v.tag) ORDER BY v.value) as votes FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY v.uid'. tablesort_sql($header) .'';
     $query_count = 'SELECT COUNT(DISTINCT v.uid) FROM {votingapi_vote} v LEFT JOIN {users} u ON v.uid = u.uid WHERE v.content_id = %d GROUP BY content_id'. tablesort_sql($header);
-    $result = pager_query($query, variable_get('decisions_votes_per_page', 20), 0, $query_count, $node->nid);
-    $votes = array();
-    $names = array();
+    $result      = pager_query($query, variable_get('decisions_votes_per_page', 20), 0, $query_count, $node->nid);
+    $votes       = array();
+    $names       = array();
     while ($vote = db_fetch_object($result)) {
-      $key = $vote->uid? $vote->uid : $vote->vote_source;
+      $key = $vote->uid ? $vote->uid : $vote->vote_source;
       $choices = explode(',', $vote->votes);
       foreach ($choices as $choice) {
         $choice = explode("=>", $choice);
-        $votes[$key][] = (object) array('value' => $choice[0], 'tag' => $choice[1]);
+        $votes[$key][] = (object)array('value' => $choice[0], 'tag' => $choice[1]);
       }
       $names[$key] = $vote->name ? theme('username', $vote) : check_plain($vote->vote_source);
     }
@@ -699,7 +708,7 @@ function decisions_votes_tab() {
       _decisions_panic_on_mode($mode, __FUNCTION__);
       drupal_not_found();
     }
-    
+
     $rows = array();
     foreach ($names as $key => $name) {
       $rows[$key]['name'] = $name;
@@ -716,31 +725,33 @@ function decisions_votes_tab() {
 }
 
 /**
- * Callback for 'results' tab for decisions you can vote on. 	 
- */ 	 
-function decisions_results() { 	 
-  if ($node = menu_get_object()) { 	 
-    drupal_set_title(check_plain($node->title)); 	 
-    return node_show($node, 0); 	 
-  } 	 
-  else { 	 
-    // The url does not provide the appropriate node id 	 
-    drupal_not_found(); 	 
-  } 	 
+ * Callback for 'results' tab for decisions you can vote on.
+ */
+function decisions_results() {
+  if ($node = menu_get_object()) {
+    drupal_set_title(check_plain($node->title));
+    return node_show($node, 0);
+  }
+  else {
+    // The url does not provide the appropriate node id
+    drupal_not_found();
+  }
 }
 
- /**
+/**
  * Callback to display a reset votes confirmation form
  */
 function decisions_reset_form($form_state, $node) {
   $form['nid'] = array('#type' => 'hidden', '#value' => $node->nid);
   return confirm_form($form,
-                         t('Are you sure you want to reset the votes for !title?',
-                           array('!title' => theme('placeholder', $node->title))),
-                         'node/'. $node->nid,
-                         t('This action cannot be undone.'),
-                         t('Reset votes'),
-                         t('Cancel') );
+    t('Are you sure you want to reset the votes for !title?',
+      array('!title' => theme('placeholder', $node->title))
+    ),
+    'node/'. $node->nid,
+    t('This action cannot be undone.'),
+    t('Reset votes'),
+    t('Cancel')
+  );
 }
 
 /**
@@ -772,11 +783,11 @@ function _decisions_get_mode($node) {
  * Callback function to see if a node is acceptable for poll menu items.
  */
 function _decisions_votes_access($node, $perm) {
-	return user_access($perm) && $node->showvotes && strpos($node->type, 'decisions_') === 0;
+  return user_access($perm) && $node->showvotes && strpos($node->type, 'decisions_') === 0;
 }
 
 function _decisions_reset_access($node, $perm) {
-	return user_access($perm) && strpos($node->type, 'decisions_') === 0;
+  return user_access($perm) && strpos($node->type, 'decisions_') === 0;
 }
 
 function _decisions_electoral_list_access($node, $perm) {
@@ -788,20 +799,26 @@ function _decisions_electoral_list_acces
  */
 function _decisions_is_open($node) {
   $time = time();
-  return ($node->active &&                    // node must be active
-          // current time must be past start date and before end date
-          ($time >= $node->startdate) &&
-          ($node->runtime == DECISIONS_RUNTIME_INFINITY ||
-           $time < ($node->startdate + $node->runtime)));
+    // node must be active
+  return ($node->active &&
+    // current time must be past start date and before end date
+    ($time >= $node->startdate) &&
+    ($node->runtime == DECISIONS_RUNTIME_INFINITY ||
+      $time < ($node->startdate + $node->runtime)
+    )
+  );
 }
 
 /**
  * Function that tells if the given user can vote on this decision.
  */
 function _decisions_can_vote($node, $user = NULL) {
-  return (_decisions_is_open($node) &&         // node must be open
-          !$node->voted &&                    // user should not have already voted
-          _decisions_eligible($node, $user));  // user must be eligible to vote
+    // node must be open
+  return (_decisions_is_open($node) &&
+    // user should not have already voted
+    !$node->voted &&
+    // user must be eligible to vote
+    _decisions_eligible($node, $user));
 }
 
 /**
@@ -814,7 +831,6 @@ function _decisions_meets_quorum($node) 
   return ($num_voters >= $quorum);
 }
 
-
 /**
  * Internal function factored out that just rings lots of bells when
  * we detect an unknown mode.
@@ -859,7 +875,7 @@ function _decisions_count_eligible($node
       $result = db_fetch_object(db_query("SELECT COUNT(DISTINCT ur.uid) AS num FROM {users_roles} ur JOIN {permission} p ON ur.rid = p.rid WHERE FIND_IN_SET(' vote on decisions', p.perm) AND ur.uid <> 0"));
     }
   }
-  return $result->num;    
+  return $result->num;
 }
 
 /**
@@ -887,16 +903,16 @@ function _decisions_count_voters($node) 
  */
 function _decisions_user_votes($node) {
   $votes = _decisions_votes($node);
-  
+
   // aggregate votes by user (uid if logged in, IP if anonymous)
   // in ascending order of value
   $user_votes = array();
 
   foreach ($votes as $vote) {
-    $key = ($vote->uid == 0 ? $vote->vote_source: $vote->uid);
+    $key = ($vote->uid == 0 ? $vote->vote_source : $vote->uid);
     $user_votes[$key][] = $vote;
   }
-  
+
   return $user_votes;
 }
 
@@ -921,10 +937,12 @@ function _decisions_eligible($node, $uid
 
 /**
  * Constructs the time select boxes.
- * 
+ *
  * @ingroup event_support
+ *
  * @param $timestamp The time GMT timestamp of the event to use as the default
  *   value.
+ *
  * @return An array of form elements for month, day, year, hour, and minute
  */
 function _decisions_form_date($timestamp) {
@@ -934,8 +952,8 @@ function _decisions_form_date($timestamp
   // ...hours
   if (variable_get('event_ampm', '0')) {
     $hour_format = t('g');
-    $hours = drupal_map_assoc(range(1, 12));
-    $am_pms = array('am' => t('am'), 'pm' => t('pm'));
+    $hours       = drupal_map_assoc(range(1, 12));
+    $am_pms      = array('am' => t('am'), 'pm' => t('pm'));
   }
   else {
     $hour_format = t('H');
@@ -951,52 +969,60 @@ function _decisions_form_date($timestamp
     '#default_value' => _decisions_date('d', $timestamp),
     '#maxlength' => 2,
     '#size' => 2,
-    '#required' => TRUE);
+    '#required' => TRUE,
+  );
   $form['month'] = array(
     '#type' => 'select',
     '#default_value' => _decisions_date('n', $timestamp),
     '#options' => $months,
-    '#required' => TRUE);
+    '#required' => TRUE,
+  );
   $form['year'] = array(
     '#type' => 'textfield',
     '#default_value' => _decisions_date('Y', $timestamp),
     '#maxlength' => 4,
     '#size' => 4,
-    '#required' => TRUE);
+    '#required' => TRUE,
+  );
   $form['hour'] = array(
     '#prefix' => '</div>&#8212;<div class="time">',
     '#type' => 'select',
     '#default_value' => _decisions_date($hour_format, $timestamp),
     '#options' => $hours,
-    '#required' => TRUE);
+    '#required' => TRUE,
+  );
   $form['minute'] = array(
     '#prefix' => ':',
     '#type' => 'select',
     '#default_value' => _decisions_date('i', $timestamp),
     '#options' => $minutes,
-    '#required' => TRUE);
+    '#required' => TRUE,
+  );
   if (isset($am_pms)) {
     $form['ampm'] = array(
       '#type' => 'radios',
       '#default_value' => _decisions_date('a', $timestamp),
       '#options' => $am_pms,
-      '#required' => TRUE);
+      '#required' => TRUE,
+    );
   }
   $form['close'] = array(
     '#type' => 'markup',
-    '#value' => '</div></div>');
+    '#value' => '</div></div>',
+  );
 
   return $form;
 }
 
 /**
  * Takes a time element and prepares to send it to form_date()
- * 
+ *
  * @param $time
  *   The time to be turned into an array. This can be:
  *   - a timestamp when from the database
  *   - an array (day, month, year) when previewing
  *   - null for new nodes
+ *
  * @returnn
  *   an array for form_date (day, month, year)
  */
@@ -1010,7 +1036,7 @@ function _decisions_form_prepare_datetim
   $time_array = array();
   if (is_array($time)) {
     $time_array = $time;
-  } 
+  }
   // otherwise build the array from the timestamp
   elseif (is_numeric($time)) {
     $time_array = array(
@@ -1036,6 +1062,7 @@ function _decisions_block_mostrecent() {
   if ($decision = db_fetch_object($result)) {
     $n = decisions_view(node_load($decision->nid), FALSE, FALSE, TRUE);
     /* XXX: we have to do this because somehow the #printed settings lives across multiple node_load */
+
     unset($n->content['#printed']);
     $output = drupal_render($n->content);
   }
@@ -1050,12 +1077,16 @@ function _decisions_block_mostrecent() {
  */
 function _decisions_can_view_results($node) {
   $view_results = variable_get('decisions_view_results', DECISIONS_DEFAULT_VIEW_RESULTS);
-  return user_access('administer decisions') || 
-          (_decisions_meets_quorum($node) && // node meets the quorum
-          strpos($node->type, 'decisions_') === 0 &&
-          (!_decisions_is_open($node)       // node is closed
-          || ($node->voted && $view_results == 'aftervote') // user voted
-          || ($view_results == 'always'))); // all can view
+    // node meets the quorum
+  return user_access('administer decisions') || (_decisions_meets_quorum($node) &&
+    strpos($node->type, 'decisions_') === 0 &&
+      // node is closed
+    (!_decisions_is_open($node)
+      // user voted
+      || ($node->voted && $view_results == 'aftervote')
+      // all can view
+      || ($view_results == 'always'))
+  );
 }
 
 /**
@@ -1073,7 +1104,6 @@ function _decisions_electoral_list_reset
     // all users must not be allowed to vote, add relevant users only
     return db_query("INSERT INTO {decisions_electoral_list} (nid, uid) SELECT '%d', u.uid FROM users_roles u, permission p WHERE FIND_IN_SET(' view decisions', p.perm) AND u.rid = p.rid AND u.uid <> 0", $node->nid);
   }
-
 }
 
 /**
@@ -1123,14 +1153,14 @@ function decisions_insert($node) {
     $runtime = DECISIONS_RUNTIME_INFINITY;
   }
   else {
-    $enddate =  _decisions_translate_form_date($node->settings['date']['enddate']['date']);
+    $enddate = _decisions_translate_form_date($node->settings['date']['enddate']['date']);
     if ($enddate < $startdate) {
       form_set_error('enddate', t('The specified close date is less than the opening date, setting it to the same for now.'));
       $enddate = $startdate;
     }
     $runtime = $enddate - $startdate;
   }
-  
+
   // just create an empty entry for now
   $mode = _decisions_get_mode($node);
 
@@ -1172,11 +1202,10 @@ function decisions_validate(&$node) {
   }
 
   $startdate = _decisions_translate_form_date($node->settings['date']['startdate']['date']);
-  $enddate =  _decisions_translate_form_date($node->settings['date']['enddate']['date']);
+  $enddate = _decisions_translate_form_date($node->settings['date']['enddate']['date']);
   if (!$node->settings['date']['noenddate'] && $enddate < $startdate) {
     form_set_error('enddate', t('The specified close date is less than the opening date.'));
   }
-
 }
 
 /**
@@ -1191,14 +1220,14 @@ function decisions_update($node) {
     $runtime = DECISIONS_RUNTIME_INFINITY;
   }
   else {
-    $enddate =  _decisions_translate_form_date($node->settings['date']['enddate']['date']);
+    $enddate = _decisions_translate_form_date($node->settings['date']['enddate']['date']);
     if ($enddate < $startdate) {
       form_set_error('enddate', t('The specified close date is less than the opening date, setting it to the same for now.'));
       $enddate = $startdate;
     }
     $runtime = $enddate - $startdate;
   }
-    
+
   $uselist = db_result(db_query("SELECT uselist FROM {decisions} WHERE nid = %d", $node->nid));
   if ($node->settings['uselist'] != $uselist) {
     // create the electoral list if activated
@@ -1209,7 +1238,7 @@ function decisions_update($node) {
     else {
       db_query("DELETE FROM {decisions_electoral_list} WHERE nid = %d", $node->nid);
     }
-  } 
+  }
 
   db_query("UPDATE {decisions} SET quorum_abs=%d, quorum_percent=%f, active=%d, runtime=%d, maxchoices=%d, algorithm='%s', uselist=%d, showvotes=%d, startdate=%d, randomize=%d WHERE nid = %d", $node->settings['quorum']['quorum_abs'], $node->settings['quorum']['quorum_percent'], $node->settings['active'], $runtime, $node->settings['maxchoices'], $node->settings['algorithm'], $node->settings['uselist'], $node->settings['showvotes'], $startdate, $node->settings['randomize'], $node->nid);
   // XXX: should update decisions here, when it has some parameters
@@ -1242,11 +1271,14 @@ function decisions_submit(&$node) {
 function decisions_add_choices_submit($form, &$form_state) {
   // Set the form to rebuild and run submit handlers.
   node_form_submit_build_node($form, $form_state);
-  if (!isset($form_state['values']['choice'])) return;
+  if (!isset($form_state['values']['choice'])) {
+    return;
+  }
 
-  // Add new choices 
+  // Add new choices
   if ($form_state['values']['choice']['morechoices']) {
-    $form_state['values']['choice']['choices'] = count($form_state['values']['choice']) + 1; // adding 1 + 2 elements
+    // adding 1 + 2 elements
+    $form_state['values']['choice']['choices'] = count($form_state['values']['choice']) + 1;
   }
 }
 
@@ -1257,30 +1289,31 @@ function decisions_add_choices_js() {
 
   $form_build_id = $_POST['form_build_id'];
   $form_id = $_POST['form_id'];
-  
+
   $form_state = array('submitted' => FALSE);
-  $form = form_get_cache($form_build_id, $form_state);  
-  
-  // Update related form data 
+  $form = form_get_cache($form_build_id, $form_state);
+
+  // Update related form data
   if (!$form['choice']['choices']['#default_value']) {
-    $form['choice']['choices']['#default_value'] = 0; // silence a warning
+    // silence a warning
+    $form['choice']['choices']['#default_value'] = 0;
   }
   $count = ++$form['choice']['choices']['#default_value'];
   $form['settings']['maxchoices']['#options'] = _decisions_choice_list($count);
   $form['choice'][$count]['label'] = _decisions_new_choice($count);
 
   form_set_cache($form_build_id, $form, $form_state);
-  
-  $form['#post'] = $_POST; 
-  $form['#redirect'] = FALSE; 
-  $form['#programmed'] = FALSE; 
+
+  $form['#post']       = $_POST;
+  $form['#redirect']   = FALSE;
+  $form['#programmed'] = FALSE;
 
   $form = form_builder($form_id, $form, $form_state);
 
   $newchoice = $form['choice'][$count];
   $output = theme('status_messages') . drupal_render($newchoice);
 
-  drupal_json(array('status' => TRUE, 'data' => $output)); 
+  drupal_json(array('status' => TRUE, 'data' => $output));
 }
 
 /**
@@ -1312,7 +1345,7 @@ function decisions_view(&$node, $teaser 
     }
   }
   $node->content['decisions']['status']['#value'] = $status_messages;
-  $node->content['decisions']['#weight'] = 1;  
+  $node->content['decisions']['#weight'] = 1;
 
   if (arg(2) != 'results' && _decisions_can_vote($node)) {
     // User hasn't voted and we're not on the results tab
@@ -1323,7 +1356,8 @@ function decisions_view(&$node, $teaser 
     // show results only if the user has voted or decision is closed
     $node->content['decisions']['results']['#value'] = decisions_view_results($node, $teaser, $page);
     $node->content['decisions']['list']['#value'] = theme('decisions_view_header', $node, $teaser);
-  } else {
+  }
+  else {
     $node->content['decisions']['#value'] = theme('decisions_view_own_result');
   }
   if (isset($node->voted) && $node->voted && user_access('cancel own vote') && $node->active) {
@@ -1335,9 +1369,10 @@ function decisions_view(&$node, $teaser 
 
 /**
  * Generate a new choice element in decisions form
- * 
+ *
  * @param $index position of choice item in list
- * @param $value default value of choice element 
+ * @param $value default value of choice element
+ *
  * @return new choice element
  */
 function _decisions_new_choice($index, $value = NULL) {
@@ -1360,7 +1395,7 @@ function _decisions_new_choice($index, $
 function _decisions_choice_list($choices) {
   $max_choice_list = array();
   for ($i = 0; $i <= $choices; $i++) {
-    $max_choice_list[$i] = ($i == 0? 'No limit' : $i);
+    $max_choice_list[$i] = ($i == 0 ? 'No limit' : $i);
   }
   return $max_choice_list;
 }
@@ -1373,18 +1408,19 @@ function _decisions_choice_list($choices
 function decisions_form(&$node, &$form_state) {
   $mode = _decisions_get_mode($node);
   if (array_key_exists('values', $form_state)) {
-    $form_values = $form_state['values']; # adapt to D6 FormsAPI
+    # adapt to D6 FormsAPI
+    $form_values = $form_state['values'];
   }
   else {
     $form_values = array();
   }
 
   $form['title'] = array(
-                         '#type' => 'textfield',
-                         '#title' => ucfirst($mode) .' '. t('Question'),
-                         '#required' => TRUE,
-                         '#default_value' => $node->title,
-                         );
+    '#type' => 'textfield',
+    '#title' => ucfirst($mode) .' '. t('Question'),
+    '#required' => TRUE,
+    '#default_value' => $node->title,
+  );
 
   $type = node_get_types('type', $node);
   if (empty($type->body_label) || $type->body_label == "Body") {
@@ -1397,7 +1433,7 @@ function decisions_form(&$node, &$form_s
 
   if (isset($form_state['values']['choice']['choices']) && is_numeric($form_state['values']['choice']['choices'])) {
     $choices = max(2, $form_state['values']['choice']['choices']);
-  } 
+  }
   else {
     $choices = max(2, isset($node->choice) && count($node->choice) ? count($node->choice) : 5);
   }
@@ -1405,19 +1441,20 @@ function decisions_form(&$node, &$form_s
   $form['choice']['js'] = array(
     '#type' => 'markup',
     '#theme' => 'decisions_morechoices',
-  );  
-  
+  );
+
   $form['choice']['choices'] = array(
     '#type' => 'hidden',
-    '#default_value' => $choices,  
+    '#default_value' => $choices,
   );
-      
+
   $form['choice']['morechoices'] = array(
     '#type' => 'submit',
     '#value' => t('Add more choices'),
     '#description' => t("Click this button to add more choices to this form."),
     '#weight' => 2,
-    '#submit' => array('decisions_add_choices_submit'), // falback method for when JS is turned off
+    // falback method for when JS is turned off
+    '#submit' => array('decisions_add_choices_submit'),
     '#ahah' => array(
       'path' => 'decisions/add_choices_js',
       'wrapper' => 'edit-choice-morechoices',
@@ -1428,53 +1465,53 @@ function decisions_form(&$node, &$form_s
 
   // Decisions choices
   $form['choice'] += array(
-                           '#type' => 'fieldset',
-                           '#title' => t('Decision choices'),
-                           '#description' => t('Enter all available choices here. Leave text box empty to delete a choice.'),
-                           '#collapsible' => TRUE,
-                           '#prefix' => '<div class="poll-form">',
-                           '#suffix' => '</div>', 
-                           '#tree' => TRUE,
-                           '#weight' => 1,
-                           );
+    '#type' => 'fieldset',
+    '#title' => t('Decision choices'),
+    '#description' => t('Enter all available choices here. Leave text box empty to delete a choice.'),
+    '#collapsible' => TRUE,
+    '#prefix' => '<div class="poll-form">',
+    '#suffix' => '</div>',
+    '#tree' => TRUE,
+    '#weight' => 1,
+  );
 
   for ($a = 1; $a <= $choices; $a++) {
     $form['choice'][$a]['label'] = _decisions_new_choice($a, (isset($node->choice) ? $node->choice[$a]['label'] : NULL));
   }
 
   $form['settings'] = array(
-                            '#type' => 'fieldset',
-                            '#tree' => TRUE,
-                            '#title' => t('Decision settings'),
-                            '#collapsible' => TRUE,
-                            '#collapsed' => TRUE,
-                            '#weight' => 2,
-                            );
- 
+    '#type' => 'fieldset',
+    '#tree' => TRUE,
+    '#title' => t('Decision settings'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#weight' => 2,
+  );
+
   $form['settings']['maxchoices'] = array(
-                                          '#type' => 'select',
-                                          '#title' => t('Maximum Choices'),
-                                          '#default_value' => (isset($node->maxchoices)? $node->maxchoices : 0),
-                                          '#options' => _decisions_choice_list($choices),
-                                          '#description' => t('Limits the total number of choices voters may select.'),
-                                          );
+    '#type' => 'select',
+    '#title' => t('Maximum Choices'),
+    '#default_value' => (isset($node->maxchoices) ? $node->maxchoices : 0),
+    '#options' => _decisions_choice_list($choices),
+    '#description' => t('Limits the total number of choices voters may select.'),
+  );
 
   $algs = decisions_algorithms($mode);
   $alg_desc = '';
   foreach ($algs as $alg => $desc) {
     $voting_algorithms[$alg] = ucwords($alg);
-    $alg_desc .= ucwords($alg) . " - " . $desc . "<br />";
+    $alg_desc .= ucwords($alg) ." - ". $desc ."<br />";
   }
 
   $defaultalg = (isset($node->algorithm) ? $node->algorithm : (isset($algs[0]) ? $algs[0] : ''));
   if (count($voting_algorithms) > 1) {
     $form['settings']['algorithm'] = array(
-                                         '#type' => 'select',
-                                         '#title' => t('Algorithm'),
-                                         '#options' => $voting_algorithms,
-                                         '#default_value' => $defaultalg,
-                                         '#description' => t('Voting algorithm to use to calculate the winner.') . "<br />" . $alg_desc,
-                                         );
+      '#type' => 'select',
+      '#title' => t('Algorithm'),
+      '#options' => $voting_algorithms,
+      '#default_value' => $defaultalg,
+      '#description' => t('Voting algorithm to use to calculate the winner.') ."<br />". $alg_desc,
+    );
   }
   else {
     $form['settings']['algorithm'] = array('#type' => 'hidden', '#value' => $defaultalg);
@@ -1482,36 +1519,36 @@ function decisions_form(&$node, &$form_s
 
   $active = array(1 => t('Active'), 0 => t('Closed'));
   $form['settings']['active'] = array(
-                                      '#type' => 'radios',
-                                      '#title' => t('Decision Status'),
-                                      '#options' => $active,
-                                      '#default_value' => (isset($node->active)? $node->active : 1),
-                                      '#description' => t('When a decision is closed users may no longer vote on it.'),
-                                      );
+    '#type' => 'radios',
+    '#title' => t('Decision Status'),
+    '#options' => $active,
+    '#default_value' => (isset($node->active) ? $node->active : 1),
+    '#description' => t('When a decision is closed users may no longer vote on it.'),
+  );
 
   $enabled = array(0 => t('Disabled'), 1 => t('Enabled'));
   $form['settings']['uselist'] = array(
-                                       '#type' => 'checkbox',
-                                       '#title' => t('Restrict voting to electoral list'),
-                                       '#description' => t('If enabled, a list of eligible voters will be created and only that group will be able to vote in the decision.'),
-                                       '#default_value' => isset($node->uselist)? $node->uselist : variable_get('decisions_default_electoral_list', DECISIONS_DEFAULT_ELECTORAL_LIST),
-                                       '#options' => $enabled,
-                                       );
+    '#type' => 'checkbox',
+    '#title' => t('Restrict voting to electoral list'),
+    '#description' => t('If enabled, a list of eligible voters will be created and only that group will be able to vote in the decision.'),
+    '#default_value' => isset($node->uselist) ? $node->uselist : variable_get('decisions_default_electoral_list', DECISIONS_DEFAULT_ELECTORAL_LIST),
+    '#options' => $enabled,
+  );
 
   $form['settings']['showvotes'] = array(
-                                         '#type' => 'checkbox',
-                                         '#title' => t('Show individual votes'),
-                                         '#description' => t('Users with the appropriate permissions will be able to see how each person voted.'),
-                                         '#default_value' => isset($node->showvotes)? $node->showvotes : 1,
-                                         '#options' => $enabled,
-                                         );
-  
+    '#type' => 'checkbox',
+    '#title' => t('Show individual votes'),
+    '#description' => t('Users with the appropriate permissions will be able to see how each person voted.'),
+    '#default_value' => isset($node->showvotes) ? $node->showvotes : 1,
+    '#options' => $enabled,
+  );
+
   $form['settings']['randomize'] = array(
-                                         '#type' => 'checkbox',
-                                         '#title' => t('Randomize answers order'),
-                                         '#default_value' => $node->randomize,
-                                         '#description' => t('Display answers in a random order each time the poll is displayed.'),
-                                        );
+    '#type' => 'checkbox',
+    '#title' => t('Randomize answers order'),
+    '#default_value' => $node->randomize,
+    '#description' => t('Display answers in a random order each time the poll is displayed.'),
+  );
 
   $form['settings']['date'] = array(
     '#type' => 'fieldset',
@@ -1519,22 +1556,23 @@ function decisions_form(&$node, &$form_s
     '#collapsed' => TRUE,
     '#collapsible' => TRUE,
   );
-  
+
   $startdate = !is_null($node->startdate) ? $node->startdate : time();
   $runtime = !is_null($node->runtime) ? $node->runtime : variable_get('decisions_default_runtime', 24 * 60 * 60);
   if ($runtime == DECISIONS_RUNTIME_INFINITY) {
-    $enddate = $startdate; // by default
+    // by default
+    $enddate = $startdate;
   }
   else {
     $enddate = $startdate + $runtime;
   }
-  
+
   $form['settings']['date']['startdate'] = array(
     '#type' => 'fieldset',
-    '#title' => t('Opening date')
-  );  
+    '#title' => t('Opening date'),
+  );
   $form['settings']['date']['startdate']['date'] = _decisions_form_date($startdate);
-  
+
   $form['settings']['date']['noenddate'] = array(
     '#type' => 'checkbox',
     '#title' => t('No closing date'),
@@ -1548,51 +1586,51 @@ function decisions_form(&$node, &$form_s
     '#collapsed' => ($runtime != DECISIONS_RUNTIME_INFINITY),
     '#collapsible' => TRUE,
     '#attributes' => array('id' => 'enddate'),
-    '#title' => t('Closing date')
-  );  
+    '#title' => t('Closing date'),
+  );
   $form['settings']['date']['enddate']['date'] = _decisions_form_date($enddate);
 
-  
+
   $form['settings']['quorum'] = array(
-                            '#type' => 'fieldset',
-                            '#tree' => TRUE,
-                            '#title' => t('Quorum'),
-                            '#collapsible' => TRUE,
-                            '#collapsed' => TRUE,
-                            '#weight' => 2,
-                            '#description' => t('These settings allow for a decision to be valid only if a certain number of eligible voters have cast their ballot. It can be configured both with an absolute number and a percentage of eligible voters. For example, a common setting is "50% + 1", which would be expressed as "@percent: 50" and "@number: 1". Note that the quorum has no impact on the winning conditions.', array('@percent' => t('Percentage (%)'), '@number' => t('Number'))),
-                            );
+    '#type' => 'fieldset',
+    '#tree' => TRUE,
+    '#title' => t('Quorum'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#weight' => 2,
+    '#description' => t('These settings allow for a decision to be valid only if a certain number of eligible voters have cast their ballot. It can be configured both with an absolute number and a percentage of eligible voters. For example, a common setting is "50% + 1", which would be expressed as "@percent: 50" and "@number: 1". Note that the quorum has no impact on the winning conditions.', array('@percent' => t('Percentage (%)'), '@number' => t('Number'))),
+  );
 
   $form['settings']['quorum']['quorum_abs'] = array(
-                                       '#type' => 'textfield',
-                                       '#size' => 10,
-                                       '#title' => t('Number'),
-                                       '#default_value' => ($node->quorum_abs? $node->quorum_abs : 0),
-                                       '#required' => TRUE,
-                                       '#description' => t('Minimum number of voters required to cast their ballot for this decision to be valid, in addition to the percentage.')
-                                       );
+    '#type' => 'textfield',
+    '#size' => 10,
+    '#title' => t('Number'),
+    '#default_value' => ($node->quorum_abs ? $node->quorum_abs : 0),
+    '#required' => TRUE,
+    '#description' => t('Minimum number of voters required to cast their ballot for this decision to be valid, in addition to the percentage.'),
+  );
 
   $form['settings']['quorum']['quorum_percent'] = array(
-                                       '#type' => 'textfield',
-                                       '#size' => 10,
-                                       '#title' => t('Percentage (%)'),
-                                       '#default_value' => ($node->quorum_percent? $node->quorum_percent : 0),
-                                       '#required' => TRUE,
-                                       '#description' => t('Minimum numbers of voters required for this decision to be valid, expressed as a percentage of the eligible voters rounded up.'),
-                                       '#weight' => -1,
-                                       );
-                                                                           
+    '#type' => 'textfield',
+    '#size' => 10,
+    '#title' => t('Percentage (%)'),
+    '#default_value' => ($node->quorum_percent ? $node->quorum_percent : 0),
+    '#required' => TRUE,
+    '#description' => t('Minimum numbers of voters required for this decision to be valid, expressed as a percentage of the eligible voters rounded up.'),
+    '#weight' => -1,
+  );
+
   return $form;
 }
 
 function theme_decisions_morechoices(&$element) {
-    
-    drupal_add_js('misc/jquery.form.js');
-    drupal_add_js('misc/ahah.js');
-    drupal_add_js(drupal_get_path('module', 'decisions') .'/decisions.js', 'module');
 
-    $output = drupal_render($element);     
-    return $output;
+  drupal_add_js('misc/jquery.form.js');
+  drupal_add_js('misc/ahah.js');
+  drupal_add_js(drupal_get_path('module', 'decisions') .'/decisions.js', 'module');
+
+  $output = drupal_render($element);
+  return $output;
 }
 
 /**
@@ -1620,6 +1658,7 @@ function _decisions_translate_form_date(
  * @param $format The date() format to apply to the timestamp.
  * @param $timestamp The GMT timestamp value.
  * @param $offset Time zone offset to apply to the timestamp.
+ *
  * @return gmdate() formatted date value
  */
 function _decisions_mktime($hour, $minute, $second, $month, $day, $year, $offset = NULL) {
@@ -1648,6 +1687,7 @@ function _decisions_mktime($hour, $minut
  * @param $format The date() format to apply to the timestamp.
  * @param $timestamp The GMT timestamp value.
  * @param $offset Time zone offset to apply to the timestamp.
+ *
  * @return gmdate() formatted date value
  */
 function _decisions_date($format, $timestamp, $offset = NULL) {
@@ -1665,7 +1705,7 @@ function _decisions_date($format, $times
 
   // make sure we apply the site first day of the week setting for dow requests
   $result = gmdate($format, $timestamp);
-  return  $result;
+  return $result;
 }
 
 /*
@@ -1679,13 +1719,14 @@ function _decisions_randomize_options($c
   $temp_choices = $choices;
   // Put array keys from ordered choices in random order.
   $rand_keys = array_rand($choices, $num_choices);
-  
+
   // Use keys from randomized array to get data from temp variable.
   // Use key+1 because $choices is 1 based and keys in randomized array
   // are 0 based.
-  foreach($rand_keys as $key => $value) {
-    $randomized_choices[$key+1]['vote_offset'] = $temp_choices[$value]['vote_offset'];
-    $randomized_choices[$key+1]['label'] = $temp_choices[$value]['label'];    
-  }  
-  return $randomized_choices;  
+  foreach ($rand_keys as $key => $value) {
+    $randomized_choices[$key + 1]['vote_offset'] = $temp_choices[$value]['vote_offset'];
+    $randomized_choices[$key + 1]['label'] = $temp_choices[$value]['label'];
+  }
+  return $randomized_choices;
 }
+
Index: modes/ranking.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/decisions/modes/ranking.module,v
retrieving revision 1.24
diff -u -p -r1.24 ranking.module
--- modes/ranking.module	26 Oct 2009 20:49:06 -0000	1.24
+++ modes/ranking.module	4 Feb 2010 16:45:05 -0000
@@ -9,26 +9,36 @@
 
 // $Id: ranking.module,v 1.24 2009/10/26 20:49:06 anarcat Exp $
 
+
 /**
  * Implementation of hook_help()
  */
 function ranking_help($section) {
   $help = '';
   switch ($section) {
-  case 'admin/modules#description':
-    break;
-  default:
-    if ($section == 'node/add#decisions-ranking') {
-      $help = t('Creates a vote where n options are ranked from 1 to n.');
-    }
-    break;
+    case 'admin/modules#description':
+      break;
+
+    default:
+      if ($section == 'node/add#decisions-ranking') {
+        $help = t('Creates a vote where n options are ranked from 1 to n.');
+      }
+      break;
   }
   return $help;
 }
 
-function ranking_perm() { return decisions_perm(); } 
-function ranking_acces($op, $node, $account) { return decisions_access($op, $node, $account); }
-function ranking_form(&$node) { return decisions_form($node); }
+function ranking_perm() {
+  return decisions_perm();
+}
+
+function ranking_acces($op, $node, $account) {
+  return decisions_access($op, $node, $account);
+}
+
+function ranking_form(&$node) {
+  return decisions_form($node);
+}
 
 function ranking_node_info() {
   $info = array();
@@ -47,8 +57,9 @@ function ranking_node_info() {
  */
 function ranking_decisions_algorithms() {
   return array('instant runoff' => t('Instant run-off voting, also known as IVR or Alternative Voting, is an algorithm by which the candidate having the least ballots gets its votes redistributed to the other candidates. See <a href="http://en.wikipedia.org/wiki/Instant-runoff_voting">Instant runoff voting on Wikipedia</a> for more information.'),
-               'borda count' => t('Borda count is an algorithm by which each candidate gets a number of points assigned based on the number of candidates standing. See the <a href="http://en.wikipedia.org/wiki/Borda_count">Borda count article on Wikipedia</a> for more information.'),
-               'condorcet' => t('Condorcet finds the one candidate who would beat all other candidates in all possible two-person races.  In this implementation, ties are broken using Schulze method. See the <a href="http://en.wikipedia.org/wiki/Schulze_method">Schulze method article on Wikipedia</a> for more information.'));
+    'borda count' => t('Borda count is an algorithm by which each candidate gets a number of points assigned based on the number of candidates standing. See the <a href="http://en.wikipedia.org/wiki/Borda_count">Borda count article on Wikipedia</a> for more information.'),
+    'condorcet' => t('Condorcet finds the one candidate who would beat all other candidates in all possible two-person races.  In this implementation, ties are broken using Schulze method. See the <a href="http://en.wikipedia.org/wiki/Schulze_method">Schulze method article on Wikipedia</a> for more information.'),
+  );
 }
 
 /**
@@ -64,11 +75,11 @@ function ranking_decisions_voting_form(&
 
   if ($node->choice) {
     $list = array();
-    
+
     // Put options in random order if randomize option
     // selected on node create/edit form.
-    if($node->randomize) {
-      $node->choice = _decisions_randomize_options($node->choice, $node->choices); 
+    if ($node->randomize) {
+      $node->choice = _decisions_randomize_options($node->choice, $node->choices);
     }
 
     $num_choices = count($node->choice);
@@ -92,35 +103,35 @@ function ranking_decisions_voting_form(&
     }
 
     $form['choice'] = array(
-                            '#type' => 'fieldset',
-                            '#tree' => TRUE,
-                            '#title' => t('Choices'),
-                            '#description' => t('Rank the following options in your prefered order, the lower the number the better'),
-                            );
+      '#type' => 'fieldset',
+      '#tree' => TRUE,
+      '#title' => t('Choices'),
+      '#description' => t('Rank the following options in your prefered order, the lower the number the better'),
+    );
 
     foreach ($node->choice as $key => $choice) {
       if ($choice['label']) {
         $form['choice'][$key] = array(
-                                      '#type' => 'select',
-                                      '#title' => check_plain($choice['label']),
-                                      '#options' => $choices,
-                                      );
+          '#type' => 'select',
+          '#title' => check_plain($choice['label']),
+          '#options' => $choices,
+        );
       }
     }
   }
 
   $form['nid'] = array(
-                       '#type' => 'hidden',
-                       '#value' => $node->nid,
-                       '#weight' => $weight++,
-                       );
-    
+    '#type' => 'hidden',
+    '#value' => $node->nid,
+    '#weight' => $weight++,
+  );
+
   $form['vote'] = array(
-                          '#type' => 'submit',
-                          '#value' => t('Vote'),
-                          '#weight' => $weight++,
-                          );
-  
+    '#type' => 'submit',
+    '#value' => t('Vote'),
+    '#weight' => $weight++,
+  );
+
   $form['#action'] = url('node/'. $node->nid);
   return $form;
 }
@@ -134,43 +145,49 @@ function ranking_decisions_view_results(
 
   $output = '';
 
-  if ($node->algorithm == 'condorcet') { // Use this display method only if using condorcet.
+  // Use this display method only if using condorcet.
+  if ($node->algorithm == 'condorcet') {
     $rows[0][] = "";
     $options = count($node->choice);
-    for ($i = 1; $i<=$options; $i++) {
+    for ($i = 1; $i <= $options; $i++) {
       $rows[0][] = array('data' => check_plain($node->choice[$i]['label']), 'header' => 1);
     }
-    for ($i = 1; $i<=$options; $i++) {
+    for ($i = 1; $i <= $options; $i++) {
       $rows[$i][0] = array('data' => check_plain($node->choice[$i]['label']), 'header' => 1);
-      for ($j = 1; $j<=$options; $j++) {
-        if ($i==$j) {
+      for ($j = 1; $j <= $options; $j++) {
+        if ($i == $j) {
           $rows[$i][$j] = "N/A";
-        } else {
+        }
+        else {
           if ($results->matrix[$i][$j]) {
             $rows[$i][$j] = $results->matrix[$i][$j];
-          } else {
+          }
+          else {
             $rows[$i][$j] = 0;
           }
         }
       }
     }
-    
+
     $output .= theme_table(array(), $rows, array(), "The table below indicates the number of voters who preferred the row to the column.");
 
     // Display the outcome of the Schulze count.
     $output .= '<p>Results</p><ul>';
-    for ($i=1; $i<=count($results->ranking); $i++) {
+    for ($i = 1; $i <= count($results->ranking); $i++) {
       $output .= "<li><em>Round ". $i ."</em>: ". $results->ranking[$i][0] .": ";
       $first_one = TRUE;
-      for ($j=1; $j<count($results->ranking[$i]); $j++) {
-        if (!$first_one) {$output .= ", ";}
+      for ($j = 1; $j < count($results->ranking[$i]); $j++) {
+        if (!$first_one) {
+          $output .= ", ";
+        }
         $output .= check_plain($node->choice[$results->ranking[$i][$j]]['label']);
-        $first_one=FALSE;
+        $first_one = FALSE;
       }
       $output .= "</li>";
     }
     $output .= "</ul>";
-  } else {
+  }
+  else {
 
     // If no one has voted, $results = array() and thus is empty
     if (!empty($results)) {
@@ -183,7 +200,7 @@ function ranking_decisions_view_results(
 
         // Loop through all choices with this ranking
         foreach ($results->ranking[$i]['choices'] as $choice) {
-          $output .= ($first_one? '' : ', ') . check_plain($node->choice[$choice]['label']);
+          $output .= ($first_one ? '' : ', ') . check_plain($node->choice[$choice]['label']);
           $first_one = FALSE;
         }
 
@@ -204,7 +221,7 @@ function ranking_decisions_view_results(
             $round++;
           }
         }
-    
+
         $round = 1;
         $i = 0;
         if (count($results->matrix) > 0) {
@@ -214,20 +231,21 @@ function ranking_decisions_view_results(
               $rows[$i][$round] = count($a_round[$key]);
               $i++;
             }
-            $i=0;
+            $i = 0;
             $round++;
           }
         }
         $output .= theme('table', $header, $rows);
       }
     }
-  } // end condorcet else.
+  }
+  // end condorcet else.
   return $output;
 }
 
 /**
  * implementation of the format_votes() hook.
- * 
+ *
  * formats how a user's votes should be displayed.
  *
  * @returns a formatted string
@@ -236,7 +254,7 @@ function ranking_decisions_format_votes(
   $ordered_votes = array();
   foreach ($votes as $vote) {
     // Need two dimensional results (if equal rankings are allowed)
-    $ordered_votes[$vote->value][] =  check_plain($node->choice[$vote->tag]['label']);
+    $ordered_votes[$vote->value][] = check_plain($node->choice[$vote->tag]['label']);
   }
   asort($ordered_votes);
   $rankings = array();
@@ -254,14 +272,15 @@ function ranking_decisions_format_votes(
  */
 function ranking_decisions_vote($node, $form_values) {
   $votes = array();
-  foreach ( $form_values['choice'] as $choice => $rank ) {
+  foreach ($form_values['choice'] as $choice => $rank) {
     // A zero value indicates they didn't rank that choice
     if ($rank != 0) {
       $vote = array('value' => $rank,
-                    'content_type' => 'decisions',
-                    'content_id' => $node->nid, 
-                    'value_type' => 'option',
-                    'tag' => $choice);
+        'content_type' => 'decisions',
+        'content_id' => $node->nid,
+        'value_type' => 'option',
+        'tag' => $choice,
+      );
       $votes[] = $vote;
     }
   }
@@ -280,10 +299,10 @@ function ranking_decisions_vote_validate
   $ok = TRUE;
   // array used to check which values are set
   $setvalues = array();
-        
+
   $numchoices = 0;
   foreach ($node->choice as $key => $choice) {
-                
+
     // count the number of choices that are ranked
     if (!empty($form_values['choice'][$key])) {
       $numchoices++;
@@ -301,9 +320,8 @@ function ranking_decisions_vote_validate
       form_set_error('Choice_'. $key, "illegal rank for choice $key: $intvalue (min: 1, max: ". count($node->choice) .")");
       $ok = FALSE;
     }
-
   }
-        
+
   // too many choices ranked
   if ($node->maxchoices != 0 && $numchoices > $node->maxchoices) {
     form_set_error('choice', t('@num choices were selected but only @max are allowed.', array('@num' => $numchoices, '@max' => $node->maxchoices)));
@@ -318,14 +336,16 @@ function ranking_decisions_vote_validate
   }
 
   // Check that multiple choices are not set to the same value
-  if ($node->algorithm != "condorcet") { // condorcet uses ties.
+  // condorcet uses ties.
+  if ($node->algorithm != "condorcet") {
     foreach ($setvalues as $val => $count) {
       if ($val != 0 && $count > 1) {
         form_set_error('choice', t('Multiple choices given the rank of @val.', array('@val' => $val)));
         $ok = FALSE;
       }
     }
-  } // end condorcet if.
+  }
+  // end condorcet if.
 
 
   return $ok;
@@ -337,11 +357,11 @@ function ranking_decisions_vote_validate
 
 /**
  * Calculate the results for a ranking decision based on the algorithm
- * 
+ *
  * @param $node
  *      The node object for the current decision
  *
- * @return 
+ * @return
  *      Should return an object that include the following attributes
  *   -results : 2d array listing the aggregate preference, including ties
  *   -rounds : 2d array listing the per-choice vote count for each round and
@@ -362,21 +382,20 @@ function _ranking_decisions_calculate_re
 
 /**
  * Calculate the results using borda count
- * 
+ *
  * @param $node
  *      The node object for the current decision
  *
- * @return 
+ * @return
  *      Should return an object that include the following attributes
  *   -results : 2d array listing the aggregate preference, including ties
  *   -rounds : 2d array listing the per-choice vote count for each round and
  *             a status message indicating who was eliminated
  *   -totalVoters : the total number of voters who participated
  */
-
 function _decisions_calculate_bordacount($node) {
   $votes = _decisions_votes($node);
-  
+
   if (count($votes) == 0) {
     // no votes yet
     return array();
@@ -410,8 +429,8 @@ function _decisions_calculate_bordacount
       $vote_value = max($total_choices - $ranking, 0);
       if (!array_key_exists($choice, $choice_votes)) {
         $choice_votes[$choice] = 0;
-      }        
-      $choice_votes[$choice] +=  $vote_value;
+      }
+      $choice_votes[$choice] += $vote_value;
     }
   }
 
@@ -419,9 +438,9 @@ function _decisions_calculate_bordacount
   arsort($choice_votes);
 
   // Figure out the final ranking
-  $ranking = array();
+  $ranking        = array();
   $previous_total = -1;
-  $cur_result = -1;
+  $cur_result     = -1;
 
   foreach ($choice_votes as $choice => $total) {
     if ($total != $previous_total) {
@@ -430,7 +449,7 @@ function _decisions_calculate_bordacount
     }
     $ranking[$cur_result]['choices'][] = $choice;
     $ranking[$cur_result]['rawscore'] = $total;
-    $ranking[$cur_result]['viewscore'] = $total .' point'. ($total == 1? '' : 's');
+    $ranking[$cur_result]['viewscore'] = $total .' point'. ($total == 1 ? '' : 's');
   }
 
   $total_votes = count($user_votes);
@@ -440,21 +459,19 @@ function _decisions_calculate_bordacount
   return $result_obj;
 }
 
-
 /**
  * Calculate the results using instant-runoff voting
- * 
+ *
  * @param $node
  *      The node object for the current decision
  *
- * @return 
+ * @return
  *      Should return an object that include the following attributes
  *   -results : 2d array listing the aggregate preference, including ties
  *   -rounds : 2d array listing the per-choice vote count for each round and
  *             a status message indicating who was eliminated
  *   -totalVoters : the total number of voters who participated
  */
-
 function _decisions_calculate_instantrunoff($node) {
   $votes = _decisions_votes($node);
 
@@ -495,6 +512,8 @@ function _decisions_calculate_instantrun
 
 
 
+
+
   // log of 1st-place votes per choice in each round
   $round_log = array();
 
@@ -502,10 +521,10 @@ function _decisions_calculate_instantrun
   $reverse_ranking = array();
 
 
-        
+
   // If we eliminate one choice per round and have n choices, we should
   // not be able to do more than n - 1 rounds
-  $max_rounds = count($node->choice); 
+  $max_rounds = count($node->choice);
   for ($round = 0; $round < $max_rounds; $round++) {
 
     // Initialize cur_round
@@ -515,7 +534,7 @@ function _decisions_calculate_instantrun
       $cur_round[$chi] = array();
     }
 
-                
+
     // Loop through each user
     foreach ($user_votes as $key => $user_vote) {
       // $user_vote[0] contains the user's first remaining preference
@@ -550,13 +569,15 @@ function _decisions_calculate_instantrun
 
       if ($num_votes > $max_votes) {
         $max_votes = $num_votes;
-        $cur_winner = $ch; // store current winner in case it has a majority
+        // store current winner in case it has a majority
+        $cur_winner = $ch;
       }
 
       // This choice has already been eliminated (theoretically)
       // so don't count it as the minimum
       if ($num_votes == 0) {
-        $num_discarded++; // probably don't need this variable any more
+        // probably don't need this variable any more
+        $num_discarded++;
       }
       else if ($num_votes != 0 && ($num_votes < $min_votes || $min_votes == -1)) {
         $min_votes = $num_votes;
@@ -567,14 +588,14 @@ function _decisions_calculate_instantrun
     // Note: we use count($user_votes) because some users may have incomplete
     // ballots and may have already had all of their choices eliminated
     if ($max_votes > count($user_votes) / 2) {
-                
+
       // Prune out the winning choice if it's still in there
       if (isset($cur_round[$cur_winner])) {
         unset($cur_round[$cur_winner]);
       }
 
       // Keep computing until we figure out all final rankings
-      while (count($cur_round)  > 0) {
+      while (count($cur_round) > 0) {
         // Loop through non-winning choices
         $current_place = array();
         $min = -1;
@@ -584,7 +605,8 @@ function _decisions_calculate_instantrun
             unset($cur_round[$ch]);
           }
           else if ($min == -1
-                   || count($choice_votes) < $min) {
+            || count($choice_votes) < $min
+          ) {
             // New minimum
             $current_place = array($ch);
             $min = count($choice_votes);
@@ -601,7 +623,7 @@ function _decisions_calculate_instantrun
         // choices had no first-place votes and were eliminated
         // at the beginning
         if (count($current_place) > 0) {
-          $reverse_ranking[]['choices'] = $current_place; 
+          $reverse_ranking[]['choices'] = $current_place;
           // Remove all choices that had the minimum
           foreach ($current_place as $ch_key) {
             unset($cur_round[$ch_key]);
@@ -623,7 +645,7 @@ function _decisions_calculate_instantrun
       $result_obj->ranking = array_reverse($reverse_ranking);
       return $result_obj;
     }
-                
+
     // Since we're still here, no one has won, so eliminate one of the
     // choices with the lowest number of votes.
 
@@ -642,7 +664,7 @@ function _decisions_calculate_instantrun
     //. strval($min_choices[$round_loser])
     //. ' (min = ' . $min_votes . ') ' . count($cur_round));
     $reverse_ranking[]['choices'] = array($min_choices[$round_loser]);
-                
+
     // Loop through the users who voted for the loser and redistribute
     foreach ($cur_round[$min_choices[$round_loser]] as $user_key) {
       // Remove their current first preference
@@ -651,9 +673,10 @@ function _decisions_calculate_instantrun
       // Keep eliminating first preference until we run out or find an choice
       // that hasn't been eliminated
       while ($cur_round[$user_votes[$user_key][0]] == array()
-             && count($user_votes[$user_key]) > 0) {
-          array_shift($user_votes[$user_key]);
-        }
+        && count($user_votes[$user_key]) > 0
+      ) {
+        array_shift($user_votes[$user_key]);
+      }
 
       // If they have no more preferences, remove from list for simplicity
       if (count($user_votes[$user_key]) == 0) {
@@ -666,24 +689,23 @@ function _decisions_calculate_instantrun
   $result_obj->matrix = $round_log;
   $result_obj->total_votes = $total_votes;
   return $result_obj;
-
 }
 
 /**
  * Calculate the results using condorcet voting.
- * 
+ *
  * @param $node
  *      The node object for the current decision
  *
- * @return 
+ * @return
  *      Should return an object that include the following attributes
  *   -matrix: 2d array listing the aggregate preferences
  *   -ranking : 2d array listing the results of the Schulze count.
  *   -total_votes : the total number of voters who participated
  */
-function _decisions_calculate_condorcet ($node) {
+function _decisions_calculate_condorcet($node) {
   $votes = _decisions_votes($node);
-  
+
   if (count($votes) == 0) {
     // no votes yet
     return array();
@@ -703,7 +725,8 @@ function _decisions_calculate_condorcet 
       $key = $vote['uid'];
     }
 
-    $user_votes[$key][$vote['tag']] = $vote['value']; // TAG and Value had to be reversed here to allow for ties.
+    // TAG and Value had to be reversed here to allow for ties.
+    $user_votes[$key][$vote['tag']] = $vote['value'];
   }
 
   $choice_votes = array();
@@ -717,31 +740,42 @@ function _decisions_calculate_condorcet 
     $choice_ranks = array();
     // Go through all the node choices, and find their ranking.
     for ($choice = 1; $choice <= $total_choices; $choice++) {
-      $ranking = 256; // default value applied to anything that isn't ranked.  Tied for last.  Problem if there were more than 256 options.
-      if (array_key_exists($choice, $user_vote)) { $ranking = $user_vote[$choice]; } // Pull the ranking from the vote.
-      $choice_ranks[$choice] = 0 - $ranking; // We inverse the numerical values  so a high ranking is bad, negatives work fine.
+      // default value applied to anything that isn't ranked.  Tied for last.  Problem if there were more than 256 options.
+      $ranking = 256;
+      if (array_key_exists($choice, $user_vote)) {
+        $ranking = $user_vote[$choice];
+        // Pull the ranking from the vote.
+      }
+      // We inverse the numerical values  so a high ranking is bad, negatives work fine.
+      $choice_ranks[$choice] = 0 - $ranking;
     }
     // Loop through to compare every choice.
-    for ($choice_A = 1; $choice_A <= $total_choices-1; $choice_A++) {
+    for ($choice_A = 1; $choice_A <= $total_choices - 1; $choice_A++) {
       // Loop through all choices to which choice_A has not been compared, excluding itself.
-      for ($choice_B = $choice_A+1; $choice_B <= $total_choices; $choice_B++) {
+      for ($choice_B = $choice_A + 1; $choice_B <= $total_choices; $choice_B++) {
         // Figure out where to put the points.
-        if ($choice_ranks[$choice_A]>$choice_ranks[$choice_B]) {
+        if ($choice_ranks[$choice_A] > $choice_ranks[$choice_B]) {
           // Indicate A beat B
           $choice_votes[$choice_A][$choice_B] = $choice_votes[$choice_A][$choice_B] + 1;
           $choice_votes[$choice_B][$choice_A] = $choice_votes[$choice_B][$choice_A] + 0;
-        } else if ($choice_ranks[$choice_B]>$choice_ranks[$choice_A]) {
+        }
+        else if ($choice_ranks[$choice_B] > $choice_ranks[$choice_A]) {
           // Indicate B beat A
           $choice_votes[$choice_B][$choice_A] = $choice_votes[$choice_B][$choice_A] + 1;
           $choice_votes[$choice_A][$choice_B] = $choice_votes[$choice_A][$choice_B] + 0;
-        } else {
+        }
+        else {
           // Indicate a Tie
           $choice_votes[$choice_B][$choice_A] = $choice_votes[$choice_B][$choice_A] + 0.5;
           $choice_votes[$choice_A][$choice_B] = $choice_votes[$choice_A][$choice_B] + 0.5;
-        } // end if
-      } // end for
-    } // end for
-  } // end foreach
+        }
+        // end if
+      }
+      // end for
+    }
+    // end for
+  }
+  // end foreach
 
   //Return the results.
   $result_obj->matrix = $choice_votes;
@@ -751,7 +785,7 @@ function _decisions_calculate_condorcet 
 }
 
 function _compare_beatpaths($a, $b) {
-  return strcmp($b[2],$a[2]);
+  return strcmp($b[2], $a[2]);
 }
 
 /**
@@ -762,11 +796,11 @@ function _compare_beatpaths($a, $b) {
  *
  * @return
  *    Should return an array appropriate for the condorcet display method.
- *    
+ *
  * Note: There is another heuristic where strongest
  * beatpaths are locked in, and weaker beatpaths that conflict with them are ignored.
  * From my understanding, that would eliminate entirely the need for the second half of the
- * Floyd-Warshall algorithm.  
+ * Floyd-Warshall algorithm.
  * I think that would be much faster to implement and run, but I would want to satisfy myself that
  * the results were the same either way, so I went for the hard way first.
  */
@@ -775,23 +809,24 @@ function _decisions_shultz($matrix) {
   $candidates = count($matrix);
   // Create a matrix of path strengths. Based on the Floyd-Warshall algorithm.
   $strongest_paths = array();
-  for ($i = 1; $i<=$candidates; $i++) {
-    for ($j = 1; $j<=$candidates; $j++) {
-      if ($i!=$j) {
-      if ($matrix[$i][$j]>$matrix[$j][$i]) {
+  for ($i = 1; $i <= $candidates; $i++) {
+    for ($j = 1; $j <= $candidates; $j++) {
+      if ($i != $j) {
+        if ($matrix[$i][$j] > $matrix[$j][$i]) {
           $strongest_paths[$i][$j] = $matrix[$i][$j];
-      } else {
+        }
+        else {
           $strongest_paths[$i][$j] = 0;
-      }
+        }
       }
     }
   }
-  for ($i = 1; $i<=$candidates; $i++) {
-    for ($j = 1; $j<=$candidates; $j++) {
+  for ($i = 1; $i <= $candidates; $i++) {
+    for ($j = 1; $j <= $candidates; $j++) {
       if ($i != $j) {
-        for ($k = 1; $k<=$candidates; $k++) {
-          if (($j!=$k) && ($i != $k)) {
-            $strongest_paths[$j][$k] = max ($strongest_paths[$j][$k], min ($strongest_paths[$j][$i], $strongest_paths[$i][$k]));
+        for ($k = 1; $k <= $candidates; $k++) {
+          if (($j != $k) && ($i != $k)) {
+            $strongest_paths[$j][$k] = max($strongest_paths[$j][$k], min($strongest_paths[$j][$i], $strongest_paths[$i][$k]));
           }
         }
       }
@@ -799,33 +834,35 @@ function _decisions_shultz($matrix) {
   }
   // Create an array of for,against,strength values from the strongest_paths array to allow sorting.
   $beatpath = array();
-  for ($i = 1; $i<=$candidates; $i++) {
-    for ($j = 1; $j<=$candidates; $j++) {
-      if ($i!=$j && $strongest_paths[$i][$j] != 0) {
+  for ($i = 1; $i <= $candidates; $i++) {
+    for ($j = 1; $j <= $candidates; $j++) {
+      if ($i != $j && $strongest_paths[$i][$j] != 0) {
         $beatpath[] = array($i, $j, $strongest_paths[$i][$j]);
-    }
+      }
     }
   }
   // sort the array so that we're starting with the strongest links.
-  usort($beatpath,"_compare_beatpaths");
-  
-  $round_count = 0;
+  usort($beatpath, "_compare_beatpaths");
+
+  $round_count         = 0;
   $original_candidates = $candidates;
-  $orig_beatpath = count($beatpath);
-  $pathed_out = array(); // 1 indicates that the candidate has been pathed out. 2 indicates their beatpaths have been removed.
-  while ($candidates>1 && count($beatpath)>0) {
+  $orig_beatpath       = count($beatpath);
+  // 1 indicates that the candidate has been pathed out. 2 indicates their beatpaths have been removed.
+  $pathed_out = array();
+  while ($candidates > 1 && count($beatpath) > 0) {
     // Find if there are any candidates that have been pathed out.
     // Pathed out means that A has a path to beat B, but B has no path to beat A, so B is eliminated.
     $round_count++;
-    if ($round_count > $original_candidates) { // We have a problem.
+    // We have a problem.
+    if ($round_count > $original_candidates) {
       $broken = TRUE;
       break;
     }
-    for ($i=1; $i<$original_candidates; $i++) {
-      for ($j=$i+1; $j<=$original_candidates; $j++) {
+    for ($i = 1; $i < $original_candidates; $i++) {
+      for ($j = $i + 1; $j <= $original_candidates; $j++) {
         $forward = FALSE;
         $reverse = FALSE;
-        for ($k=0; $k<count($beatpath); $k++){
+        for ($k = 0; $k < count($beatpath); $k++) {
           if (($beatpath[$k][0] == $i) && ($beatpath[$k][1] == $j)) {
             $forward = TRUE;
           }
@@ -842,17 +879,20 @@ function _decisions_shultz($matrix) {
       }
     }
     $pathed_out_count = 0;
-    for ($i=1; $i<=$original_candidates; $i++) {
-      if ($pathed_out[$i] == 1) {$pathed_out_count++;}
+    for ($i = 1; $i <= $original_candidates; $i++) {
+      if ($pathed_out[$i] == 1) {
+        $pathed_out_count++;
+      }
     }
-    if ($pathed_out_count>0) { // Some candidate was eliminated this round.
+    // Some candidate was eliminated this round.
+    if ($pathed_out_count > 0) {
       // Remove all of the beatpaths associated with them.
       $ranking[$round_count][] = "Eliminated";
-      for ($i=1; $i<=$original_candidates; $i++) {
+      for ($i = 1; $i <= $original_candidates; $i++) {
         if ($pathed_out[$i] == 1) {
           $ranking[$round_count][] = $i;
           $candidates--;
-          for ($j=0; $j<$orig_beatpath; $j++) {
+          for ($j = 0; $j < $orig_beatpath; $j++) {
             if (($beatpath[$j][0]) == $i || ($beatpath[$j][1] == $i)) {
               unset($beatpath[$j]);
             }
@@ -860,13 +900,15 @@ function _decisions_shultz($matrix) {
           $pathed_out[$i] = 2;
         }
       }
-    } else { // No candidates were eliminated this round.  There is a Cyclical Tie.
+      // No candidates were eliminated this round.  There is a Cyclical Tie.
+    }
+    else {
       // Drop all the beatpaths tied for weakest.
-      $index = count($beatpath)-1;
+      $index = count($beatpath) - 1;
       $value = $beatpath[$index][2];
       do {
         unset($beatpath[$index]);
-        $new = $beatpath[$index-1][2];
+        $new = $beatpath[$index - 1][2];
         $index--;
       } while ($new == $value);
       $ranking[$round_count][] = "Cyclical Tie";
@@ -875,14 +917,15 @@ function _decisions_shultz($matrix) {
   // Everyone left is tied for the win.
   $round_count++;
   $ranking[$round_count][] = "Winner";
-  for ($i=1; $i<=$original_candidates; $i++) {
+  for ($i = 1; $i <= $original_candidates; $i++) {
     if (!$pathed_out[$i]) {
       $ranking[$round_count][] = $i;
       $winner_count++;
     }
   }
-  if ($winner_count>1) {
+  if ($winner_count > 1) {
     $ranking[$round_count][0] = "Tie for Win";
   }
   return $ranking;
 }
+
Index: modes/selection.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/decisions/modes/selection.install,v
retrieving revision 1.2
diff -u -p -r1.2 selection.install
--- modes/selection.install	5 Dec 2008 03:48:02 -0000	1.2
+++ modes/selection.install	4 Feb 2010 16:45:05 -0000
@@ -2,22 +2,23 @@
 
 /**
  * @file
- * 
+ *
  * .install file for the selection mode module
  */
 
 // $Id: selection.install,v 1.2 2008/12/05 03:48:02 anarcat Exp $
 
+
 /**
  * change the polls to selection on upgrade
  */
 function selection_update_1() {
-  switch ($GLOBALS['db_type']) {         
-  case 'mysql':          
-  case 'mysqli':
-    $items[] = update_sql("UPDATE {node} SET type='decisions_selection' WHERE type='decisions_poll';");
-    $items[] = update_sql("UPDATE {decisions} SET mode='selection' WHERE mode='poll';");
-    break;
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      $items[] = update_sql("UPDATE {node} SET type='decisions_selection' WHERE type='decisions_poll';");
+      $items[] = update_sql("UPDATE {decisions} SET mode='selection' WHERE mode='poll';");
+      break;
   }
   return $items;
 }
Index: modes/selection.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/decisions/modes/selection.module,v
retrieving revision 1.16
diff -u -p -r1.16 selection.module
--- modes/selection.module	3 Feb 2010 02:18:55 -0000	1.16
+++ modes/selection.module	4 Feb 2010 16:45:05 -0000
@@ -11,13 +11,14 @@
 function selection_help($section) {
   $help = "";
   switch ($section) {
-  case 'admin/modules#description':
-    break;
-  default:
-    if ($section == 'node/add#decisions-selection') {
-      $help = t('Creates a decision where the user selects one or many options.');
-    }
-    break;
+    case 'admin/modules#description':
+      break;
+
+    default:
+      if ($section == 'node/add#decisions-selection') {
+        $help = t('Creates a decision where the user selects one or many options.');
+      }
+      break;
   }
   return $help;
 }
@@ -26,10 +27,17 @@ function selection_node_info() {
   return array('decisions_selection' => array('name' => t('Decisions - selection'), 'module' => 'decisions', 'description' => t('Creates a decision where the user selects one or many options.')));
 }
 
-function selection_perm() { return decisions_perm(); } 
-function selection_acces($op, $node, $account) { return decisions_access($op, $node, $account); }
-function selection_form(&$node) { return decisions_form($node); }
+function selection_perm() {
+  return decisions_perm();
+}
 
+function selection_acces($op, $node, $account) {
+  return decisions_access($op, $node, $account);
+}
+
+function selection_form(&$node) {
+  return decisions_form($node);
+}
 
 /**
  * Implementation of the decisions_algorithms() hook
@@ -40,7 +48,7 @@ function selection_decisions_algorithms(
 
 /**
  * Implementation of the decisions_voting_hook_form() hook for the selection module.
- * 
+ *
  * This creates a list of choices to allow the user to vote on choices.
  */
 function selection_decisions_voting_form(&$node, $teaser, $page) {
@@ -49,8 +57,8 @@ function selection_decisions_voting_form
 
     // Put options in random order if randomize option
     // selected on node create/edit form.
-    if($node->randomize) {
-      $node->choice = _decisions_randomize_options($node->choice, $node->choices); 
+    if ($node->randomize) {
+      $node->choice = _decisions_randomize_options($node->choice, $node->choices);
     }
 
     if ($node->maxchoices == 1) {
@@ -62,11 +70,11 @@ function selection_decisions_voting_form
       }
 
       $form['choice'] = array(
-                              '#type' => 'radios',
-                              '#title' => $page ? '' : check_plain($node->title),
-                              '#default_value' => -1,
-                              '#options' => $list
-                              );
+        '#type' => 'radios',
+        '#title' => $page ? '' : check_plain($node->title),
+        '#default_value' => -1,
+        '#options' => $list,
+      );
     }
     else {
       // approval voting
@@ -76,20 +84,20 @@ function selection_decisions_voting_form
         }
       }
       $form['choice'] = array(
-                              '#type' => 'checkboxes',
-                              '#title' => $page ? '' : check_plain($node->title),
-                              '#options' => $list,
-                              );
+        '#type' => 'checkboxes',
+        '#title' => $page ? '' : check_plain($node->title),
+        '#options' => $list,
+      );
     }
   }
   $form['nid'] = array(
-                       '#type' => 'hidden',
-                       '#value' => $node->nid
-                       );
+    '#type' => 'hidden',
+    '#value' => $node->nid,
+  );
   $form['vote'] = array(
-                        '#type' => 'submit',
-                        '#value' => t('Vote')
-                        );
+    '#type' => 'submit',
+    '#value' => t('Vote'),
+  );
   $form['#action'] = url('node/'. $node->nid);
   return $form;
 }
@@ -110,7 +118,7 @@ function selection_decisions_view_result
 
     // approval
     $voteval = $result['tag'];
-    
+
     if (!array_key_exists($voteval, $votes)) {
       $votes[$voteval] = 0;
     }
@@ -125,7 +133,7 @@ function selection_decisions_view_result
   }
   // sort the votes
   arsort($votes);
- 
+
   $total_votes = array_sum($votes);
   if ($node->choice && $total_votes > 0) {
     // TODO: Those <div>s and <br />s should be in a theme function. First collect all the data in a structure, then theme it.
@@ -133,11 +141,11 @@ function selection_decisions_view_result
     $output .= '<div class="poll">';
     $max_votes = 0;
     foreach ($votes as $i => $vote) {
-      $max_votes = ( $vote > $max_votes ? $vote : $max_votes );
+      $max_votes = ($vote > $max_votes ? $vote : $max_votes);
     }
     foreach ($votes as $i => $vote) {
       $percentage = round(100 * $vote / $total_votes, 0);
-      $output .= theme('decisions_bar',  check_plain($node->choice[$i]['label']), $vote, $total_votes, $max_votes);
+      $output .= theme('decisions_bar', check_plain($node->choice[$i]['label']), $vote, $total_votes, $max_votes);
     }
     $output .= '</div>';
   }
@@ -148,7 +156,7 @@ function selection_decisions_view_result
 
 /**
  * implementation of the format_votes() hook.
- * 
+ *
  * formats how a user's votes should be displayed.
  *
  * @returns a formatted string
@@ -164,7 +172,6 @@ function selection_decisions_format_vote
   return implode(', ', $unordered_votes);
 }
 
-
 /**
  * implementation of the submit() hook
  *
@@ -175,11 +182,12 @@ function selection_decisions_vote($node,
   if ($node->maxchoices == 1) {
     // plurality voting
     $vote = array(
-                  'value' => 1,
-                  'tag' => $form_values['choice'],
-                  'value_type' => 'option',
-                  'content_type' => 'decisions',
-                  'content_id' => $node->nid);
+      'value' => 1,
+      'tag' => $form_values['choice'],
+      'value_type' => 'option',
+      'content_type' => 'decisions',
+      'content_id' => $node->nid,
+    );
     $votes[] = $vote;
   }
   else {
@@ -187,11 +195,11 @@ function selection_decisions_vote($node,
     foreach ($node->choice as $key => $choice) {
       if (isset($form_values['choice'][$key]) && $form_values['choice'][$key]) {
         $vote = array(
-                      'value' => 1,
-                      'value_type' => 'option',
-                      'tag' => $key,
-                      'content_type' => 'decisions',
-                      'content_id' => $node->nid
+          'value' => 1,
+          'value_type' => 'option',
+          'tag' => $key,
+          'content_type' => 'decisions',
+          'content_id' => $node->nid,
         );
         $votes[] = $vote;
       }
@@ -234,12 +242,14 @@ function selection_decisions_vote_valida
         $numchoices++;
       }
     }
-        
+
     // too many choices ranked
     if ($node->maxchoices != 0 && $numchoices > $node->maxchoices) {
       form_set_error('choice',
-                     t('%num choices were selected but only %max are allowed.',
-                       array('%num' => $numchoices, '%max' => $node->maxchoices)));
+        t('%num choices were selected but only %max are allowed.',
+          array('%num' => $numchoices, '%max' => $node->maxchoices)
+        )
+      );
       $ok = FALSE;
     }
 
