Loading README.txt +19 −0 Changes for README.txt: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Advanced Poll ----- Introduction ------------ Advanced Poll is a replacement to Drupal's poll module and provides multiple voting systems, decision-making tools, and management options. - Voting systems: Basic polls, Approval Voting, Borda Count, and Instant-Runoff Voting. - Vote management: view each user's vote, delete all votes, or restrict the poll to a list of users. - Time management: schedule when to open or close the poll, and choose when to show results. - Choice management: write-in choices, and support for HTML (or other input filter). - Usability: fast Ajax interaction and customizable default settings. - Migration: convert regular Drupal polls into Advanced Polls. Dependencies: Voting API, Date API. INSTALLATION: ------------ Download and enable the module as usual. advpoll.install +12 −4 Changes for advpoll.install: 12 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -137,7 +137,7 @@ function advpoll_uninstall() { * http://api.drupal.org/api/function/field_delete_field/7 */ $instances = field_info_instances('node', 'advpoll'); foreach ($instances as $instance_name => $instance) { foreach ($instances as $instance) { field_delete_instance($instance); } Loading @@ -153,8 +153,7 @@ function advpoll_uninstall() { // Delete precision and rounding method variables. variable_del('advpoll_percentage_precision'); variable_del('percentage_rounding_method'); variable_del('advpoll_percentage_rounding_method'); } /** Loading @@ -172,8 +171,8 @@ function _advpoll_installed_fields() { return array( // -- Choices field -- 'advpoll_choice' => array( 'active' => '1', 'cardinality' => '-1', 'active' => '1', 'deleted' => '0', 'entity_types' => array(), 'field_name' => 'advpoll_choice', Loading Loading @@ -858,3 +857,12 @@ function advpoll_update_7004() { function advpoll_update_7006() { menu_rebuild(); } /** * Fix variable name for coding standards. */ function advpoll_update_7007() { $method = variable_get('percentage_rounding_method', 'round'); variable_set('advpoll_percentage_rounding_method', $method); variable_del('percentage_rounding_method'); } advpoll.module +36 −11 Changes for advpoll.module: 36 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -173,7 +173,10 @@ function advpoll_node_view($node, $view_mode) { if ($node->type == 'advpoll') { $data = advpoll_get_data($node); if ($data->behavior == 'approval' || $data->behavior == 'pool') { drupal_add_css(drupal_get_path('module', 'advpoll') . '/css/advpoll.css', array('group' => CSS_DEFAULT, 'every_page' => TRUE)); drupal_add_css(drupal_get_path('module', 'advpoll') . '/css/advpoll.css', array( 'group' => CSS_DEFAULT, 'every_page' => TRUE )); // Use existing weight if defined. $weight = 1; if (!empty($node->content['advpoll_choice']['#weight'])) { Loading @@ -185,11 +188,17 @@ function advpoll_node_view($node, $view_mode) { if (advpoll_user_eligibility($node)) { // Print out voting form. $voteform = drupal_get_form('advpoll_choice_form', $node); $node->content['advpoll_choice'] = array(0 => $voteform, '#weight' => $weight); $node->content['advpoll_choice'] = array( 0 => $voteform, '#weight' => $weight ); } else { $results = advpoll_display_results($node->nid, $data); $node->content['advpoll_choice'] = array('#markup' => $results, '#weight' => $weight); $node->content['advpoll_choice'] = array( '#markup' => $results, '#weight' => $weight ); } } } Loading Loading @@ -299,9 +308,8 @@ function advpoll_node_presave($node) { } $count = count($choices); /* Set up for the benefit of Devel to ensure values present a * normal/average type of poll setting. */ // Set up for the benefit of Devel to ensure values present a // normal/average type of poll setting. if (isset($node->devel_generate)) { $node->advpoll_dates[$lang][0]['value'] = date('Y-m-d 00:00:00', time()); $node->advpoll_dates[$lang][0]['value2'] = date('Y-m-d 00:00:00', time() + (60 * 60 * 24 * 30)); Loading @@ -328,7 +336,7 @@ function advpoll_node_presave($node) { } // Check for vote results for this node. if (isset($nid)) { if (isset($node->nid)) { $criteria = array(); $criteria['entity_id'] = $node->nid; $criteria['entity_type'] = 'node'; Loading Loading @@ -532,7 +540,6 @@ function advpoll_display_results($nid, $data, $page = 0) { * * @return array * A keyed array of voting totals for each choice. * */ function advpoll_update_choices($choices, $results) { $choice_set = array(); Loading @@ -556,9 +563,8 @@ function advpoll_update_choices($choices, $results) { unset($choice_set[$result['index']]); } /* If there are still items in this array, it means they have no votes * associated with them but they still need to be rendered. */ // If there are still items in this array, it means they have no votes // associated with them but they still need to be rendered. if (count($choice_set) > 0) { foreach ($choice_set as $key => $choice) { $final[] = array( Loading Loading @@ -1178,3 +1184,22 @@ function advpoll_views_api() { 'path' => drupal_get_path('module', 'advpoll') . '/views', ); } /** * Round value with advpoll_percentage_rounding_method * * @param float $percentage * @param int $precision * @return float */ function advpoll_round($percentage, $precision = 0) { $rounding_method = variable_get('advpoll_percentage_rounding_method', 'round'); if (is_callable($rounding_method)) { $result = $rounding_method($percentage, $precision); } else { $result = $percentage; } return $result; } advpoll_converter/advpoll_converter.admin.inc +1 −2 Changes for advpoll_converter/advpoll_converter.admin.inc: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -184,7 +184,6 @@ function _advpoll_converter_create_nodes($nids) { array(':nid' => $record->nid) ); $votes = array(); foreach ($poll_votes as $row) { $votes = array( 'entity_type' => 'node', Loading @@ -196,7 +195,7 @@ function _advpoll_converter_create_nodes($nids) { 'timestamp' => $row->timestamp, ); votingapi_set_votes($votes, $criteria = NULL); votingapi_set_votes($votes); } drupal_set_message(t('A new advanced poll node was created for %title.', array('%title' => $record->title))); } Loading advpoll_field/advpoll_field.module +2 −6 Changes for advpoll_field/advpoll_field.module: 2 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -49,12 +49,10 @@ function advpoll_field_field_formatter_info() { function advpoll_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); switch ($display['type']) { case 'advpoll_choice': if ($display['type'] == 'advpoll_choice') { foreach ($items as $delta => $item) { $element[$delta]['#markup'] = filter_xss($item['choice'], $allowed = array('em', 'strong', 'a', 'b', 'i')); $element[$delta]['#markup'] = filter_xss($item['choice'], array('em', 'strong', 'a', 'b', 'i')); } break; } return $element; Loading @@ -76,7 +74,6 @@ function advpoll_field_field_widget_info() { /** * Implements hook_field_widget_form(). * */ function advpoll_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { $element += array( Loading Loading @@ -116,7 +113,6 @@ function advpoll_field_field_widget_form(&$form, &$form_state, $field, $instance */ function advpoll_field_field_views_data($field) { // An attempt to make a Views-friendly display. $views_fields = field_views_field_default_views_data($field); foreach ($views_fields as $key => $data) { $views_fields[$key][$field['field_name'] . '_choice']['argument']['name field'] = $field['field_name'] . '_choice'; Loading Loading
README.txt +19 −0 Changes for README.txt: 19 added lines, 0 removed lines. Original line number Diff line number Diff line Advanced Poll ----- Introduction ------------ Advanced Poll is a replacement to Drupal's poll module and provides multiple voting systems, decision-making tools, and management options. - Voting systems: Basic polls, Approval Voting, Borda Count, and Instant-Runoff Voting. - Vote management: view each user's vote, delete all votes, or restrict the poll to a list of users. - Time management: schedule when to open or close the poll, and choose when to show results. - Choice management: write-in choices, and support for HTML (or other input filter). - Usability: fast Ajax interaction and customizable default settings. - Migration: convert regular Drupal polls into Advanced Polls. Dependencies: Voting API, Date API. INSTALLATION: ------------ Download and enable the module as usual.
advpoll.install +12 −4 Changes for advpoll.install: 12 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -137,7 +137,7 @@ function advpoll_uninstall() { * http://api.drupal.org/api/function/field_delete_field/7 */ $instances = field_info_instances('node', 'advpoll'); foreach ($instances as $instance_name => $instance) { foreach ($instances as $instance) { field_delete_instance($instance); } Loading @@ -153,8 +153,7 @@ function advpoll_uninstall() { // Delete precision and rounding method variables. variable_del('advpoll_percentage_precision'); variable_del('percentage_rounding_method'); variable_del('advpoll_percentage_rounding_method'); } /** Loading @@ -172,8 +171,8 @@ function _advpoll_installed_fields() { return array( // -- Choices field -- 'advpoll_choice' => array( 'active' => '1', 'cardinality' => '-1', 'active' => '1', 'deleted' => '0', 'entity_types' => array(), 'field_name' => 'advpoll_choice', Loading Loading @@ -858,3 +857,12 @@ function advpoll_update_7004() { function advpoll_update_7006() { menu_rebuild(); } /** * Fix variable name for coding standards. */ function advpoll_update_7007() { $method = variable_get('percentage_rounding_method', 'round'); variable_set('advpoll_percentage_rounding_method', $method); variable_del('percentage_rounding_method'); }
advpoll.module +36 −11 Changes for advpoll.module: 36 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -173,7 +173,10 @@ function advpoll_node_view($node, $view_mode) { if ($node->type == 'advpoll') { $data = advpoll_get_data($node); if ($data->behavior == 'approval' || $data->behavior == 'pool') { drupal_add_css(drupal_get_path('module', 'advpoll') . '/css/advpoll.css', array('group' => CSS_DEFAULT, 'every_page' => TRUE)); drupal_add_css(drupal_get_path('module', 'advpoll') . '/css/advpoll.css', array( 'group' => CSS_DEFAULT, 'every_page' => TRUE )); // Use existing weight if defined. $weight = 1; if (!empty($node->content['advpoll_choice']['#weight'])) { Loading @@ -185,11 +188,17 @@ function advpoll_node_view($node, $view_mode) { if (advpoll_user_eligibility($node)) { // Print out voting form. $voteform = drupal_get_form('advpoll_choice_form', $node); $node->content['advpoll_choice'] = array(0 => $voteform, '#weight' => $weight); $node->content['advpoll_choice'] = array( 0 => $voteform, '#weight' => $weight ); } else { $results = advpoll_display_results($node->nid, $data); $node->content['advpoll_choice'] = array('#markup' => $results, '#weight' => $weight); $node->content['advpoll_choice'] = array( '#markup' => $results, '#weight' => $weight ); } } } Loading Loading @@ -299,9 +308,8 @@ function advpoll_node_presave($node) { } $count = count($choices); /* Set up for the benefit of Devel to ensure values present a * normal/average type of poll setting. */ // Set up for the benefit of Devel to ensure values present a // normal/average type of poll setting. if (isset($node->devel_generate)) { $node->advpoll_dates[$lang][0]['value'] = date('Y-m-d 00:00:00', time()); $node->advpoll_dates[$lang][0]['value2'] = date('Y-m-d 00:00:00', time() + (60 * 60 * 24 * 30)); Loading @@ -328,7 +336,7 @@ function advpoll_node_presave($node) { } // Check for vote results for this node. if (isset($nid)) { if (isset($node->nid)) { $criteria = array(); $criteria['entity_id'] = $node->nid; $criteria['entity_type'] = 'node'; Loading Loading @@ -532,7 +540,6 @@ function advpoll_display_results($nid, $data, $page = 0) { * * @return array * A keyed array of voting totals for each choice. * */ function advpoll_update_choices($choices, $results) { $choice_set = array(); Loading @@ -556,9 +563,8 @@ function advpoll_update_choices($choices, $results) { unset($choice_set[$result['index']]); } /* If there are still items in this array, it means they have no votes * associated with them but they still need to be rendered. */ // If there are still items in this array, it means they have no votes // associated with them but they still need to be rendered. if (count($choice_set) > 0) { foreach ($choice_set as $key => $choice) { $final[] = array( Loading Loading @@ -1178,3 +1184,22 @@ function advpoll_views_api() { 'path' => drupal_get_path('module', 'advpoll') . '/views', ); } /** * Round value with advpoll_percentage_rounding_method * * @param float $percentage * @param int $precision * @return float */ function advpoll_round($percentage, $precision = 0) { $rounding_method = variable_get('advpoll_percentage_rounding_method', 'round'); if (is_callable($rounding_method)) { $result = $rounding_method($percentage, $precision); } else { $result = $percentage; } return $result; }
advpoll_converter/advpoll_converter.admin.inc +1 −2 Changes for advpoll_converter/advpoll_converter.admin.inc: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -184,7 +184,6 @@ function _advpoll_converter_create_nodes($nids) { array(':nid' => $record->nid) ); $votes = array(); foreach ($poll_votes as $row) { $votes = array( 'entity_type' => 'node', Loading @@ -196,7 +195,7 @@ function _advpoll_converter_create_nodes($nids) { 'timestamp' => $row->timestamp, ); votingapi_set_votes($votes, $criteria = NULL); votingapi_set_votes($votes); } drupal_set_message(t('A new advanced poll node was created for %title.', array('%title' => $record->title))); } Loading
advpoll_field/advpoll_field.module +2 −6 Changes for advpoll_field/advpoll_field.module: 2 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -49,12 +49,10 @@ function advpoll_field_field_formatter_info() { function advpoll_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array(); switch ($display['type']) { case 'advpoll_choice': if ($display['type'] == 'advpoll_choice') { foreach ($items as $delta => $item) { $element[$delta]['#markup'] = filter_xss($item['choice'], $allowed = array('em', 'strong', 'a', 'b', 'i')); $element[$delta]['#markup'] = filter_xss($item['choice'], array('em', 'strong', 'a', 'b', 'i')); } break; } return $element; Loading @@ -76,7 +74,6 @@ function advpoll_field_field_widget_info() { /** * Implements hook_field_widget_form(). * */ function advpoll_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { $element += array( Loading Loading @@ -116,7 +113,6 @@ function advpoll_field_field_widget_form(&$form, &$form_state, $field, $instance */ function advpoll_field_field_views_data($field) { // An attempt to make a Views-friendly display. $views_fields = field_views_field_default_views_data($field); foreach ($views_fields as $key => $data) { $views_fields[$key][$field['field_name'] . '_choice']['argument']['name field'] = $field['field_name'] . '_choice'; Loading