Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • develop
  • issue-424
  • issue-525
  • master
  • master-no-logins
  • svn-staging
  • svn-testing
  • svn-trunk
  • topics/add-contribution-info
  • 2010-11-11
  • 2010-12-15
  • 2011-01-11
  • 2011-01-18
  • 2011-01-26
  • 2011-02-10
  • 2011-02-23
  • 2011-03-09
  • 2011-03-15
  • 2011-03-30
  • 2011-04-05
  • 2011-05-03
  • 2011-05-12
  • 2011-06-16
  • 2011-06-21
  • 2011-06-23
  • 2011-06-29
  • 2011-06-30
  • 2011-07-11
  • 2011-07-18
  • 2011-07-20
  • 2011-07-21
  • 2011-07-28
  • 2011-08-03
  • 2011-08-05
  • 2011-08-15
  • 2011-08-17
  • 2011-08-29
  • 2011-08-30
  • 2011-09-19
  • 2011-10-03
  • 2011-10-06
  • 2011-10-27
  • 2011-11-01
  • 2011-11-08
  • 2011-11-08.2
  • 2011-11-14
  • 2011-11-17
  • 2011-12-05
  • 2011-12-16
  • 2012-01-12
  • 2012-01-13
  • 2012-02-07
  • 2012-03-01
  • 2012-04-02
  • 2012-04-03
  • 2012-04-18
  • 20120207
  • 7.1
  • 7.2
  • 7.3
  • 7.3.1
  • 7.4
  • 7.5
  • 7.5.1
  • 7.6
  • 7.6.1
66 results

Target

Select target project
  • rklusman2/UNL-CMS
  • yzha1/UNL-CMS
  • pear/UNL-CMS
  • bbieber2/UNL-CMS
  • tsteiner2/UNL-CMS
  • erasmussen2/UNL-CMS
  • UNL-Information-Services/UNL-CMS
7 results
Select Git revision
  • develop
  • issue-424
  • master
  • master-no-logins
  • svn-staging
  • svn-testing
  • svn-trunk
  • topics/add-contribution-info
  • 2010-11-11
  • 2010-12-15
  • 2011-01-11
  • 2011-01-18
  • 2011-01-26
  • 2011-02-10
  • 2011-02-23
  • 2011-03-09
  • 2011-03-15
  • 2011-03-30
  • 2011-04-05
  • 2011-05-03
  • 2011-05-12
  • 2011-06-16
  • 2011-06-21
  • 2011-06-23
  • 2011-06-29
  • 2011-06-30
  • 2011-07-11
  • 2011-07-18
  • 2011-07-20
  • 2011-07-21
  • 2011-07-28
  • 2011-08-03
  • 2011-08-05
  • 2011-08-15
  • 2011-08-17
  • 2011-08-29
  • 2011-08-30
  • 2011-09-19
  • 2011-10-03
  • 2011-10-06
  • 2011-10-27
  • 2011-11-01
  • 2011-11-08
  • 2011-11-08.2
  • 2011-11-14
  • 2011-11-17
  • 2011-12-05
  • 2011-12-16
  • 2012-01-12
  • 2012-01-13
  • 2012-02-07
  • 2012-03-01
  • 2012-04-02
  • 2012-04-03
  • 2012-04-18
  • 20120207
  • 7.1
  • 7.10
  • 7.11
  • 7.12
  • 7.13
  • 7.14
  • 7.15
  • 7.16
  • 7.16.1
  • 7.17
  • 7.18
  • 7.19
  • 7.2
  • 7.3
  • 7.3.1
  • 7.4
  • 7.5
  • 7.5.1
  • 7.6
  • 7.6.1
  • 7.7
  • 7.7.1
  • 7.7.2
  • 7.7.3
  • 7.8
  • 7.9
