[geeklog-cvs] geeklog: Merged with Tom's changes

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Thu Mar 11 11:20:21 EST 2010


changeset 7782:0dff3aa6e0b7
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/0dff3aa6e0b7
user: Dirk Haun <dirk at haun-online.de>
date: Thu Mar 11 16:25:37 2010 +0100
description:
Merged with Tom's changes

diffstat:

 plugins/polls/functions.inc              |  59 +++++++++++++++++------------
 plugins/polls/language/english.php       |   4 +-
 plugins/polls/language/english_utf-8.php |   4 +-
 3 files changed, 38 insertions(+), 29 deletions(-)

diffs (140 lines):

diff -r be74560f386e -r 0dff3aa6e0b7 plugins/polls/functions.inc
--- a/plugins/polls/functions.inc	Thu Mar 11 13:34:15 2010 +0100
+++ b/plugins/polls/functions.inc	Thu Mar 11 16:25:37 2010 +0100
@@ -1237,7 +1237,7 @@
 */
 function plugin_getiteminfo_polls($pid, $what, $uid = 0, $options = array())
 {
-    global $_CONF, $_TABLES;
+    global $_CONF, $_TABLES, $_USER;
     
     // parse $what to see what we need to pull from the database
     $properties = explode(',', $what);
@@ -1257,6 +1257,7 @@
             // needed for $pid == '*', but also in case we're only requesting
             // the URL (so that $fields isn't emtpy)
             $fields[] = 'pid';
+            $fields[] = 'hideresults';
 
             break;
         default:
@@ -1317,9 +1318,12 @@
                                   . '/polls/index.php?pid=' . $pid
                                   . '&aid=-1';
                 } else {
-                    $props['url'] = $_CONF['site_url']
-                                  . '/polls/index.php?pid=' . $A['pid']
-                                  . '&aid=-1';
+                    // Users who have already voted but cannot see the results cannot view link
+                    if ($_USER['uid'] == 2 || ($_USER['uid'] != 2 && !($A['hideresults'] == 1 && (isset($_COOKIE['poll-' . $A['pid']]) || POLLS_ipAlreadyVoted($A['pid']))))) {
+                        $props['url'] = $_CONF['site_url']
+                                      . '/polls/index.php?pid=' . $A['pid'];
+                                      // . '&aid=-1';
+                    }
                 }
                 break;
             default:
