Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

BugFix: Vote details link prevented if tracedetails switched off

Signed-off-by: Taggic <taggic@t-online.de>
  • Loading branch information...
commit ff05883b805e8276f867b932b725cdda8a3b2dfe 1 parent 69905b7
Taggic authored December 16, 2011
2  INFO
@@ -2,7 +2,7 @@
2 2
 
3 3
 author  Taggic
4 4
 email   taggic@t-online.de
5  
-date    2011-10-05
  5
+date    2011-12-16
6 6
 name    rater
7 7
 desc    provides a simple star rater
8 8
 url     http://www.dokuwiki.org/plugin:rater
2  VERSION
... ...
@@ -1 +1 @@
1  
-2011-10-05
  1
+2011-12-16
41  action.php
@@ -23,7 +23,7 @@ function getInfo(){
23 23
     return array(
24 24
          'author' => 'Taggic',
25 25
          'email'  => 'Taggic@t-online.de',
26  
-         'date'   => '2011-09-26',
  26
+         'date'   => '2011-12-16',
27 27
          'name'   => 'rater (action plugin component)',
28 28
          'desc'   => 'to store votes and display feedback.',
29 29
          'url'    => 'http://www.dokuwiki.org/plugin:rater',
@@ -47,15 +47,17 @@ function _handle_act(&$event, $param) {
47 47
              $this->rater_name = $_GET['rater_name'];
48 48
              $this->rater_ip = $_GET['rater_ip'];
49 49
              $this->rater_end = $_GET['rater_end'];
  50
+             $this->anker_id = $_GET['anker'];
50 51
              $this->vote = 1;         
51 52
          }
52 53
          elseif ($event->data === 'rate_votedown') {
53 54
              $this->raterfile = $_GET['rater_file'];
54 55
              $this->rater_id = $_GET['rater_id'];
55 56
              $this->rater_name = $_GET['rater_name'];
56  
-             $this->rater_ip = $_GET['$rater_ip'];
  57
+             $this->rater_ip = $_GET['rater_ip'];
57 58
              $this->rater_end = $_GET['rater_end'];
58  
-             $this->vote = 2;
  59
+             $this->anker_id = $_GET['anker'];
  60
+             $this->vote = 2;         
59 61
          }
60 62
          else return;
61 63
          
@@ -81,16 +83,7 @@ function output(&$data) {
81 83
       $rater_name = $this->rater_name;
82 84
       $rater_ip   = $this->rater_ip;
83 85
       $rater_end  = $this->rater_end;
84  
-
85  
-/*          if (($rater_end!='never') && (date('d.m.Y',strtotime($rater_end))<date('d.m.Y')))     
86  
-              { $rastr ='<'; }
87  
-          elseif (($rater_end!='never') && (date('d.m.Y',strtotime($rater_end))==date('d.m.Y'))) 
88  
-              { $rastr ='='; }
89  
-          elseif (($rater_end!='never') && (date('d.m.Y',strtotime($rater_end))>date('d.m.Y'))) 
90  
-              { $rastr ='>'; }
91  
-          echo  date('d.m.Y',strtotime($rater_end)). $rastr . date('d.m.Y').'<br>';   */     
92  
-
93  
-
  86
+      $anker_id   = $this->anker_id;
94 87
 
95 88
           // Config settings
96 89
           $rater_ip_voting_restriction = $this->getConf('voting_restriction'); // restrict ip address voting (true or false)
@@ -103,20 +96,21 @@ function output(&$data) {
103 96
 
104 97
           $msg_votended                = $this->getLang('msg_votended');
105 98
           $alink_Back                  = $this->getLang('alink_Back');
106  
-
  99
+          $today                       = date('d.m.Y');
  100
+          
107 101
           //check if vote period already ended
108  
-          if (($rater_end!='never') && (date('d.m.Y',strtotime($rater_end))<=date('d.m.Y')))
  102
+          if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
109 103
               {$rater_endmsg =sprintf($msg_votended,date('d.m.Y',strtotime($rater_end))).'<br>';
110  
-               echo $rater_endmsg.'<br><a href="doku.php?id='.$ID.'" />'.$alink_Back.'</a>';
111  
-               return;}
  104
+               
  105
+               echo '<div class="thumb__negative_feedback">'.$rater_endmsg.
  106
+                    '<a href="doku.php?id='.$ID.'" />'.$alink_Back.'</a></div>';
  107
+               return;
  108
+               }
112 109
 
113 110
 
114 111
     //        save vote
115 112
             $rater_filename = metaFN('rater_'.$rater_id.'_'.$rater_name.'_'.$rater_type, '.rating');
116 113
            // trace ip or login
117  
-           
118  
-
119  
-             
120 114
             $rater_file=fopen($rater_filename,"a+");
121 115
             $rater_str="";
122 116
             $rater_str = rtrim(fread($rater_file, 1024*8),$rater_end_of_line_char);
@@ -151,8 +145,11 @@ function output(&$data) {
151 145
       
152 146
       // reload original page
153 147
 //      $ret .= $rater_msg.'<br><a href="doku.php?id='.$ID.'" />back</a>';
154  
-//      echo $ret;
155  
-      echo '<meta http-equiv="refresh" content="0; URL=doku.php?id='.$ID.$addMXG.'">';
  148
+      echo '<div class="thumb__positive_feedback">'.$rater_ip.' : '.$rater_msg.'<br />'.
  149
+                    '<a href="doku.php?id='.$ID.'" />'.$alink_Back.'</a></div>';
  150
+
  151
+//      echo "anker = ".$anker_id.'<br>';
  152
+      echo '<meta http-equiv="refresh" content="0; URL=doku.php?id='.$ID.'#'.$anker_id.'">';
156 153
 
157 154
     }
158 155
 /******************************************************************************/
2  plugin.info.txt
@@ -3,7 +3,7 @@
3 3
 base    rater
4 4
 author  Taggic
5 5
 email   taggic@t-online.de
6  
-date    2011-10-05
  6
+date    2011-12-16
7 7
 name    rater
8 8
 desc    provides a simple 5 star rater and thumb voting
9 9
 url     http://www.dokuwiki.org/plugin:rater
38  syntax.php
@@ -101,7 +101,9 @@ function render($mode, &$renderer, $data) {
101 101
           
102 102
           $rater_id = $data['rater_id'];
103 103
           $rater_name = $data['rater_name'];
104  
-          if (!isset($data['rater_end'])) $data['rater_end']='never';
  104
+          if (!isset($data['rater_end'])) {$data['rater_end']='never'; $rater_end='never';}
  105
+          else {$rater_end=$data['rater_end'];}
  106
+
105 107
           if(!isset($data['rater_tracedetails'])) $data['rater_tracedetails']='0';
106 108
           if(!isset($rater_id)) $rater_id=1;
107 109
           $rater_item_name = $data['rater_name'];                              // item name what is to be rated
@@ -117,7 +119,7 @@ function render($mode, &$renderer, $data) {
117 119
           $rater_rating=0;
118 120
           $rater_votes=0;
119 121
           $rater_msg="";
120  
-          
  122
+          $today = date('d.m.Y');
121 123
           // check to trace ip or user name
122 124
           $user_grp = pageinfo();
123 125
           $rater_realname =  $user_grp['userinfo']['name'];
@@ -192,12 +194,12 @@ function render($mode, &$renderer, $data) {
192 194
               // Assign star image
193 195
               $rater_stars = $this->assign_star_image($rater_rating);
194 196
               $anker_id = 'rateanker_'. uniqid((double)microtime()*1000000,1);
195  
-                            
  197
+                           
196 198
               // build the return value for details
197  
-              if (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))>=date('d.m.Y')))
  199
+              if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
198 200
               {  $ret_details = '<div class="rating__details">'.sprintf($msg_ratingend,date('d.m.Y',strtotime($data['rater_end']))).'<br />'; 
199 201
                  $alink_Details = '<a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a>'; }
200  
-              elseif (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))<date('d.m.Y')))
  202
