Fixed display of the Polls block when it only contained blocks not visible for anonymous visitors (bug #0000996) HEAD
authorDirk Haun <dirk@haun-online.de>
Sun Oct 11 20:45:41 2009 +0200 (5 months ago)
branchHEAD
changeset 7373b04a760c72ea
parent 737259f8f25b16c2
child 73740ba218a98a1a
Fixed display of the Polls block when it only contained blocks not visible for anonymous visitors (bug #0000996)
plugins/polls/functions.inc
public_html/docs/history
     1.1 --- a/plugins/polls/functions.inc	Sun Oct 11 19:38:14 2009 +0200
     1.2 +++ b/plugins/polls/functions.inc	Sun Oct 11 20:45:41 2009 +0200
     1.3 @@ -621,40 +621,41 @@
     1.4  /**
     1.5  * This shows a poll
     1.6  *
     1.7 -* This will determine if a user needs to see the poll form OR the poll
     1.8 -* result.
     1.9 +* This will determine if a user needs to see the poll form OR the poll result.
    1.10  *
    1.11 -* @param        int        $size       Size in pixels of poll results
    1.12 -* @param        string     $pid        topic ID to show (optional)
    1.13 -* @param        int        $displaytype       Possible values 0 = Normal, 1 = In Block, 2 = autotag 
    1.14 +* @param        int     $size           Size in pixels of poll results
    1.15 +* @param        string  $pid            Poll topic ID to show (optional)
    1.16 +* @param        bool    $showall        Show only the first question or all
    1.17 +* @param        int     $displaytype    Possible values 0 = Normal, 1 = In Block, 2 = autotag 
    1.18 +* @return       string  HTML formatted string of poll
    1.19  * @see function COM_pollVote
    1.20  * @see function COM_pollResults
    1.21 -* @return    String  HTML Formated string of Poll
    1.22  *
    1.23  */
    1.24 -
    1.25 -function POLLS_showPoll($size, $pid='', $showall = false, $displaytype = 0 )
    1.26 +function POLLS_showPoll($size, $pid = '', $showall = false, $displaytype = 0)
    1.27  {
    1.28 -    global $_CONF, $_PO_CONF, $_TABLES, $LANG_POLLS;
    1.29 +    global $_CONF, $_TABLES, $_PO_CONF, $LANG_POLLS;
    1.30  
    1.31      $retval = '';
    1.32  
    1.33      DB_query("DELETE FROM {$_TABLES['pollvoters']} WHERE date < UNIX_TIMESTAMP() - {$_PO_CONF['polladdresstime']}");
    1.34 -    
    1.35 -    if(!empty($pid)) {
    1.36 +
    1.37 +    if (!empty($pid)) {
    1.38          $Q['is_open'] = DB_getItem($_TABLES['polltopics'], 'is_open', "pid = '".$pid."'");
    1.39  
    1.40 -        if ($displaytype == 2 && $Q['is_open'] == 0) {
    1.41 -            $retval = '<div class="poll-autotag-message">' . $LANG_POLLS['pollclosed']. "</div>";
    1.42 +        if (($displaytype == 2) && ($Q['is_open'] == 0)) {
    1.43 +            $retval = '<div class="poll-autotag-message">'
    1.44 +                    . $LANG_POLLS['pollclosed'] . '</div>';
    1.45          }        
    1.46 -        if(!isset($_COOKIE["poll-".$pid]) && !POLLS_ipAlreadyVoted($pid) && ($Q['is_open'] == 1)) {
    1.47 +        if (!isset($_COOKIE['poll-' . $pid]) && !POLLS_ipAlreadyVoted($pid) &&
    1.48 +                ($Q['is_open'] == 1)) {
    1.49              $retval .= POLLS_pollVote($pid, $showall, $displaytype);
    1.50          } else {
    1.51              $retval .= POLLS_pollResults($pid, $size, '', '', $displaytype);
    1.52          }
    1.53      } else {
    1.54 -        $result = DB_query("SELECT pid,topic,is_open FROM {$_TABLES['polltopics']} WHERE display = 1 ORDER BY date DESC");
    1.55 -        $nrows = DB_numRows($result );
    1.56 +        $result = DB_query("SELECT pid,topic,is_open FROM {$_TABLES['polltopics']} WHERE display = 1" . COM_getPermSql('AND') . " ORDER BY date DESC");
    1.57 +        $nrows = DB_numRows($result);
    1.58  
    1.59          $title = DB_getItem($_TABLES['blocks'], 'title', "name='poll_block'");
    1.60  
    1.61 @@ -662,23 +663,24 @@
    1.62              for ($i = 1; $i <= $nrows; $i++) {
    1.63                  $Q = DB_fetchArray($result);
    1.64                  $pid = $Q['pid'];
    1.65 -                //if ($size < 120) { // assume we're in the poll block
    1.66 -                if ($displaytype == 1) { // In the poll block
    1.67 +                if ($displaytype == 1) { // in the poll block
    1.68                      $showall = false;
    1.69                  } else { // assume we're in polls/index.php
    1.70                      $retval .= COM_startBlock($title);
    1.71                      $showall = true;
    1.72                  }
    1.73  
    1.74 -                if (!isset($_COOKIE["poll-".$pid]) && !POLLS_ipAlreadyVoted($pid) && ($Q['is_open'] == 1)) {
    1.75 +                if (!isset($_COOKIE['poll-' . $pid]) &&
    1.76 +                        !POLLS_ipAlreadyVoted($pid) && ($Q['is_open'] == 1)) {
    1.77                      $retval .= POLLS_pollVote($pid, $showall, $displaytype);
    1.78                  } else {
    1.79 -                    $retval .= POLLS_pollResults($pid, $size, '', '', $displaytype);
    1.80 +                    $retval .= POLLS_pollResults($pid, $size, '', '',
    1.81 +                                                 $displaytype);
    1.82                  }
    1.83  
    1.84 -                if ($size < 120) {
    1.85 -                    if ($i < $nrows){
    1.86 -                        $retval .= "<div class=\"poll-divider\"></div>";
    1.87 +                if ($displaytype == 1) { // in the poll block
    1.88 +                    if (($i < $nrows) && !empty($retval)) {
    1.89 +                        $retval .= '<div class="poll-divider"></div>';
    1.90                      }
    1.91                  } else {
    1.92                      $retval .= COM_endBlock();
    1.93 @@ -686,6 +688,7 @@
    1.94              }
    1.95          }
    1.96      }
    1.97 +
    1.98      return $retval;
    1.99  }
   1.100  
   1.101 @@ -953,10 +956,15 @@
   1.102      return $retval;
   1.103  }
   1.104  
   1.105 +/**
   1.106 +* Display the current poll(s) in a side block
   1.107 +*
   1.108 +* @return   string  HTML for the poll(s) to be displayed (or an empty string)
   1.109 +*
   1.110 +*/
   1.111  function phpblock_polls()
   1.112  {
   1.113 -    $retval = POLLS_showPoll(60, '', false, 1);
   1.114 -    return $retval;
   1.115 +    return POLLS_showPoll(60, '', false, 1);
   1.116  }
   1.117  
   1.118  
     2.1 --- a/public_html/docs/history	Sun Oct 11 19:38:14 2009 +0200
     2.2 +++ b/public_html/docs/history	Sun Oct 11 20:45:41 2009 +0200
     2.3 @@ -105,6 +105,8 @@
     2.4  
     2.5  Polls Plugin
     2.6  ------------
     2.7 +- Fixed display of the Polls block when it only contained blocks not visible
     2.8 +  for anonymous visitors (bug #0000996) [Dirk]
     2.9  - When upgrading from Geeklog 1.5.2, the length of the poll IDs was not extended
    2.10    to 40 characters - only fresh installs of Geeklog 1.6.0 and upgrades from
    2.11    older versions worked correctly (cf. feature request #0000754) [Dirk]