Follow-up from #2671250: Remove broken Votes local task. We should re-add the votes information for a poll.

CommentFileSizeAuthor
#2 screenshot-1-poll.png17.98 KBtbonomelli
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tduong created an issue. See original summary.

tbonomelli’s picture

Assigned: Unassigned » tbonomelli
Status: Active » Needs review
FileSize
17.98 KB

Did the functionality for the Votes Local Task get re-added?

Berdir’s picture

Status: Needs review » Active

Not sure what you are asking.

No, that is the purpose of this issue, to add this feature again.

Bambell’s picture

Status: Active » Needs work

We are missing quite a lot of context and couldn't figure out what that local task is supposed to do. I've been digging a bit and found the following at commit #935748 (Jan. 7 2013) :

/**
 * Page callback: Displays the 'votes' tab for polls.
 *
 * This page displays a table containing each vote that has been cast.
 *
 * @param $node
 *   The poll node object.
 *
 * @return
 *   Render array containing table with votes.
 *
 * @see poll_menu()
 */
function poll_votes($node) {
  $votes_per_page = 20;
  drupal_set_title($node->label());

  $header[] = array('data' => t('Visitor'), 'field' => 'u.name');
  $header[] = array('data' => t('Vote'), 'field' => 'pc.chtext');
  $header[] = array('data' => t('Timestamp'), 'field' => 'pv.timestamp', 'sort' => 'desc');

  $select = db_select('poll_vote', 'pv')
    ->extend('Drupal\Core\Database\Query\PagerSelectExtender')
    ->extend('Drupal\Core\Database\Query\TableSortExtender');
  $select->join('poll_choice', 'pc', 'pv.chid = pc.chid');
  $select->join('users', 'u', 'pv.uid = u.uid');
  $queried_votes = $select
    ->addTag('translatable')
    ->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid'))
    ->fields('pc', array('chtext'))
    ->fields('u', array('name'))
    ->condition('pv.nid', $node->nid)
    ->limit($votes_per_page)
    ->orderByHeader($header)
    ->execute();

  $rows = array();
  foreach ($queried_votes as $vote) {
    $rows[] = array(
      $vote->name ? theme('username', array('account' => $vote)) : check_plain($vote->hostname),
      check_plain($vote->chtext),
      format_date($vote->timestamp),
    );
  }
  $build['poll_votes_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#prefix' => t('This table lists all the recorded votes for this poll. If anonymous users are allowed to vote, they will be identified by the IP address of the computer they used when they voted.'),
  );
  $build['poll_votes_pager'] = array('#theme' => 'pager');
  return $build;
}

Should be able to move forward with this now :).

tbonomelli’s picture

Assigned: tbonomelli » Unassigned