82 results
Show changes
<?php
// $Id: poll.module,v 1.358 2010/10/20 01:31:07 dries Exp $
/**
* @file
......@@ -133,6 +132,7 @@ function _poll_menu_access($node, $perm, $inspect_allowvotes) {
*/
function poll_block_info() {
$blocks['recent']['info'] = t('Most recent poll');
$blocks['recent']['properties']['administrative'] = TRUE;
return $blocks;
}
......@@ -241,7 +241,7 @@ function poll_form($node, &$form_state) {
$type = node_type_get_type($node);
// The submit handlers to add more poll choices require that this form is
// cached, regardless of whether AJAX is used.
// cached, regardless of whether Ajax is used.
$form_state['cache'] = TRUE;
$form['title'] = array(
......@@ -279,11 +279,10 @@ function poll_form($node, &$form_state) {
$weight = 0;
if (isset($node->choice)) {
$delta = count($node->choice);
$weight = -$delta;
foreach ($node->choice as $chid => $choice) {
$key = 'chid:' . $chid;
$form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, $choice['chid'], $choice['chtext'], $choice['chvotes'], $choice['weight'], $choice_count);
$weight = ($choice['weight'] > $weight) ? $choice['weight'] : $weight;
$weight = max($choice['weight'], $weight);
}
}
......@@ -291,15 +290,19 @@ function poll_form($node, &$form_state) {
$existing_delta = $delta;
for ($delta; $delta < $choice_count; $delta++) {
$key = 'new:' . ($delta - $existing_delta);
// Increase the weight of each new choice.
$weight++;
$form['choice_wrapper']['choice'][$key] = _poll_choice_form($key, NULL, '', 0, $weight, $choice_count);
}
// We name our button 'poll_more' to avoid conflicts with other modules using
// AJAX-enabled buttons with the id 'more'.
// Ajax-enabled buttons with the id 'more'.
$form['choice_wrapper']['poll_more'] = array(
'#type' => 'submit',
'#value' => t('More choices'),
'#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
'#attributes' => array(
'title' => t("If the amount of boxes above isn't enough, click here to add more choices."),
),
'#weight' => 1,
'#limit_validation_errors' => array(array('choice')),
'#submit' => array('poll_more_choices_submit'),
......@@ -361,7 +364,7 @@ function poll_form($node, &$form_state) {
* return just the changed part of the form.
*/
function poll_more_choices_submit($form, &$form_state) {
// If this is a AJAX POST, add 1, otherwise add 5 more choices to the form.
// If this is a Ajax POST, add 1, otherwise add 5 more choices to the form.
if ($form_state['values']['poll_more']) {
$n = $_GET['q'] == 'system/ajax' ? 1 : 5;
$form_state['choice_count'] = count($form_state['values']['choice']) + $n;
......@@ -378,6 +381,7 @@ function poll_more_choices_submit($form, &$form_state) {
function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight = 0, $size = 10) {
$form = array(
'#tree' => TRUE,
'#weight' => $weight,
);
// We'll manually set the #parents property of these fields so that
......@@ -405,6 +409,7 @@ function _poll_choice_form($key, $chid = NULL, $value = '', $votes = 0, $weight
'#maxlength' => 7,
'#parents' => array('choice', $key, 'chvotes'),
'#access' => user_access('administer nodes'),
'#element_validate' => array('element_validate_integer'),
);
$form['weight'] = array(
......@@ -448,10 +453,8 @@ function poll_node_form_submit(&$form, &$form_state) {
*/
function poll_validate($node, $form) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes:
// Check for at least two options and validate amount of votes.
$realchoices = 0;
// Renumber fields
$node->choice = array_values($node->choice);
foreach ($node->choice as $i => $choice) {
if ($choice['chtext'] != '') {
$realchoices++;
......@@ -484,6 +487,10 @@ function poll_load($nodes) {
foreach ($nodes as $node) {
$poll = db_query("SELECT runtime, active FROM {poll} WHERE nid = :nid", array(':nid' => $node->nid))->fetchObject();
if (empty($poll)) {
$poll = new stdClass();
}
// Load the appropriate choices into the $poll object.
$poll->choice = db_select('poll_choice', 'c')
->addTag('translatable')
......@@ -578,7 +585,12 @@ function poll_update($node) {
'chvotes' => (int) $choice['chvotes'],
'weight' => $choice['weight'],
))
->insertFields(array('nid' => $node->nid))
->insertFields(array(
'nid' => $node->nid,
'chtext' => $choice['chtext'],
'chvotes' => (int) $choice['chvotes'],
'weight' => $choice['weight'],
))
->execute();
}
else {
......@@ -586,6 +598,10 @@ function poll_update($node) {
->condition('nid', $node->nid)
->condition('chid', $key)
->execute();
db_delete('poll_choice')
->condition('nid', $node->nid)
->condition('chid', $choice['chid'])
->execute();
}
}
}
......@@ -637,6 +653,11 @@ function poll_block_latest_poll_view($node) {
if (!empty($node->allowvotes)) {
$node->content['poll_view_voting'] = drupal_get_form('poll_view_voting', $node, TRUE);
$node->content['links'] = array(
'#theme' => 'links',
'#links' => $node->links,
'#weight' => 5,
);
}
else {
$node->content['poll_view_results'] = array('#markup' => poll_view_results($node, TRUE, TRUE));
......@@ -790,6 +811,9 @@ function template_preprocess_poll_vote(&$variables) {
* Generates a graphical representation of the results of a poll.
*/
function poll_view_results($node, $view_mode, $block = FALSE) {
// Make sure that choices are ordered by their weight.
uasort($node->choice, 'drupal_sort_weight');
// Count the votes and find the maximum
$total_votes = 0;
$max_votes = 0;
......@@ -826,14 +850,14 @@ function theme_poll_choices($variables) {
drupal_add_tabledrag('poll-choice-table', 'order', 'sibling', 'poll-weight');
$is_admin= user_access('administer nodes');
$delta = 0;
$rows = array();
$headers = array(
'',
t('Choice'),
t('Vote count'),
t('Weight'),
);
$headers = array('', t('Choice'));
if ($is_admin) {
$headers[] = t('Vote count');
}
$headers[] = t('Weight');
foreach (element_children($form) as $key) {
$delta++;
......@@ -845,11 +869,13 @@ function theme_poll_choices($variables) {
'data' => array(
array('class' => array('choice-flag')),
drupal_render($form[$key]['chtext']),
drupal_render($form[$key]['chvotes']),
drupal_render($form[$key]['weight']),
),
'class' => array('draggable'),
);
if ($is_admin) {
$row['data'][] = drupal_render($form[$key]['chvotes']);
}
$row['data'][] = drupal_render($form[$key]['weight']);
// Add any additional classes set on the row.
if (!empty($form[$key]['#attributes']['class'])) {
......
<?php
// $Id: poll.pages.inc,v 1.28 2010/10/06 13:38:40 dries Exp $
/**
* @file
......