+              elseif (($rater_end!='never') || (strtotime($today) <= strtotime($rater_end)))
201 203
               {  $ret_details = '<div class="rating__details">'.sprintf($msg_ratingended,date('d.m.Y',strtotime($data['rater_end']))).'<br />'; 
202 204
                  $alink_Details = '<a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a>';}
203 205
               else 
@@ -242,7 +244,8 @@ function hidden'.$rater_id.'()
242 244
               $ret .= '<tr><td style="display : none" id="details_'.$rater_id.'">'.$ret_details.'</td></tr>'; 
243 245
               $ret .= '<tr><td>';
244 246
               
245  
-              if (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))<date('d.m.Y')))
  247
+              
  248
+              if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
246 249
               {
247 250
                   $rater_msg =''; }
248 251
               else {
@@ -291,11 +294,12 @@ function hidden'.$rater_id.'()
291 294
                  }
292 295
                  fclose($rater_file);
293 296
                }
294  
-               //check if vote period already ended
295  
-              if (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))>=date('d.m.Y')))
296  
-                  {$rater_endmsg = sprintf($msg_votend,date('d.m.Y',strtotime($data['rater_end']))).'<br />';}
297  
-              elseif (($data['rater_end']!='never') && (date('d.m.Y',strtotime($data['rater_end']))<date('d.m.Y')))
  297
