Dotclear


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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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) 
Note: See TracChangeset for help on using the changeset viewer.

Sites map