Dotclear

Changeset 2626:8082d2ad2e34


Ignore:
Timestamp:
12/31/13 09:44:35 (10 years ago)
Author:
Dsls
Branch:
2.6
Message:

Removed pgsql/mysql specific code on comments processing, now working with sqlite closes #1912

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.blog.php

    r2566 r2626  
    21992199 
    22002200          $strReq = 
    2201                'UPDATE '.$this->prefix.'comment tc '; 
    2202  
    2203           # mySQL uses "JOIN" synthax 
    2204           if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') { 
    2205                $strReq .= 
    2206                     'JOIN '.$this->prefix.'post tp ON tc.post_id = tp.post_id '; 
    2207           } 
    2208  
     2201               'UPDATE '.$this->prefix.'comment '. 
     2202               'SET comment_status = '.$status.' '; 
    22092203          $strReq .= 
    2210                'SET comment_status = '.$status.' '; 
    2211  
    2212           # pgSQL uses "FROM" synthax 
    2213           if ($this->con->driver() != 'mysql' && $this->con->driver() != 'mysqli') { 
    2214                $strReq .= 
    2215                     'FROM '.$this->prefix.'post tp '; 
    2216           } 
    2217  
    2218           $strReq .= 
    2219                "WHERE blog_id = '".$this->con->escape($this->id)."' ". 
    2220                'AND comment_id'.$this->con->in($co_ids); 
    2221  
    2222           # add pgSQL "WHERE" clause 
    2223           if ($this->con->driver() != 'mysql' && $this->con->driver() != 'mysqli') { 
    2224                $strReq .= 
    2225                     'AND tc.post_id = tp.post_id '; 
    2226           } 
    2227  
    2228           #If user is only usage, we need to check the post's owner 
     2204               'WHERE comment_id'.$this->con->in($co_ids). 
     2205               'AND post_id in (SELECT tp.post_id '. 
     2206               'FROM '.$this->prefix.'post tp '. 
     2207               "WHERE tp.blog_id = '".$this->con->escape($this->id)."' "; 
    22292208          if (!$this->core->auth->check('contentadmin',$this->id)) 
    22302209          { 
     
    22322211                    "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    22332212          } 
    2234  
     2213          $strReq .= ')'; 
    22352214          $this->con->execute($strReq); 
    22362215          $this->triggerComments($co_ids); 
     
    22792258          } 
    22802259 
    2281           # mySQL uses "INNER JOIN" synthax 
    2282           if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') { 
    2283                $strReq = 
    2284                     'DELETE FROM tc '. 
    2285                     'USING '.$this->prefix.'comment tc '. 
    2286                     'INNER JOIN '.$this->prefix.'post tp '; 
    2287           } 
    2288           # pgSQL uses nothing special 
    2289           else { 
    2290                $strReq = 
    2291                     'DELETE FROM '.$this->prefix.'comment tc '. 
    2292                     'USING '.$this->prefix.'post tp '; 
    2293           } 
    2294  
    2295           $strReq .= 
    2296                'WHERE tc.post_id = tp.post_id '. 
    2297                "AND tp.blog_id = '".$this->con->escape($this->id)."' ". 
    2298                'AND comment_id'.$this->con->in($co_ids); 
    2299  
     2260          $strReq = 
     2261               'DELETE FROM '.$this->prefix.'comment '. 
     2262               'WHERE comment_id'.$this->con->in($co_ids).' '. 
     2263               'AND post_id in (SELECT tp.post_id '. 
     2264               'FROM '.$this->prefix.'post tp '. 
     2265               "WHERE tp.blog_id = '".$this->con->escape($this->id)."' "; 
    23002266          #If user can only delete, we need to check the post's owner 
    23012267          if (!$this->core->auth->check('contentadmin',$this->id)) 
    23022268          { 
    23032269               $strReq .= 
    2304                     "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    2305           } 
    2306  
     2270                    "AND tp.user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
     2271          } 
     2272          $strReq .= ")"; 
    23072273          $this->con->execute($strReq); 
    23082274          $this->triggerComments($co_ids, true, $affected_posts); 
     
    23162282          } 
    23172283 
    2318           # mySQL uses "INNER JOIN" synthax 
    2319           if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') { 
    2320                $strReq = 
    2321                     'DELETE FROM tc '. 
    2322                     'USING '.$this->prefix.'comment tc '. 
    2323                     'INNER JOIN '.$this->prefix.'post tp '; 
    2324           } 
    2325           # pgSQL uses nothing special 
    2326           else { 
    2327                $strReq = 
    2328                     'DELETE FROM '.$this->prefix.'comment tc '. 
    2329                     'USING '.$this->prefix.'post tp '; 
    2330           } 
    2331  
    2332           $strReq .= 
    2333                'WHERE tc.post_id = tp.post_id '. 
    2334                "AND tp.blog_id = '".$this->con->escape($this->id)."' ". 
    2335                'AND comment_status = -2'; 
    2336  
     2284          $strReq = 
     2285               'DELETE FROM '.$this->prefix.'comment '. 
     2286               'WHERE comment_status = -2 '. 
     2287               'AND post_id in (SELECT tp.post_id '. 
     2288               'FROM '.$this->prefix.'post tp '. 
     2289               "WHERE tp.blog_id = '".$this->con->escape($this->id)."' "; 
    23372290          #If user can only delete, we need to check the post's owner 
    23382291          if (!$this->core->auth->check('contentadmin',$this->id)) 
    23392292          { 
    23402293               $strReq .= 
    2341                     "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    2342           } 
    2343  
     2294                    "AND tp.user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
     2295          } 
     2296          $strReq .= ")"; 
    23442297          $this->con->execute($strReq); 
    23452298          $this->triggerBlog(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map