+               
  298
+               //check if vote period already ended                
  299
+              if (($rater_end!='never') && (strtotime($today) > strtotime($rater_end)))
298 300
                   {$rater_endmsg = sprintf($msg_votended,date('d.m.Y',strtotime($data['rater_end']))).'<br />';}
  301
+              elseif (($rater_end!='never') || (strtotime($today) <= strtotime($rater_end)))
  302
+                  {$rater_endmsg = sprintf($msg_votend,date('d.m.Y',strtotime($data['rater_end']))).'<br />';}
299 303
               else
300 304
                   {$rater_endmsg ='';}
301 305
               // build the return value for details if details option is on
@@ -307,7 +311,7 @@ function hidden'.$rater_id.'()
307 311
               $ret_details .= '</div>';                            
308 312
               
309 313
               // Output vote
310  
-              $ret .= '<form name="'.$data['rater_id'].$data['rater_name'].$data['rater_type'].'" method="post" action="doku.php?id=' . $ID .'">';
  314
+//              $ret .= '<form name="'.$data['rater_id'].$data['rater_name'].$data['rater_type'].'" method="post" action="doku.php?id=' . $ID .'">';
311 315
               $ret .= '<table class="hreview">';              
312 316
 
313 317
               
@@ -331,11 +335,15 @@ function hidden'.$rater_id.'()
331 335
               $ret .= $addMSG.'<a class="thumbup tup" href="doku.php?id='.$ID.'&do=rate_voteup&rater_id='.$rater_id.'&rater_ip='.$rater_ip.'&rater_end='.$data['rater_end'].'&anker='.$anker_id.'&rater_name='.$rater_name.'"></a>'.
332 336
                    '<span id="vote1_1" style="color:#5b8f22">('.$vote1.')&nbsp;</span>'.
333 337
                    '<a class="thumbdown tdn" href="doku.php?id='.$ID.'&do=rate_votedown&rater_id='.$rater_id.'&rater_ip='.$rater_ip.'&rater_end='.$data['rater_end'].'&anker='.$anker_id.'&rater_name='.$rater_name.'"></a>'.
334  
-                   '<span id="vote1_2" style="color:#FF1822">('.$vote2.')</span><a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a></td></tr>';
335  
-              $ret .= '<tr><td style="display : none" id="details_'.$rater_id.'">'.$ret_details.'</td></tr>';
  338
+                   '<span id="vote1_2" style="color:#FF1822">('.$vote2.')</span>';
  339
+              if($data['rater_tracedetails']==='1') {
  340
+                    $ret .= '<a href="#'.$anker_id.'" onclick="hidden'.$rater_id.'()">(Details)</a></td></tr>'.
  341
+                         '<tr><td style="display : none" id="details_'.$rater_id.'">'.$ret_details.'</td></tr>';
  342
+              }
  343
+              else $ret .='</td></tr>';
336 344
               if($rater_msg!="") $ret .= "<div>".$rater_msg."</div>";
337 345
               $ret .= '</table>';              
338  
-              $ret .= '</form>';
  346
+//              $ret .= '</form>';
339 347
           }
340 348
 /******************************************************************************/
341 349
           elseif ($rater_type=="stat") {
@@ -473,7 +481,7 @@ function hidden'.$rater_id.'()
473 481
             
474 482
             // output statistic
475 483
             $ret = '<table class="rating_stat_table"><form method="post" action="doku.php?id=' . $ID .'" >'.
476  
-                   '<tr><TH class="rating_stat_th">Item</TH><TH class="rating_stat_th">Value</TH><TH class="rating_stat_th">Details</TH></tr>';
  484
+                   '<tr><th class="rating_stat_th">Item</th><th class="rating_stat_th">Value</th><th class="rating_stat_th">Details</th></tr>';
477 485
             foreach($found_ratings as $findings) {
478 486
                   $dtls_id = uniqid((double)microtime()*1000000,1);
479 487
                   $alink_id++;

0 notes on commit ff05883

Please sign in to comment.
Something went wrong with that request. Please try again.