Dotclear

Changeset 1486


Ignore:
Timestamp:
09/23/09 17:29:51 (14 years ago)
Author:
JcDenis
Message:

rateIt 0.9.6:

  • Fixed DC 2.1.6 URL handlers ending
  • Added sort by sort rate by date (thanks to lottie14)
  • Cleaned some stuff
Location:
plugins/rateIt
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • plugins/rateIt/_define.php

    r1458 r1486  
    1818     /* Description*/         "Rating system for your posts", 
    1919     /* Author */             "JC Denis", 
    20      /* Version */            '0.9.5', 
     20     /* Version */            '0.9.6', 
    2121     /* Permissions */        'admin' 
    2222); 
    23      /* date */          #20090909 
     23     /* date */          #20090923 
    2424?> 
  • plugins/rateIt/_public.php

    r1458 r1486  
    8383          if (!$core->blog->settings->rateit_active) { 
    8484               self::p404(); 
    85                exit; 
     85               return; 
    8686          } 
    8787 
    8888          if (!preg_match('#([^/]+)/([^/]+)$#',$args,$m)) { 
    8989               self::p404(); 
    90                exit; 
     90               return; 
    9191          } 
    9292 
    9393          if (!isset($_POST['rateit-'.$m[1].'-'.$m[2]])) { 
    9494               self::p404(); 
    95                exit; 
     95               return; 
    9696          } 
    9797 
     
    112112               if ($post->post_id) { 
    113113                    http::redirect($core->blog->url.$core->url->getBase('post').'/'.$post->post_url.($voted ? '#rateit' : '')); 
    114                     exit; 
     114                    return; 
    115115               } 
    116116          } 
     
    120120               if ($comment->comment_id) { 
    121121                    http::redirect($core->blog->url.$core->url->getBase('post').'/'.$post->post_url.($voted ? '#rateit' : '')); 
     122                    return; 
    122123               } 
    123124          } 
     
    127128               if ($cat->cat_id) { 
    128129                    http::redirect($core->blog->url.$core->url->getBase('category').'/'.$cat->cat_url.($voted ? '#rateit' : '')); 
     130                    return; 
    129131               } 
    130132          } 
     
    135137               if ($metas->meta_id) { 
    136138                    http::redirect($core->blog->url.$core->url->getBase('tag').'/'.$metas->meta_id.($voted ? '#rateit' : '')); 
     139                    return; 
    137140               } 
    138141          } 
     
    142145               if ($gal->cat_id) { 
    143146                    http::redirect($core->blog->url.$core->url->getBase('galleries').'/'.$gal->post_url.($voted ? '#rateit' : '')); 
     147                    return; 
    144148               } 
    145149          } 
     
    149153               if ($gal->cat_id) { 
    150154                    http::redirect($core->blog->url.$core->url->getBase('gal').'/'.$gal->post_url.($voted ? '#rateit' : '')); 
     155                    return; 
    151156               } 
    152157          } 
     
    156161 
    157162          http::redirect($core->blog->url); 
    158           exit; 
     163          return; 
    159164     } 
    160165 
     
    165170          if (!$core->blog->settings->rateit_active) { 
    166171               self::p404(); 
    167                exit; 
     172               return; 
    168173          } 
    169174 
    170175          if (!preg_match('#^(.*?)$#',$args,$m)) { 
    171176               self::p404(); 
    172                exit; 
     177               return; 
    173178          } 
    174179 
    175180          if (!($f = self::searchRateItTplFiles($m[1]))) { 
    176181               self::p404(); 
    177                exit; 
     182               return; 
    178183          } 
    179184 
     
    181186          if (!file_exists($f) || !in_array(files::getExtension($f),$allowed_types)) { 
    182187               self::p404(); 
    183                exit; 
     188               return; 
    184189          } 
    185190 
     
    193198               echo preg_replace('#url\((?!(http:)|/)#','url('.$core->blog->url.$core->url->getBase('rateItmodule').'/',file_get_contents($f)); 
    194199          } 
    195           exit; 
     200          return; 
    196201     } 
    197202 
     
    643648 
    644649          $p = array('from'=>'','sql'=>'','columns'=>array()); 
    645           $p['order'] = ($w->sortby && in_array($w->sortby,array('rateit_avg','rateit_total'))) ?  
     650          $p['order'] = ($w->sortby && in_array($w->sortby,array('rateit_avg','rateit_total','rateit_time'))) ?  
    646651               $w->sortby.' ' : 'rateit_total '; 
    647652 
  • plugins/rateIt/_widgets.php

    r1406 r1486  
    112112          $w->rateitrank->setting('sortby',__('Order by:'),'rateit_avg','combo',array( 
    113113               __('Note') => 'rateit_avg', 
    114                __('Votes') => 'rateit_total')); 
     114               __('Votes') => 'rateit_total', 
     115               __('Date') => 'rateit_time')); 
    115116          $w->rateitrank->setting('sort',__('Sort:'),'desc','combo',array( 
    116117               __('Ascending') => 'asc', 
  • plugins/rateIt/inc/class.rateit.php

    r1458 r1486  
    1717{ 
    1818     public $core; 
     19     public $con; 
     20     private $blog; 
    1921     private $table; 
    2022     private $quotient; 
     
    2729     { 
    2830          $this->core =& $core; 
     31          $this->con = $core->con; 
     32          $this->blog = $core->con->escape($core->blog->id); 
    2933          $this->table = $core->prefix.'rateit'; 
    3034          $this->quotient = $core->blog->settings->rateit_quotient; 
     
    5862               return false; 
    5963 
    60           $cur = $this->core->con->openCursor($this->table); 
    61           $this->core->con->writeLock($this->table); 
    62  
    63           $cur->blog_id = $this->core->blog->id; 
     64          $cur = $this->con->openCursor($this->table); 
     65          $this->con->writeLock($this->table); 
     66 
     67          $cur->blog_id = $this->blog; 
    6468          $cur->rateit_type = (string) $type; 
    6569          $cur->rateit_id = (string) $id; 
     
    7579 
    7680          $cur->insert(); 
    77           $this->core->con->unlock(); 
     81          $this->con->unlock(); 
    7882          $this->core->blog->triggerBlog(); 
    7983 
     
    9397          $req= 
    9498               'SELECT rateit_note, rateit_quotient '. 
    95                'FROM '.$this->table.' WHERE blog_id=\''.$this->core->con->escape($this->core->blog->id).'\' '; 
     99               'FROM '.$this->table.' WHERE blog_id=\''.$this->blog.'\' '; 
    96100          if ($type!=null) 
    97                $req .= 'AND rateit_type=\''.$this->core->con->escape($type).'\' '; 
     101               $req .= 'AND rateit_type=\''.$this->con->escape($type).'\' '; 
    98102          if ($id!=null) 
    99                $req .= 'AND rateit_id=\''.$this->core->con->escape($id).'\' '; 
     103               $req .= 'AND rateit_id=\''.$this->con->escape($id).'\' '; 
    100104          if ($ip!=null) 
    101                $req .= 'AND rateit_ip=\''.$this->core->con->escape($ip).'\' '; 
    102  
    103           $rs = $this->core->con->select($req); 
     105               $req .= 'AND rateit_ip=\''.$this->con->escape($ip).'\' '; 
     106 
     107          $rs = $this->con->select($req); 
    104108          $rs->toStatic(); 
    105109 
     
    135139     public function voted($type=null,$id=null) 
    136140     { 
    137           $rs = $this->core->con->select( 
     141          $rs = $this->con->select( 
    138142               'SELECT COUNT(*) '. 
    139143               'FROM '.$this->table.' '. 
    140                'WHERE blog_id=\''.$this->core->con->escape($this->core->blog->id).'\' '. 
    141                'AND rateit_ip=\''.$this->core->con->escape($this->ip).'\' '. 
     144               'WHERE blog_id=\''.$this->blog.'\' '. 
     145               'AND rateit_ip=\''.$this->con->escape($this->ip).'\' '. 
    142146               ($type!=null ?  
    143                'AND rateit_type=\''.$this->core->con->escape($type).'\' ' : ''). 
     147               'AND rateit_type=\''.$this->con->escape($type).'\' ' : ''). 
    144148               ($id!=null ?  
    145                'AND rateit_id=\''.$this->core->con->escape($id).'\' ' : '') 
     149               'AND rateit_id=\''.$this->con->escape($id).'\' ' : '') 
    146150          ); 
    147151          $sql = (boolean) $rs->f(0); 
     
    157161          $req =  
    158162               'DELETE FROM '.$this->table.' '. 
    159                'WHERE blog_id=\''.$this->core->con->escape($this->core->blog->id).'\' '; 
     163               'WHERE blog_id=\''.$this->blog.'\' '; 
    160164          if (null !== $type) 
    161                $req .= 'AND rateit_type=\''.$this->core->con->escape($type).'\' '; 
     165               $req .= 'AND rateit_type=\''.$this->con->escape($type).'\' '; 
    162166          if (null !== $id) 
    163                $req .= 'AND rateit_id=\''.$this->core->con->escape($id).'\' '; 
     167               $req .= 'AND rateit_id=\''.$this->con->escape($id).'\' '; 
    164168          if (null !== $ip) 
    165                $req .= 'AND rateit_ip=\''.$this->core->con->escape($ip).'\' '; 
    166  
    167           $rs = $this->core->con->select($req); 
     169               $req .= 'AND rateit_ip=\''.$this->con->escape($ip).'\' '; 
     170 
     171          $rs = $this->con->select($req); 
    168172          $this->core->blog->triggerBlog(); 
    169173     } 
     
    183187 
    184188          if (!empty($params['rateit_type'])) { 
    185                $params['sql'] .= "AND rateit_type = '".$this->core->con->escape($params['rateit_type'])."' "; 
     189               $params['sql'] .= "AND rateit_type = '".$this->con->escape($params['rateit_type'])."' "; 
    186190               unset($params['rateit_type']); 
    187191          } 
    188192 
    189193          if (!empty($params['post_type'])) { 
    190                $params['sql'] .= "AND post_type = '".$this->core->con->escape($params['post_type'])."' "; 
     194               $params['sql'] .= "AND post_type = '".$this->con->escape($params['post_type'])."' "; 
    191195               unset($params['post_type']); 
    192196          } 
     
    253257 
    254258          $strReq .= 
    255           " WHERE RI.blog_id = '".$this->core->con->escape($this->core->blog->id)."' "; 
     259          " WHERE RI.blog_id = '".$this->blog."' "; 
    256260 
    257261          # rate type 
     
    259263 
    260264               if (is_array($params['rateit_type']) && !empty($params['rateit_type'])) 
    261                     $strReq .= 'AND RI.rateit_type '.$this->core->con->in($params['rateit_type']); 
     265                    $strReq .= 'AND RI.rateit_type '.$this->con->in($params['rateit_type']); 
    262266               elseif ($params['rateit_type'] != '') 
    263                     $strReq .= "AND RI.rateit_type = '".$this->core->con->escape($params['rateit_type'])."' "; 
     267                    $strReq .= "AND RI.rateit_type = '".$this->con->escape($params['rateit_type'])."' "; 
    264268          } else 
    265269               $strReq .= "AND RI.rateit_type = 'post' "; 
     
    273277                    $params['rateit_id'] = array((integer) $params['rateit_id']); 
    274278 
    275                $strReq .= 'AND RI.rateit_id '.$this->core->con->in($params['rateit_id']); 
     279               $strReq .= 'AND RI.rateit_id '.$this->con->in($params['rateit_id']); 
    276280          } 
    277281 
     
    284288                    $params['rateit_ip'] = array((integer) $params['rateit_ip']); 
    285289 
    286                $strReq .= 'AND RI.rateit_ip '.$this->core->con->in($params['rateit_ip']); 
     290               $strReq .= 'AND RI.rateit_ip '.$this->con->in($params['rateit_ip']); 
    287291          } 
    288292 
     
    296300 
    297301               if (!empty($params['order'])) 
    298                     $strReq .= 'ORDER BY '.$this->core->con->escape($params['order']).' '; 
     302                    $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 
    299303               else 
    300304                    $strReq .= 'ORDER BY rateit_time DESC '; 
     
    302306 
    303307          if (!$count_only && !empty($params['limit'])) 
    304                $strReq .= $this->core->con->limit($params['limit']); 
     308               $strReq .= $this->con->limit($params['limit']); 
    305309 
    306310          $rs = $this->core->con->select($strReq); 
     
    322326               $req .= 'rateit_id,rateit_type,rateit_note,rateit_quotient,rateit_ip,rateit_time '; 
    323327 
    324           $req .= 'FROM '.$this->table.' WHERE blog_id=\''.$this->core->blog->id.'\' '; 
     328          $req .= 'FROM '.$this->table.' WHERE blog_id=\''.$this->blog.'\' '; 
    325329 
    326330          if (null !== $type) 
    327                $req .= 'AND rateit_type=\''.$this->core->con->escape($type).'\' '; 
     331               $req .= 'AND rateit_type=\''.$this->con->escape($type).'\' '; 
    328332          if (null !== $id) 
    329                $req .= 'AND rateit_id=\''.$this->core->con->escape($id).'\' '; 
     333               $req .= 'AND rateit_id=\''.$this->con->escape($id).'\' '; 
    330334          if (null !== $ip) 
    331                $req .= 'AND rateit_ip=\''.$this->core->con->escape($ip).'\' '; 
    332  
    333           $rs = $this->core->con->select($req); 
     335               $req .= 'AND rateit_ip=\''.$this->con->escape($ip).'\' '; 
     336 
     337          $rs = $this->con->select($req); 
    334338 
    335339          if ($count_only) 
  • plugins/rateIt/release.txt

    r1458 r1486  
     1x.x.x xxxxxxxx 
     2 - Not fixed bug with rate by cookie 
     3 
     40.9.6 20090923 
     5 * Fixed DC 2.1.6 URL handlers ending 
     6 * Added sort by sort rate by date (thanks to lottie14) 
     7 * Cleaned some stuff 
     8 
    190.9.5 20090915 
    210 * Fixed erreur 1071 in some MySQL servers 
Note: See TracChangeset for help on using the changeset viewer.

Sites map