@@ -1508,7 +1512,7 @@
 */
 function plugin_getwhatsnew_polls()
 {
-    global $_CONF, $_TABLES, $_PO_CONF, $LANG_POLLS;
+    global $_CONF, $_TABLES, $_PO_CONF, $LANG_POLLS, $_USER;
 
     $retval = '';
     if ($_PO_CONF['hidenewpolls'] == 'modified') {
@@ -1517,13 +1521,13 @@
         $datecolumn = 'created';
     }
     $sql = array();
-    $sql['mysql'] = "SELECT pid, topic 
+    $sql['mysql'] = "SELECT pid, topic, hideresults 
         FROM {$_TABLES['polltopics']} 
         WHERE ({$datecolumn} >= (DATE_SUB(NOW(), INTERVAL {$_PO_CONF['newpollsinterval']} SECOND))) 
         " . COM_getPermSQL('AND') . " 
         ORDER BY {$datecolumn} DESC LIMIT 15";
         
-    $sql['pgsql'] = "SELECT  pid, topic 
+    $sql['pgsql'] = "SELECT  pid, topic, hideresults 
         FROM {$_TABLES['polltopics']} 
         WHERE ({$datecolumn} >= (NOW() - INTERVAL '{$_PO_CONF['newpollsinterval']} SECONDS')) 
         " . COM_getPermSQL('AND') . " 
@@ -1538,27 +1542,32 @@
         for ($x = 0; $x < $nrows; $x++) {
             $A = DB_fetchArray($result);
 
-            //$url = COM_buildUrl($_CONF['site_url'] . '/polls/index.php?pid=' . $A['pid']);
-            $url = $_CONF['site_url'] . '/polls/index.php?pid=' . $A['pid'];
-
-            $title = COM_undoSpecialChars(stripslashes( $A['topic']));
-            $titletouse = COM_truncate($title, $_PO_CONF['title_trim_length'],
-                                       '...');
-            if ($title != $titletouse) {
-                $attr = array('title' => htmlspecialchars($title));
-            } else {
-                $attr = array();
+            // Users who have already voted but cannot see the results cannot view link
+            if ($_USER['uid'] == 2 || ($_USER['uid'] != 2 && !($A['hideresults'] == 1 && (isset($_COOKIE['poll-' . $A['pid']]) || POLLS_ipAlreadyVoted($A['pid']))))) {
+                $url = $_CONF['site_url'] . '/polls/index.php?pid=' . $A['pid'];
+                $title = COM_undoSpecialChars(stripslashes( $A['topic']));
+                $titletouse = COM_truncate($title, $_PO_CONF['title_trim_length'],
+                                           '...');
+                if ($title != $titletouse) {
+                    $attr = array('title' => htmlspecialchars($title));
+                } else {
+                    $attr = array();
+                }
+                $apoll = str_replace('$', '$', $titletouse);
+                $apoll = str_replace(' ', ' ', $apoll);
+    
+                $newpolls[] = COM_createLink($apoll, $url, $attr);
             }
-            $apoll = str_replace('$', '$', $titletouse);
-            $apoll = str_replace(' ', ' ', $apoll);
-
-            $newpolls[] = COM_createLink($apoll, $url, $attr);
         }
-
-        $retval .= COM_makeList($newpolls, 'list-new-plugins');
-    } else {
+        
+        if (isset($url)) {
+            $retval .= COM_makeList($newpolls, 'list-new-plugins');
+        }
+    }
+    
+    if ($nrows == 0 || !isset($url)) {
         $retval .= $LANG_POLLS['no_new_polls'] . '<br' . XHTML . '>' . LB;
-    }
+    }     
 
     return $retval;
 }
diff -r be74560f386e -r 0dff3aa6e0b7 plugins/polls/language/english.php
--- a/plugins/polls/language/english.php	Thu Mar 11 13:34:15 2010 +0100
+++ b/plugins/polls/language/english.php	Thu Mar 11 16:25:37 2010 +0100
@@ -53,8 +53,8 @@
     'pollclosed'        => 'This poll is closed for voting.', 
     'pollhidden'        => 'You have already voted. This poll results will only be shown when voting is closed.', 
     'start_poll'        => 'Start Poll',
-    'no_new_pages' => 'No new pages',
-    'deny_msg' => 'Access to this poll is denied.  Either the poll has been moved/removed or you do not have sufficient permissions.'
+    'no_new_polls'      => 'No new polls',
+    'deny_msg'          => 'Access to this poll is denied.  Either the poll has been moved/removed or you do not have sufficient permissions.'
 );
 
 ###############################################################################
diff -r be74560f386e -r 0dff3aa6e0b7 plugins/polls/language/english_utf-8.php
--- a/plugins/polls/language/english_utf-8.php	Thu Mar 11 13:34:15 2010 +0100
+++ b/plugins/polls/language/english_utf-8.php	Thu Mar 11 16:25:37 2010 +0100
@@ -53,8 +53,8 @@
     'pollclosed'        => 'This poll is closed for voting.', 
     'pollhidden'        => 'You have already voted. This poll results will only be shown when voting is closed.', 
     'start_poll'        => 'Start Poll',
-    'no_new_pages' => 'No new pages',
-    'deny_msg' => 'Access to this poll is denied.  Either the poll has been moved/removed or you do not have sufficient permissions.'
+    'no_new_polls'      => 'No new polls',
+    'deny_msg'          => 'Access to this poll is denied.  Either the poll has been moved/removed or you do not have sufficient permissions.'
 );
 
 ###############################################################################



More information about the geeklog-cvs mailing list