Dotclear

Changeset 2521:d11c986607d2


Ignore:
Timestamp:
11/08/13 08:14:28 (12 years ago)
Author:
Dsls
Branch:
default
Message:

Now support multiple comment_id in dcBlog::getComments. Fixes #1849

File:
1 edited

Legend:

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

    r2318 r2521  
    2727     /** @var string Database table prefix */ 
    2828     public $prefix; 
    29       
     29 
    3030     /** @var string Blog ID */ 
    3131     public $id; 
     
    4646     /** @var string Blog status */ 
    4747     public $status; 
    48       
     48 
    4949     /** @var dcSettings dcSettings object */ 
    5050     public $settings; 
     
    5353     /** @var string Blog public path */ 
    5454     public $public_path; 
    55       
     55 
    5656     private $post_status = array(); 
    5757     private $comment_status = array(); 
    58       
     58 
    5959     private $categories; 
    60       
     60 
    6161     /** @var boolean Disallow entries password protection */ 
    6262     public $without_password = true; 
    63       
     63 
    6464     /** 
    6565     Inits dcBlog object 
    66       
     66 
    6767     @param    core      <b>dcCore</b>       Dotclear core reference 
    6868     @param    id        <b>string</b>       Blog ID 
     
    7373          $this->prefix = $core->prefix; 
    7474          $this->core =& $core; 
    75            
     75 
    7676          if (($b = $this->core->getBlog($id)) !== false) 
    7777          { 
     
    8585               $this->upddt = strtotime($b->blog_upddt); 
    8686               $this->status = $b->blog_status; 
    87                 
     87 
    8888               $this->settings = new dcSettings($this->core,$this->id); 
    89                 
     89 
    9090               $this->themes_path = path::fullFromRoot($this->settings->system->themes_path,DC_ROOT); 
    9191               $this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT); 
    92                 
     92 
    9393               $this->post_status['-2'] = __('Pending'); 
    9494               $this->post_status['-1'] = __('Scheduled'); 
    9595               $this->post_status['0'] = __('Unpublished'); 
    9696               $this->post_status['1'] = __('Published'); 
    97                 
     97 
    9898               $this->comment_status['-2'] = __('Junk'); 
    9999               $this->comment_status['-1'] = __('Pending'); 
    100100               $this->comment_status['0'] = __('Unpublished'); 
    101101               $this->comment_status['1'] = __('Published'); 
    102                 
     102 
    103103               # --BEHAVIOR-- coreBlogConstruct 
    104104               $this->core->callBehavior('coreBlogConstruct',$this); 
    105105          } 
    106106     } 
    107       
     107 
    108108     /// @name Common public methods 
    109109     //@{ 
     
    116116               return $this->url.'?'; 
    117117          } 
    118            
     118 
    119119          return $this->url; 
    120120     } 
    121       
     121 
    122122     /** 
    123123     Returns an entry status name given to a code. Status are translated, never 
    124124     use it for tests. If status code does not exist, returns <i>unpublished</i>. 
    125       
     125 
    126126     @param    s    <b>integer</b> Status code 
    127127     @return   <b>string</b> Blog status name 
     
    134134          return $this->post_status['0']; 
    135135     } 
    136       
     136 
    137137     /** 
    138138     Returns an array of available entry status codes and names. 
    139       
     139 
    140140     @return   <b>array</b> Simple array with codes in keys and names in value 
    141141     */ 
     
    144144          return $this->post_status; 
    145145     } 
    146       
     146 
    147147     /** 
    148148     Returns an array of available comment status codes and names. 
    149       
     149 
    150150     @return   <b>array</b> Simple array with codes in keys and names in value 
    151151     */ 
     
    154154          return $this->comment_status; 
    155155     } 
    156       
     156 
    157157     /** 
    158158     Disallows entries password protection. You need to set it to 
    159159     <var>false</var> while serving a public blog. 
    160       
     160 
    161161     @param    v         <b>boolean</b> 
    162162     */ 
     
    166166     } 
    167167     //@} 
    168       
     168 
    169169     /// @name Triggers methods 
    170170     //@{ 
     
    176176     { 
    177177          $cur = $this->con->openCursor($this->prefix.'blog'); 
    178            
     178 
    179179          $cur->blog_upddt = date('Y-m-d H:i:s'); 
    180            
     180 
    181181          $cur->update("WHERE blog_id = '".$this->con->escape($this->id)."' "); 
    182            
     182 
    183183          # --BEHAVIOR-- coreBlogAfterTriggerBlog 
    184184          $this->core->callBehavior('coreBlogAfterTriggerBlog',$cur); 
    185185     } 
    186       
     186 
    187187     /** 
    188188     Updates comment and trackback counters in post table. Should be called 
    189189     every time a comment or trackback is added, removed or changed its status. 
    190       
     190 
    191191     @param    id        <b>integer</b>      Comment ID 
    192192     @param    del       <b>boolean</b>      If comment is delete, set this to true 
     
    196196          $this->triggerComments($id,$del); 
    197197     } 
    198       
     198 
    199199     /** 
    200200     Updates comments and trackbacks counters in post table. Should be called 
    201201     every time comments or trackbacks are added, removed or changed their status. 
    202       
     202 
    203203     @param    ids       <b>mixed</b>        Comment(s) ID(s) 
    204204     @param    del       <b>boolean</b>      If comment is delete, set this to true 
     
    208208     { 
    209209          $comments_ids = dcUtils::cleanIds($ids); 
    210            
     210 
    211211          # Get posts affected by comments edition 
    212212          if (empty($affected_posts)) { 
    213                $strReq =  
     213               $strReq = 
    214214                    'SELECT post_id '. 
    215215                    'FROM '.$this->prefix.'comment '. 
    216216                    'WHERE comment_id'.$this->con->in($comments_ids). 
    217217                    'GROUP BY post_id'; 
    218                 
     218 
    219219               $rs = $this->con->select($strReq); 
    220                 
     220 
    221221               $affected_posts = array(); 
    222222               while ($rs->fetch()) { 
     
    224224               } 
    225225          } 
    226            
     226 
    227227          if (!is_array($affected_posts) || empty($affected_posts)) { 
    228228               return; 
    229229          } 
    230            
     230 
    231231          # Count number of comments if exists for affected posts 
    232           $strReq =  
     232          $strReq = 
    233233               'SELECT post_id, COUNT(post_id) AS nb_comment, comment_trackback '. 
    234234               'FROM '.$this->prefix.'comment '. 
     
    236236               'AND post_id'.$this->con->in($affected_posts). 
    237237               'GROUP BY post_id,comment_trackback'; 
    238            
     238 
    239239          $rs = $this->con->select($strReq); 
    240            
     240 
    241241          $posts = array(); 
    242242          while ($rs->fetch()) { 
     
    247247               } 
    248248          } 
    249            
     249 
    250250          # Update number of comments on affected posts 
    251251          $cur = $this->con->openCursor($this->prefix.'post'); 
     
    253253          { 
    254254               $cur->clean(); 
    255                 
     255 
    256256               if (!array_key_exists($post_id,$posts)) { 
    257257                    $cur->nb_trackback = 0; 
     
    261261                    $cur->nb_comment = empty($posts[$post_id]['comment']) ? 0 : $posts[$post_id]['comment']; 
    262262               } 
    263                 
     263 
    264264               $cur->update('WHERE post_id = '.$post_id); 
    265265          } 
    266266     } 
    267267     //@} 
    268       
     268 
    269269     /// @name Categories management methods 
    270270     //@{ 
     
    274274               $this->categories = new dcCategories($this->core); 
    275275          } 
    276            
     276 
    277277          return $this->categories; 
    278278     } 
    279       
     279 
    280280     /** 
    281281     Retrieves categories. <var>$params</var> is an associative array which can 
    282282     take the following parameters: 
    283       
     283 
    284284     - post_type: Get only entries with given type (default "post") 
    285285     - cat_url: filter on cat_url field 
     
    287287     - start: start with a given category 
    288288     - level: categories level to retrieve 
    289       
     289 
    290290     @param    params    <b>array</b>        Parameters 
    291291     @return   <b>record</b> 
     
    299299          } 
    300300          $counter = $this->getCategoriesCounter($c_params); 
    301            
     301 
    302302          if (isset($params['without_empty']) && ($params['without_empty'] == false)) { 
    303303               $without_empty = false; 
     
    305305               $without_empty = $this->core->auth->userID() == false; # Get all categories if in admin display 
    306306          } 
    307            
     307 
    308308          $start = isset($params['start']) ? (integer) $params['start'] : 0; 
    309309          $l = isset($params['level']) ? (integer) $params['level'] : 0; 
    310            
     310 
    311311          $rs = $this->categories()->getChildren($start,null,'desc'); 
    312            
     312 
    313313          # Get each categories total posts count 
    314314          $data = array(); 
     
    319319          { 
    320320               $nb_post = isset($counter[$rs->cat_id]) ? (integer) $counter[$rs->cat_id] : 0; 
    321                 
     321 
    322322               if ($rs->level > $level) { 
    323323                    $nb_total = $nb_post; 
     
    335335                    unset($stack[$rs->level+1]); 
    336336               } 
    337                 
     337 
    338338               if ($nb_total == 0 && $without_empty) { 
    339339                    continue; 
    340340               } 
    341                 
     341 
    342342               $level = $rs->level; 
    343                 
     343 
    344344               $t = array(); 
    345345               foreach ($cols as $c) { 
     
    348348               $t['nb_post'] = $nb_post; 
    349349               $t['nb_total'] = $nb_total; 
    350                 
     350 
    351351               if ($l == 0 || ($l > 0 && $l == $rs->level)) { 
    352352                    array_unshift($data,$t); 
    353353               } 
    354354          } 
    355            
     355 
    356356          # We need to apply filter after counting 
    357357          if (isset($params['cat_id']) && $params['cat_id'] !== '') 
     
    369369               } 
    370370          } 
    371            
    372           if (isset($params['cat_url']) && ($params['cat_url'] !== '')  
     371 
     372          if (isset($params['cat_url']) && ($params['cat_url'] !== '') 
    373373               && !isset($params['cat_id'])) 
    374374          { 
     
    385385               } 
    386386          } 
    387            
     387 
    388388          return staticRecord::newFromArray($data); 
    389389     } 
    390       
     390 
    391391     /** 
    392392     Retrieves a category by its ID. 
    393       
     393 
    394394     @param    id        <b>integer</b>      Category ID 
    395395     @return   <b>record</b> 
     
    399399          return $this->getCategories(array('cat_id' => $id)); 
    400400     } 
    401       
     401 
    402402     /** 
    403403     Retrieves parents of a given category. 
    404       
     404 
    405405     @param    id        <b>integer</b>      Category ID 
    406406     @return   <b>record</b> 
     
    410410          return $this->categories()->getParents($id); 
    411411     } 
    412       
     412 
    413413     /** 
    414414     Retrieves first parent of a given category. 
    415       
     415 
    416416     @param    id        <b>integer</b>      Category ID 
    417417     @return   <b>record</b> 
     
    421421          return $this->categories()->getParent($id); 
    422422     } 
    423       
     423 
    424424     /** 
    425425     Retrieves all category's first children 
    426       
     426 
    427427     @param    id        <b>integer</b>      Category ID 
    428428     @return   <b>record</b> 
     
    432432          return $this->getCategories(array('start' => $id,'level' => $id == 0 ? 1 : 2)); 
    433433     } 
    434       
     434 
    435435     private function getCategoriesCounter($params=array()) 
    436436     { 
     
    440440          'JOIN '.$this->prefix."post P ON (C.cat_id = P.cat_id AND P.blog_id = '".$this->con->escape($this->id)."' ) ". 
    441441          "WHERE C.blog_id = '".$this->con->escape($this->id)."' "; 
    442            
     442 
    443443          if (!$this->core->auth->userID()) { 
    444444               $strReq .= 'AND P.post_status = 1 '; 
    445445          } 
    446            
     446 
    447447          if (!empty($params['post_type'])) { 
    448448               $strReq .= 'AND P.post_type '.$this->con->in($params['post_type']); 
    449449          } 
    450            
     450 
    451451          $strReq .= 'GROUP BY C.cat_id '; 
    452            
     452 
    453453          $rs = $this->con->select($strReq); 
    454454          $counters = array(); 
     
    456456               $counters[$rs->cat_id] = $rs->nb_post; 
    457457          } 
    458            
     458 
    459459          return $counters; 
    460460     } 
    461       
     461 
    462462     /** 
    463463     Creates a new category. Takes a cursor as input and returns the new category 
    464464     ID. 
    465       
     465 
    466466     @param    cur       <b>cursor</b>       Category cursor 
    467467     @return   <b>integer</b>      New category ID 
     
    472472               throw new Exception(__('You are not allowed to add categories')); 
    473473          } 
    474            
     474 
    475475          $url = array(); 
    476476          if ($parent != 0) 
     
    483483               } 
    484484          } 
    485            
     485 
    486486          if ($cur->cat_url == '') { 
    487487               $url[] = text::tidyURL($cur->cat_title,false); 
     
    489489               $url[] = $cur->cat_url; 
    490490          } 
    491            
     491 
    492492          $cur->cat_url = implode('/',$url); 
    493            
     493 
    494494          $this->getCategoryCursor($cur); 
    495495          $cur->blog_id = (string) $this->id; 
    496            
     496 
    497497          # --BEHAVIOR-- coreBeforeCategoryCreate 
    498498          $this->core->callBehavior('coreBeforeCategoryCreate',$this,$cur); 
    499            
     499 
    500500          $id = $this->categories()->addNode($cur,$parent); 
    501501          # Update category's cursor 
     
    505505               $cur->cat_rgt = $rs->cat_rgt; 
    506506          } 
    507            
     507 
    508508          # --BEHAVIOR-- coreAfterCategoryCreate 
    509509          $this->core->callBehavior('coreAfterCategoryCreate',$this,$cur); 
    510510          $this->triggerBlog(); 
    511            
     511 
    512512          return $cur->cat_id; 
    513513     } 
    514       
     514 
    515515     /** 
    516516     Updates an existing category. 
    517       
     517 
    518518     @param    id        <b>integer</b>      Category ID 
    519519     @param    cur       <b>cursor</b>       Category cursor 
     
    524524               throw new Exception(__('You are not allowed to update categories')); 
    525525          } 
    526            
     526 
    527527          if ($cur->cat_url == '') 
    528528          { 
     
    534534                    } 
    535535               } 
    536                 
    537                 
     536 
     537 
    538538               $url[] = text::tidyURL($cur->cat_title,false); 
    539539               $cur->cat_url = implode('/',$url); 
    540540          } 
    541            
     541 
    542542          $this->getCategoryCursor($cur,$id); 
    543            
     543 
    544544          # --BEHAVIOR-- coreBeforeCategoryUpdate 
    545545          $this->core->callBehavior('coreBeforeCategoryUpdate',$this,$cur); 
    546            
     546 
    547547          $cur->update( 
    548548          'WHERE cat_id = '.(integer) $id.' '. 
    549549          "AND blog_id = '".$this->con->escape($this->id)."' "); 
    550            
     550 
    551551          # --BEHAVIOR-- coreAfterCategoryUpdate 
    552552          $this->core->callBehavior('coreAfterCategoryUpdate',$this,$cur); 
    553            
     553 
    554554          $this->triggerBlog(); 
    555555     } 
     
    567567                $this->triggerBlog(); 
    568568        } 
    569       
     569 
    570570     /** 
    571571     DEPRECATED METHOD. Use dcBlog::setCategoryParent and dcBlog::moveCategory 
    572572     instead. 
    573       
     573 
    574574     @param    id        <b>integer</b>      Category ID 
    575575     @param    order     <b>integer</b>      Category position 
     
    579579          return; 
    580580     } 
    581       
     581 
    582582     /** 
    583583     Set a category parent 
    584       
     584 
    585585     @param    id        <b>integer</b>      Category ID 
    586586     @param    parent    <b>integer</b>      Parent Category ID 
     
    591591          $this->triggerBlog(); 
    592592     } 
    593       
     593 
    594594     /** 
    595595     Set category position 
    596       
     596 
    597597     @param    id        <b>integer</b>      Category ID 
    598598     @param    sibling   <b>integer</b>      Sibling Category ID 
     
    604604          $this->triggerBlog(); 
    605605     } 
    606       
     606 
    607607     /** 
    608608     Deletes a category. 
    609       
     609 
    610610     @param    id        <b>integer</b>      Category ID 
    611611     */ 
     
    615615               throw new Exception(__('You are not allowed to delete categories')); 
    616616          } 
    617            
     617 
    618618          $strReq = 'SELECT COUNT(post_id) AS nb_post '. 
    619619                    'FROM '.$this->prefix.'post '. 
    620620                    'WHERE cat_id = '.(integer) $id.' '. 
    621621                    "AND blog_id = '".$this->con->escape($this->id)."' "; 
    622            
     622 
    623623          $rs = $this->con->select($strReq); 
    624            
     624 
    625625          if ($rs->nb_post > 0) { 
    626626               throw new Exception(__('This category is not empty.')); 
    627627          } 
    628            
     628 
    629629          $this->categories()->deleteNode($id,true); 
    630630          $this->triggerBlog(); 
    631631     } 
    632       
     632 
    633633     /** 
    634634     Reset categories order and relocate them to first level 
     
    639639               throw new Exception(__('You are not allowed to reset categories order')); 
    640640          } 
    641            
     641 
    642642          $this->categories()->resetOrder(); 
    643643          $this->triggerBlog(); 
    644644     } 
    645       
     645 
    646646     private function checkCategory($title,$url,$id=null) 
    647647     { 
    648648          # Let's check if URL is taken... 
    649           $strReq =  
     649          $strReq = 
    650650               'SELECT cat_url FROM '.$this->prefix.'category '. 
    651651               "WHERE cat_url = '".$this->con->escape($url)."' ". 
     
    653653               "AND blog_id = '".$this->con->escape($this->id)."' ". 
    654654               'ORDER BY cat_url DESC'; 
    655            
     655 
    656656          $rs = $this->con->select($strReq); 
    657            
     657 
    658658          if (!$rs->isEmpty()) 
    659659          { 
     
    665665                    $clause = "LIKE '".$this->con->escape($url)."%'"; 
    666666               } 
    667                $strReq =  
     667               $strReq = 
    668668                    'SELECT cat_url FROM '.$this->prefix.'category '. 
    669669                    "WHERE cat_url ".$clause.' '. 
     
    671671                    "AND blog_id = '".$this->con->escape($this->id)."' ". 
    672672                    'ORDER BY cat_url DESC '; 
    673                 
     673 
    674674               $rs = $this->con->select($strReq); 
    675675               $a = array(); 
     
    677677                    $a[] = $rs->cat_url; 
    678678               } 
    679                 
     679 
    680680               natsort($a); 
    681681               $t_url = end($a); 
    682                 
     682 
    683683               if (preg_match('/(.*?)([0-9]+)$/',$t_url,$m)) { 
    684684                    $i = (integer) $m[2]; 
     
    687687                    $i = 1; 
    688688               } 
    689                 
     689 
    690690               return $url.($i+1); 
    691691          } 
    692            
     692 
    693693          # URL is empty? 
    694694          if ($url == '') { 
    695695               throw new Exception(__('Empty category URL')); 
    696696          } 
    697            
     697 
    698698          return $url; 
    699699     } 
    700       
     700 
    701701     private function getCategoryCursor($cur,$id=null) 
    702702     { 
     
    704704               throw new Exception(__('You must provide a category title')); 
    705705          } 
    706            
     706 
    707707          # If we don't have any cat_url, let's do one 
    708708          if ($cur->cat_url == '') { 
    709709               $cur->cat_url = text::tidyURL($cur->cat_title,false); 
    710710          } 
    711            
     711 
    712712          # Still empty ? 
    713713          if ($cur->cat_url == '') { 
     
    716716               $cur->cat_url = text::tidyURL($cur->cat_url,true); 
    717717          } 
    718            
     718 
    719719          # Check if title or url are unique 
    720720          $cur->cat_url = $this->checkCategory($cur->cat_title,$cur->cat_url,$id); 
    721            
     721 
    722722          if ($cur->cat_desc !== null) { 
    723723               $cur->cat_desc = $this->core->HTMLfilter($cur->cat_desc); 
     
    725725     } 
    726726     //@} 
    727       
     727 
    728728     /// @name Entries management methods 
    729729     //@{ 
     
    731731     Retrieves entries. <b>$params</b> is an array taking the following 
    732732     optionnal parameters: 
    733       
     733 
    734734     - no_content: Don't retrieve entry content (excerpt and content) 
    735735     - post_type: Get only entries with given type (default "post", array for many types and '' for no type) 
     
    755755     - sql_only : return the sql request instead of results. Only ids are selected 
    756756     - exclude_post_id : (integer or array) Exclude entries with given post_id 
    757       
     757 
    758758     Please note that on every cat_id or cat_url, you can add ?not to exclude 
    759759     the category and ?sub to get subcategories. 
    760       
     760 
    761761     @param    params         <b>array</b>        Parameters 
    762762     @param    count_only     <b>boolean</b>      Only counts results 
     
    773773               $strReq = 'SELECT count(DISTINCT P.post_id) '; 
    774774          } 
    775           elseif (!empty($params['sql_only']))  
     775          elseif (!empty($params['sql_only'])) 
    776776          { 
    777777               $strReq = 'SELECT P.post_id '; 
     
    786786                    'post_content, post_content_xhtml, post_notes, '; 
    787787               } 
    788                 
     788 
    789789               if (!empty($params['columns']) && is_array($params['columns'])) { 
    790790                    $content_req .= implode(', ',$params['columns']).', '; 
    791791               } 
    792                 
     792 
    793793 
    794794               $strReq = 
     
    802802               'C.cat_title, C.cat_url, C.cat_desc '; 
    803803          } 
    804            
     804 
    805805          $strReq .= 
    806806          'FROM '.$this->prefix.'post P '. 
     
    811811               $strReq .= $params['from'].' '; 
    812812          } 
    813            
     813 
    814814          $strReq .= 
    815815          "WHERE P.blog_id = '".$this->con->escape($this->id)."' "; 
    816            
     816 
    817817          if (!$this->core->auth->check('contentadmin',$this->id)) { 
    818818               $strReq .= 'AND ((post_status = 1 '; 
    819                 
     819 
    820820               if ($this->without_password) { 
    821821                    $strReq .= 'AND post_password IS NULL '; 
    822822               } 
    823823               $strReq .= ') '; 
    824                 
     824 
    825825               if ($this->core->auth->userID()) { 
    826826                    $strReq .= "OR P.user_id = '".$this->con->escape($this->core->auth->userID())."')"; 
     
    829829               } 
    830830          } 
    831            
     831 
    832832          #Adding parameters 
    833833          if (isset($params['post_type'])) 
     
    841841               $strReq .= "AND post_type = 'post' "; 
    842842          } 
    843            
     843 
    844844          if (isset($params['post_id']) && $params['post_id'] !== '') { 
    845845               if (is_array($params['post_id'])) { 
     
    850850               $strReq .= 'AND P.post_id '.$this->con->in($params['post_id']); 
    851851          } 
    852            
     852 
    853853          if (isset($params['exclude_post_id']) && $params['exclude_post_id'] !== '') { 
    854854               if (is_array($params['exclude_post_id'])) { 
     
    859859               $strReq .= 'AND P.post_id NOT '.$this->con->in($params['exclude_post_id']); 
    860860          } 
    861            
     861 
    862862          if (isset($params['post_url']) && $params['post_url'] !== '') { 
    863863               $strReq .= "AND post_url = '".$this->con->escape($params['post_url'])."' "; 
    864864          } 
    865            
     865 
    866866          if (!empty($params['user_id'])) { 
    867867               $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 
    868868          } 
    869            
     869 
    870870          if (isset($params['cat_id']) && $params['cat_id'] !== '') 
    871871          { 
     
    888888               $strReq .= 'AND '.$this->getPostsCategoryFilter($params['cat_url'],'cat_url').' '; 
    889889          } 
    890            
     890 
    891891          /* Other filters */ 
    892892          if (isset($params['post_status'])) { 
    893893               $strReq .= 'AND post_status = '.(integer) $params['post_status'].' '; 
    894894          } 
    895            
     895 
    896896          if (isset($params['post_selected'])) { 
    897897               $strReq .= 'AND post_selected = '.(integer) $params['post_selected'].' '; 
    898898          } 
    899            
     899 
    900900          if (!empty($params['post_year'])) { 
    901901               $strReq .= 'AND '.$this->con->dateFormat('post_dt','%Y').' = '. 
    902902               "'".sprintf('%04d',$params['post_year'])."' "; 
    903903          } 
    904            
     904 
    905905          if (!empty($params['post_month'])) { 
    906906               $strReq .= 'AND '.$this->con->dateFormat('post_dt','%m').' = '. 
    907907               "'".sprintf('%02d',$params['post_month'])."' "; 
    908908          } 
    909            
     909 
    910910          if (!empty($params['post_day'])) { 
    911911               $strReq .= 'AND '.$this->con->dateFormat('post_dt','%d').' = '. 
    912912               "'".sprintf('%02d',$params['post_day'])."' "; 
    913913          } 
    914            
     914 
    915915          if (!empty($params['post_lang'])) { 
    916916               $strReq .= "AND P.post_lang = '".$this->con->escape($params['post_lang'])."' "; 
    917917          } 
    918            
     918 
    919919          if (!empty($params['search'])) 
    920920          { 
    921921               $words = text::splitWords($params['search']); 
    922                 
     922 
    923923               if (!empty($words)) 
    924924               { 
     
    927927                         $this->core->callBehavior('corePostSearch',$this->core,array(&$words,&$strReq,&$params)); 
    928928                    } 
    929                      
     929 
    930930                    if ($words) 
    931931                    { 
     
    937937               } 
    938938          } 
    939            
     939 
    940940          if (isset($params['media'])) { 
    941941               if ($params['media'] == '0') { 
    942942                    $strReq .= 'AND NOT '; 
    943943               } else { 
    944                     $strReq .= 'AND ';                  
     944                    $strReq .= 'AND '; 
    945945               } 
    946946               $strReq .= 'EXISTS (SELECT M.post_id FROM '.$this->prefix.'post_media M '. 
     
    964964               } 
    965965          } 
    966            
     966 
    967967          if (!$count_only && !empty($params['limit'])) { 
    968968               $strReq .= $this->con->limit($params['limit']); 
    969969          } 
    970            
     970 
    971971          if (!empty($params['sql_only'])) { 
    972972               return $strReq; 
     
    977977          $rs->_nb_media = array(); 
    978978          $rs->extend('rsExtPost'); 
    979            
     979 
    980980          # --BEHAVIOR-- coreBlogGetPosts 
    981981          $this->core->callBehavior('coreBlogGetPosts',$rs); 
    982            
     982 
    983983          return $rs; 
    984984     } 
    985       
     985 
    986986     /** 
    987987     Returns a record with post id, title and date for next or previous post 
    988988     according to the post ID. 
    989989     $dir could be 1 (next post) or -1 (previous post). 
    990       
     990 
    991991     @param    post_id                  <b>integer</b>      Post ID 
    992992     @param    dir                      <b>integer</b>      Search direction 
     
    999999          $dt = $post->post_dt; 
    10001000          $post_id = (integer) $post->post_id; 
    1001            
     1001 
    10021002          if($dir > 0) { 
    10031003               $sign = '>'; 
     
    10081008               $order = 'DESC'; 
    10091009          } 
    1010            
     1010 
    10111011          $params['post_type'] = $post->post_type; 
    10121012          $params['limit'] = 1; 
     
    10171017          "    OR post_dt ".$sign." '".$this->con->escape($dt)."' ". 
    10181018          ') '; 
    1019            
     1019 
    10201020          if ($restrict_to_category) { 
    10211021               $params['sql'] .= $post->cat_id ? 'AND P.cat_id = '.(integer) $post->cat_id.' ' : 'AND P.cat_id IS NULL '; 
    10221022          } 
    1023            
     1023 
    10241024          if ($restrict_to_lang) { 
    10251025               $params['sql'] .= $post->post_lang ? 'AND P.post_lang = \''. $this->con->escape($post->post_lang) .'\' ': 'AND P.post_lang IS NULL '; 
    10261026          } 
    1027            
     1027 
    10281028          $rs = $this->getPosts($params); 
    1029            
     1029 
    10301030          if ($rs->isEmpty()) { 
    10311031               return null; 
    10321032          } 
    1033            
     1033 
    10341034          return $rs; 
    10351035     } 
    1036       
     1036 
    10371037     /** 
    10381038     Retrieves different languages and post count on blog, based on post_lang 
    10391039     field. <var>$params</var> is an array taking the following optionnal 
    10401040     parameters: 
    1041       
     1041 
    10421042     - post_type: Get only entries with given type (default "post", '' for no type) 
    10431043     - lang: retrieve post count for selected lang 
    10441044     - order: order statement (default post_lang DESC) 
    1045       
     1045 
    10461046     @param    params    <b>array</b>        Parameters 
    10471047     @return   record 
     
    10541054                    "AND post_lang <> '' ". 
    10551055                    "AND post_lang IS NOT NULL "; 
    1056            
     1056 
    10571057          if (!$this->core->auth->check('contentadmin',$this->id)) { 
    10581058               $strReq .= 'AND ((post_status = 1 '; 
    1059                 
     1059 
    10601060               if ($this->without_password) { 
    10611061                    $strReq .= 'AND post_password IS NULL '; 
    10621062               } 
    10631063               $strReq .= ') '; 
    1064                 
     1064 
    10651065               if ($this->core->auth->userID()) { 
    10661066                    $strReq .= "OR user_id = '".$this->con->escape($this->core->auth->userID())."')"; 
     
    10691069               } 
    10701070          } 
    1071            
     1071 
    10721072          if (isset($params['post_type'])) { 
    10731073               if ($params['post_type'] != '') { 
     
    10771077               $strReq .= "AND post_type = 'post' "; 
    10781078          } 
    1079            
     1079 
    10801080          if (isset($params['lang'])) { 
    10811081               $strReq .= "AND post_lang = '".$this->con->escape($params['lang'])."' "; 
    10821082          } 
    1083            
     1083 
    10841084          $strReq .= 'GROUP BY post_lang '; 
    1085            
     1085 
    10861086          $order = 'desc'; 
    10871087          if (!empty($params['order']) && preg_match('/^(desc|asc)$/i',$params['order'])) { 
     
    10891089          } 
    10901090          $strReq .= 'ORDER BY post_lang '.$order.' '; 
    1091            
     1091 
    10921092          return $this->con->select($strReq); 
    10931093     } 
    1094       
     1094 
    10951095     /** 
    10961096     Returns a record with all distinct blog dates and post count. 
    10971097     <var>$params</var> is an array taking the following optionnal parameters: 
    1098       
     1098 
    10991099     - type: (day|month|year) Get days, months or years 
    11001100     - year: (integer) Get dates for given year 
     
    11071107     - previous: Get date before match 
    11081108     - order: Sort by date "ASC" or "DESC" 
    1109       
     1109 
    11101110     @param    params    <b>array</b>        Parameters array 
    11111111     @return   record 
     
    11261126          $dt_f .= ' 00:00:00'; 
    11271127          $dt_fc .= '000000'; 
    1128            
     1128 
    11291129          $cat_field = $catReq = $limit = ''; 
    1130            
     1130 
    11311131          if (isset($params['cat_id']) && $params['cat_id'] !== '') { 
    11321132               $catReq = 'AND P.cat_id = '.(integer) $params['cat_id'].' '; 
     
    11391139               $catReq = 'AND P.post_lang = \''. $params['post_lang'].'\' '; 
    11401140          } 
    1141            
     1141 
    11421142          $strReq = 'SELECT DISTINCT('.$this->con->dateFormat('post_dt',$dt_f).') AS dt '. 
    11431143                    $cat_field. 
     
    11471147                    "WHERE P.blog_id = '".$this->con->escape($this->id)."' ". 
    11481148                    $catReq; 
    1149            
     1149 
    11501150          if (!$this->core->auth->check('contentadmin',$this->id)) { 
    11511151               $strReq .= 'AND ((post_status = 1 '; 
    1152                 
     1152 
    11531153               if ($this->without_password) { 
    11541154                    $strReq .= 'AND post_password IS NULL '; 
    11551155               } 
    11561156               $strReq .= ') '; 
    1157                 
     1157 
    11581158               if ($this->core->auth->userID()) { 
    11591159                    $strReq .= "OR P.user_id = '".$this->con->escape($this->core->auth->userID())."')"; 
     
    11621162               } 
    11631163          } 
    1164            
     1164 
    11651165          if (!empty($params['post_type'])) { 
    11661166               $strReq .= "AND post_type ".$this->con->in($params['post_type'])." "; 
     
    11681168               $strReq .= "AND post_type = 'post' "; 
    11691169          } 
    1170            
     1170 
    11711171          if (!empty($params['year'])) { 
    11721172               $strReq .= 'AND '.$this->con->dateFormat('post_dt','%Y')." = '".sprintf('%04d',$params['year'])."' "; 
    11731173          } 
    1174            
     1174 
    11751175          if (!empty($params['month'])) { 
    11761176               $strReq .= 'AND '.$this->con->dateFormat('post_dt','%m')." = '".sprintf('%02d',$params['month'])."' "; 
    11771177          } 
    1178            
     1178 
    11791179          if (!empty($params['day'])) { 
    11801180               $strReq .= 'AND '.$this->con->dateFormat('post_dt','%d')." = '".sprintf('%02d',$params['day'])."' "; 
    11811181          } 
    1182            
     1182 
    11831183          # Get next or previous date 
    11841184          if (!empty($params['next']) || !empty($params['previous'])) 
     
    11931193                    $dt = $params['previous']; 
    11941194               } 
    1195                 
     1195 
    11961196               $dt = date('YmdHis',strtotime($dt)); 
    1197                 
     1197 
    11981198               $strReq .= 'AND '.$this->con->dateFormat('post_dt',$dt_fc).$pdir."'".$dt."' "; 
    11991199               $limit = $this->con->limit(1); 
    12001200          } 
    1201            
     1201 
    12021202          $strReq .= 'GROUP BY dt '.$cat_field; 
    1203            
     1203 
    12041204          $order = 'desc'; 
    12051205          if (!empty($params['order']) && preg_match('/^(desc|asc)$/i',$params['order'])) { 
    12061206               $order = $params['order']; 
    12071207          } 
    1208            
     1208 
    12091209          $strReq .= 
    12101210          'ORDER BY dt '.$order.' '. 
    12111211          $limit; 
    1212            
     1212 
    12131213          $rs = $this->con->select($strReq); 
    12141214          $rs->extend('rsExtDates'); 
    12151215          return $rs; 
    12161216     } 
    1217       
     1217 
    12181218     /** 
    12191219     Creates a new entry. Takes a cursor as input and returns the new entry 
    12201220     ID. 
    1221       
     1221 
    12221222     @param    cur       <b>cursor</b>       Post cursor 
    12231223     @return   <b>integer</b>      New post ID 
     
    12281228               throw new Exception(__('You are not allowed to create an entry')); 
    12291229          } 
    1230            
     1230 
    12311231          $this->con->writeLock($this->prefix.'post'); 
    12321232          try 
     
    12351235               $rs = $this->con->select( 
    12361236                    'SELECT MAX(post_id) '. 
    1237                     'FROM '.$this->prefix.'post '  
     1237                    'FROM '.$this->prefix.'post ' 
    12381238                    ); 
    1239                 
     1239 
    12401240               $cur->post_id = (integer) $rs->f(0) + 1; 
    12411241               $cur->blog_id = (string) $this->id; 
     
    12431243               $cur->post_upddt = date('Y-m-d H:i:s'); 
    12441244               $cur->post_tz = $this->core->auth->getInfo('user_tz'); 
    1245                 
     1245 
    12461246               # Post excerpt and content 
    12471247               $this->getPostContent($cur,$cur->post_id); 
    1248                 
     1248 
    12491249               $this->getPostCursor($cur); 
    1250                 
     1250 
    12511251               $cur->post_url = $this->getPostURL($cur->post_url,$cur->post_dt,$cur->post_title,$cur->post_id); 
    1252                 
     1252 
    12531253               if (!$this->core->auth->check('publish,contentadmin',$this->id)) { 
    12541254                    $cur->post_status = -2; 
    12551255               } 
    1256                 
     1256 
    12571257               # --BEHAVIOR-- coreBeforePostCreate 
    12581258               $this->core->callBehavior('coreBeforePostCreate',$this,$cur); 
    1259                 
     1259 
    12601260               $cur->insert(); 
    12611261               $this->con->unlock(); 
     
    12661266               throw $e; 
    12671267          } 
    1268            
     1268 
    12691269          # --BEHAVIOR-- coreAfterPostCreate 
    12701270          $this->core->callBehavior('coreAfterPostCreate',$this,$cur); 
    1271            
     1271 
    12721272          $this->triggerBlog(); 
    1273            
     1273 
    12741274          return $cur->post_id; 
    12751275     } 
    1276       
     1276 
    12771277     /** 
    12781278     Updates an existing post. 
    1279       
     1279 
    12801280     @param    id        <b>integer</b>      Post ID 
    12811281     @param    cur       <b>cursor</b>       Post cursor 
     
    12861286               throw new Exception(__('You are not allowed to update entries')); 
    12871287          } 
    1288            
     1288 
    12891289          $id = (integer) $id; 
    1290            
     1290 
    12911291          if (empty($id)) { 
    12921292               throw new Exception(__('No such entry ID')); 
    12931293          } 
    1294            
     1294 
    12951295          # Post excerpt and content 
    12961296          $this->getPostContent($cur,$id); 
    1297            
     1297 
    12981298          $this->getPostCursor($cur); 
    1299            
     1299 
    13001300          if ($cur->post_url !== null) { 
    13011301               $cur->post_url = $this->getPostURL($cur->post_url,$cur->post_dt,$cur->post_title,$id); 
    13021302          } 
    1303            
     1303 
    13041304          if (!$this->core->auth->check('publish,contentadmin',$this->id)) { 
    13051305               $cur->unsetField('post_status'); 
    13061306          } 
    1307            
     1307 
    13081308          $cur->post_upddt = date('Y-m-d H:i:s'); 
    1309            
     1309 
    13101310          #If user is only "usage", we need to check the post's owner 
    13111311          if (!$this->core->auth->check('contentadmin',$this->id)) 
     
    13151315                         'WHERE post_id = '.$id.' '. 
    13161316                         "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    1317                 
     1317 
    13181318               $rs = $this->con->select($strReq); 
    1319                 
     1319 
    13201320               if ($rs->isEmpty()) { 
    13211321                    throw new Exception(__('You are not allowed to edit this entry')); 
    13221322               } 
    13231323          } 
    1324            
     1324 
    13251325          # --BEHAVIOR-- coreBeforePostUpdate 
    13261326          $this->core->callBehavior('coreBeforePostUpdate',$this,$cur); 
    1327            
     1327 
    13281328          $cur->update('WHERE post_id = '.$id.' '); 
    1329            
     1329 
    13301330          # --BEHAVIOR-- coreAfterPostUpdate 
    13311331          $this->core->callBehavior('coreAfterPostUpdate',$this,$cur); 
    1332            
     1332 
    13331333          $this->triggerBlog(); 
    13341334     } 
    1335       
     1335 
    13361336     /** 
    13371337     Updates post status. 
    1338       
     1338 
    13391339     @param    id        <b>integer</b>      Post ID 
    13401340     @param    status    <b>integer</b>      Post status 
     
    13441344          $this->updPostsStatus($id,$status); 
    13451345     } 
    1346       
     1346 
    13471347     /** 
    13481348     Updates posts status. 
    1349       
     1349 
    13501350     @param    ids       <b>mixed</b>        Post(s) ID(s) 
    13511351     @param    status    <b>integer</b>      Post status 
     
    13561356               throw new Exception(__('You are not allowed to change this entry status')); 
    13571357          } 
    1358            
     1358 
    13591359          $posts_ids = dcUtils::cleanIds($ids); 
    13601360          $status = (integer) $status; 
    1361            
     1361 
    13621362          $strReq = "WHERE blog_id = '".$this->con->escape($this->id)."' ". 
    13631363                    "AND post_id ".$this->con->in($posts_ids); 
    1364            
     1364 
    13651365          #If user can only publish, we need to check the post's owner 
    13661366          if (!$this->core->auth->check('contentadmin',$this->id)) 
     
    13681368               $strReq .= "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    13691369          } 
    1370            
     1370 
    13711371          $cur = $this->con->openCursor($this->prefix.'post'); 
    1372            
     1372 
    13731373          $cur->post_status = $status; 
    13741374          $cur->post_upddt = date('Y-m-d H:i:s'); 
    1375            
     1375 
    13761376          $cur->update($strReq); 
    13771377          $this->triggerBlog(); 
    13781378     } 
    1379       
     1379 
    13801380     /** 
    13811381     Updates post selection. 
    1382       
     1382 
    13831383     @param    id        <b>integer</b>      Post ID 
    13841384     @param    selected  <b>integer</b>      Is selected post 
     
    13881388          $this->updPostsSelected($id,$selected); 
    13891389     } 
    1390       
     1390 
    13911391     /** 
    13921392     Updates posts selection. 
    1393       
     1393 
    13941394     @param    ids       <b>mixed</b>        Post(s) ID(s) 
    13951395     @param    selected  <b>integer</b>      Is selected post(s) 
     
    14001400               throw new Exception(__('You are not allowed to change this entry category')); 
    14011401          } 
    1402            
     1402 
    14031403          $posts_ids = dcUtils::cleanIds($ids); 
    14041404          $selected = (boolean) $selected; 
    1405            
     1405 
    14061406          $strReq = "WHERE blog_id = '".$this->con->escape($this->id)."' ". 
    14071407                    "AND post_id ".$this->con->in($posts_ids); 
    1408            
     1408 
    14091409          # If user is only usage, we need to check the post's owner 
    14101410          if (!$this->core->auth->check('contentadmin',$this->id)) 
     
    14121412               $strReq .= "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    14131413          } 
    1414            
     1414 
    14151415          $cur = $this->con->openCursor($this->prefix.'post'); 
    1416            
     1416 
    14171417          $cur->post_selected = (integer) $selected; 
    14181418          $cur->post_upddt = date('Y-m-d H:i:s'); 
    1419            
     1419 
    14201420          $cur->update($strReq); 
    14211421          $this->triggerBlog(); 
    14221422     } 
    1423       
     1423 
    14241424     /** 
    14251425     Updates post category. <var>$cat_id</var> can be null. 
    1426       
     1426 
    14271427     @param    id        <b>integer</b>      Post ID 
    14281428     @param    cat_id    <b>integer</b>      Category ID 
     
    14321432          $this->updPostsCategory($id,$cat_id); 
    14331433     } 
    1434       
     1434 
    14351435     /** 
    14361436     Updates posts category. <var>$cat_id</var> can be null. 
    1437       
     1437 
    14381438     @param    ids       <b>mixed</b>        Post(s) ID(s) 
    14391439     @param    cat_id    <b>integer</b>      Category ID 
     
    14441444               throw new Exception(__('You are not allowed to change this entry category')); 
    14451445          } 
    1446            
     1446 
    14471447          $posts_ids = dcUtils::cleanIds($ids); 
    14481448          $cat_id = (integer) $cat_id; 
    1449            
     1449 
    14501450          $strReq = "WHERE blog_id = '".$this->con->escape($this->id)."' ". 
    14511451                    "AND post_id ".$this->con->in($posts_ids); 
    1452            
     1452 
    14531453          # If user is only usage, we need to check the post's owner 
    14541454          if (!$this->core->auth->check('contentadmin',$this->id)) 
     
    14561456               $strReq .= "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    14571457          } 
    1458            
     1458 
    14591459          $cur = $this->con->openCursor($this->prefix.'post'); 
    1460            
     1460 
    14611461          $cur->cat_id = ($cat_id ? $cat_id : null); 
    14621462          $cur->post_upddt = date('Y-m-d H:i:s'); 
    1463            
     1463 
    14641464          $cur->update($strReq); 
    14651465          $this->triggerBlog(); 
    14661466     } 
    1467       
     1467 
    14681468     /** 
    14691469     Updates posts category. <var>$new_cat_id</var> can be null. 
    1470       
     1470 
    14711471     @param    old_cat_id     <b>integer</b>      Old category ID 
    14721472     @param    new_cat_id     <b>integer</b>      New category ID 
     
    14771477               throw new Exception(__('You are not allowed to change entries category')); 
    14781478          } 
    1479            
     1479 
    14801480          $old_cat_id = (integer) $old_cat_id; 
    14811481          $new_cat_id = (integer) $new_cat_id; 
    1482            
     1482 
    14831483          $cur = $this->con->openCursor($this->prefix.'post'); 
    1484            
     1484 
    14851485          $cur->cat_id = ($new_cat_id ? $new_cat_id : null); 
    14861486          $cur->post_upddt = date('Y-m-d H:i:s'); 
    1487            
     1487 
    14881488          $cur->update( 
    14891489               'WHERE cat_id = '.$old_cat_id.' '. 
     
    14921492          $this->triggerBlog(); 
    14931493     } 
    1494       
     1494 
    14951495     /** 
    14961496     Deletes a post. 
    1497       
     1497 
    14981498     @param    id        <b>integer</b>      Post ID 
    14991499     */ 
     
    15021502          $this->delPosts($id); 
    15031503     } 
    1504       
     1504 
    15051505     /** 
    15061506     Deletes multiple posts. 
    1507       
     1507 
    15081508     @param    ids       <b>mixed</b>        Post(s) ID(s) 
    15091509     */ 
     
    15131513               throw new Exception(__('You are not allowed to delete entries')); 
    15141514          } 
    1515            
     1515 
    15161516          $posts_ids = dcUtils::cleanIds($ids); 
    1517            
     1517 
    15181518          if (empty($posts_ids)) { 
    15191519               throw new Exception(__('No such entry ID')); 
    15201520          } 
    1521            
     1521 
    15221522          $strReq = 'DELETE FROM '.$this->prefix.'post '. 
    15231523                    "WHERE blog_id = '".$this->con->escape($this->id)."' ". 
    15241524                    "AND post_id ".$this->con->in($posts_ids); 
    1525            
     1525 
    15261526          #If user can only delete, we need to check the post's owner 
    15271527          if (!$this->core->auth->check('contentadmin',$this->id)) 
     
    15291529               $strReq .= "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    15301530          } 
    1531            
     1531 
    15321532          $this->con->execute($strReq); 
    15331533          $this->triggerBlog(); 
    15341534     } 
    1535       
     1535 
    15361536     /** 
    15371537     Publishes all entries flaged as "scheduled". 
     
    15431543                    'WHERE post_status = -1 '. 
    15441544                    "AND blog_id = '".$this->con->escape($this->id)."' "; 
    1545            
     1545 
    15461546          $rs = $this->con->select($strReq); 
    1547            
     1547 
    15481548          $now = dt::toUTC(time()); 
    15491549          $to_change = new ArrayObject(); 
     
    15521552               return; 
    15531553          } 
    1554            
     1554 
    15551555          while ($rs->fetch()) 
    15561556          { 
    15571557               # Now timestamp with post timezone 
    15581558               $now_tz = $now + dt::getTimeOffset($rs->post_tz,$now); 
    1559                 
     1559 
    15601560               # Post timestamp 
    15611561               $post_ts = strtotime($rs->post_dt); 
    1562                 
     1562 
    15631563               # If now_tz >= post_ts, we publish the entry 
    15641564               if ($now_tz >= $post_ts) { 
     
    15821582               $this->core->callBehavior('coreAfterScheduledEntriesPublish',$this,$to_change); 
    15831583          } 
    1584            
    1585      } 
    1586       
     1584 
     1585     } 
     1586 
    15871587     /** 
    15881588     Retrieves all users having posts on current blog. 
    1589       
     1589 
    15901590     @param    post_type      <b>string</b>       post_type filter (post) 
    15911591     @return   record 
     
    15981598                    'WHERE P.user_id = U.user_id '. 
    15991599                    "AND blog_id = '".$this->con->escape($this->id)."' "; 
    1600            
     1600 
    16011601          if ($post_type) { 
    16021602               $strReq .= "AND post_type = '".$this->con->escape($post_type)."' "; 
    16031603          } 
    1604            
     1604 
    16051605          $strReq .= 'GROUP BY P.user_id, user_name, user_firstname, user_displayname, user_email '; 
    1606            
     1606 
    16071607          return $this->con->select($strReq); 
    16081608     } 
    1609       
     1609 
    16101610     private function getPostsCategoryFilter($arr,$field='cat_id') 
    16111611     { 
    16121612          $field = $field == 'cat_id' ? 'cat_id' : 'cat_url'; 
    1613            
     1613 
    16141614          $sub = array(); 
    16151615          $not = array(); 
    16161616          $queries = array(); 
    1617            
     1617 
    16181618          foreach ($arr as $v) 
    16191619          { 
     
    16221622               $id = array_shift($args); 
    16231623               $args = array_flip($args); 
    1624                 
     1624 
    16251625               if (isset($args['not'])) { $not[$id] = 1; } 
    16261626               if (isset($args['sub'])) { $sub[$id] = 1; } 
     
    16361636               } 
    16371637          } 
    1638            
     1638 
    16391639          if (!empty($sub)) { 
    16401640               $rs = $this->con->select( 
     
    16431643                    'AND '.$field.' '.$this->con->in(array_keys($sub)) 
    16441644               ); 
    1645                 
     1645 
    16461646               while ($rs->fetch()) { 
    16471647                    $queries[$rs->f($field)] = '(C.cat_lft BETWEEN '.$rs->cat_lft.' AND '.$rs->cat_rgt.')'; 
    16481648               } 
    16491649          } 
    1650            
     1650 
    16511651          # Create queries 
    16521652          $sql = array( 
     
    16541654               1 => array()  # excluded categories 
    16551655          ); 
    1656            
     1656 
    16571657          foreach ($queries as $id => $q) { 
    16581658               $sql[(integer) isset($not[$id])][] = $q; 
    16591659          } 
    1660            
     1660 
    16611661          $sql[0] = implode(' OR ',$sql[0]); 
    16621662          $sql[1] = implode(' OR ',$sql[1]); 
    1663            
     1663 
    16641664          if ($sql[0]) { 
    16651665               $sql[0] = '('.$sql[0].')'; 
     
    16671667               unset($sql[0]); 
    16681668          } 
    1669            
     1669 
    16701670          if ($sql[1]) { 
    16711671               $sql[1] = '(P.cat_id IS NULL OR NOT('.$sql[1].'))'; 
     
    16731673               unset($sql[1]); 
    16741674          } 
    1675            
     1675 
    16761676          return implode(' AND ',$sql); 
    16771677     } 
    1678       
     1678 
    16791679     private function getPostCursor($cur,$post_id=null) 
    16801680     { 
     
    16821682               throw new Exception(__('No entry title')); 
    16831683          } 
    1684            
     1684 
    16851685          if ($cur->post_content == '') { 
    16861686               throw new Exception(__('No entry content')); 
    16871687          } 
    1688            
     1688 
    16891689          if ($cur->post_password === '') { 
    16901690               $cur->post_password = null; 
    16911691          } 
    1692            
     1692 
    16931693          if ($cur->post_dt == '') { 
    16941694               $offset = dt::getTimeOffset($this->core->auth->getInfo('user_tz')); 
     
    16961696               $cur->post_dt = date('Y-m-d H:i:00',$now); 
    16971697          } 
    1698            
     1698 
    16991699          $post_id = is_int($post_id) ? $post_id : $cur->post_id; 
    1700            
     1700 
    17011701          if ($cur->post_content_xhtml == '') { 
    17021702               throw new Exception(__('No entry content')); 
    17031703          } 
    1704            
     1704 
    17051705          # Words list 
    17061706          if ($cur->post_title !== null && $cur->post_excerpt_xhtml !== null 
     
    17111711               $cur->post_excerpt_xhtml.' '. 
    17121712               $cur->post_content_xhtml; 
    1713                 
     1713 
    17141714               $cur->post_words = implode(' ',text::splitWords($words)); 
    17151715          } 
    17161716     } 
    1717       
     1717 
    17181718     private function getPostContent($cur,$post_id) 
    17191719     { 
     
    17221722          $post_content = $cur->post_content; 
    17231723          $post_content_xhtml = $cur->post_content_xhtml; 
    1724            
     1724 
    17251725          $this->setPostContent( 
    17261726               $post_id,$cur->post_format,$cur->post_lang, 
     
    17281728               $post_content,$post_content_xhtml 
    17291729          ); 
    1730            
     1730 
    17311731          $cur->post_excerpt = $post_excerpt; 
    17321732          $cur->post_excerpt_xhtml = $post_excerpt_xhtml; 
     
    17341734          $cur->post_content_xhtml = $post_content_xhtml; 
    17351735     } 
    1736       
     1736 
    17371737     /** 
    17381738     Creates post HTML content, taking format and lang into account. 
    1739       
     1739 
    17401740     @param         post_id        <b>integer</b>      Post ID 
    17411741     @param         format         <b>string</b>       Post format 
     
    17711771               } 
    17721772          } 
    1773            
     1773 
    17741774          if ($excerpt) { 
    17751775               $excerpt_xhtml = $this->core->callFormater($format,$excerpt); 
     
    17781778               $excerpt_xhtml = ''; 
    17791779          } 
    1780            
     1780 
    17811781          if ($content) { 
    17821782               $content_xhtml = $this->core->callFormater($format,$content); 
     
    17851785               $content_xhtml = ''; 
    17861786          } 
    1787            
     1787 
    17881788          # --BEHAVIOR-- coreAfterPostContentFormat 
    17891789          $this->core->callBehavior('coreAfterPostContentFormat',array( 
     
    17941794          )); 
    17951795     } 
    1796       
     1796 
    17971797     /** 
    17981798     Returns URL for a post according to blog setting <var>post_url_format</var>. 
    17991799     It will try to guess URL and append some figures if needed. 
    1800       
     1800 
    18011801     @param    url            <b>string</b>       Origin URL, could be empty 
    18021802     @param    post_dt        <b>string</b>       Post date (in YYYY-MM-DD HH:mm:ss) 
     
    18081808     { 
    18091809          $url = trim($url); 
    1810            
     1810 
    18111811          $url_patterns = array( 
    18121812          '{y}' => date('Y',strtotime($post_dt)), 
     
    18161816          '{id}' => (integer) $post_id 
    18171817          ); 
    1818            
     1818 
    18191819          # If URL is empty, we create a new one 
    18201820          if ($url == '') 
     
    18311831               $url = text::tidyURL($url); 
    18321832          } 
    1833            
     1833 
    18341834          # Let's check if URL is taken... 
    18351835          $strReq = 'SELECT post_url FROM '.$this->prefix.'post '. 
     
    18381838                    "AND blog_id = '".$this->con->escape($this->id)."' ". 
    18391839                    'ORDER BY post_url DESC'; 
    1840            
     1840 
    18411841          $rs = $this->con->select($strReq); 
    1842            
     1842 
    18431843          if (!$rs->isEmpty()) 
    18441844          { 
     
    18551855                         "AND blog_id = '".$this->con->escape($this->id)."' ". 
    18561856                         'ORDER BY post_url DESC '; 
    1857                 
     1857 
    18581858               $rs = $this->con->select($strReq); 
    18591859               $a = array(); 
     
    18611861                    $a[] = $rs->post_url; 
    18621862               } 
    1863                 
     1863 
    18641864               natsort($a); 
    18651865               $t_url = end($a); 
    1866                 
     1866 
    18671867               if (preg_match('/(.*?)([0-9]+)$/',$t_url,$m)) { 
    18681868                    $i = (integer) $m[2]; 
     
    18711871                    $i = 1; 
    18721872               } 
    1873                 
     1873 
    18741874               return $url.($i+1); 
    18751875          } 
    1876            
     1876 
    18771877          # URL is empty? 
    18781878          if ($url == '') { 
    18791879               throw new Exception(__('Empty entry URL')); 
    18801880          } 
    1881            
     1881 
    18821882          return $url; 
    18831883     } 
    18841884     //@} 
    1885       
     1885 
    18861886     /// @name Comments management methods 
    18871887     //@{ 
     
    18891889     Retrieves comments. <b>$params</b> is an array taking the following 
    18901890     optionnal parameters: 
    1891       
     1891 
    18921892     - no_content: Don't retrieve comment content 
    1893      - post_type: Get only entries with given type (default no type, array for many types)  
     1893     - post_type: Get only entries with given type (default no type, array for many types) 
    18941894     - post_id: (integer) Get comments belonging to given post_id 
    18951895     - cat_id: (integer or array) Get comments belonging to entries of given category ID 
    1896      - comment_id: (integer) Get comment with given ID 
     1896     - comment_id: (integer or array) Get comment with given ID (or IDs) 
    18971897     - comment_site: (string) Get comments with given comment_site 
    18981898     - comment_status: (integer) Get comments with given comment_status 
     
    19071907     - limit: Limit parameter 
    19081908     - sql_only : return the sql request instead of results. Only ids are selected 
    1909       
     1909 
    19101910     @param    params         <b>array</b>        Parameters 
    19111911     @param    count_only     <b>boolean</b>      Only counts results 
     
    19181918               $strReq = 'SELECT count(comment_id) '; 
    19191919          } 
    1920           elseif (!empty($params['sql_only']))  
     1920          elseif (!empty($params['sql_only'])) 
    19211921          { 
    19221922               $strReq = 'SELECT P.post_id '; 
     
    19291929                    $content_req = 'comment_content, '; 
    19301930               } 
    1931                 
     1931 
    19321932               if (!empty($params['columns']) && is_array($params['columns'])) { 
    19331933                    $content_req .= implode(', ',$params['columns']).', '; 
    19341934               } 
    1935                 
     1935 
    19361936               $strReq = 
    19371937               'SELECT C.comment_id, comment_dt, comment_tz, comment_upddt, '. 
     
    19421942               'P.post_dt, P.user_id, U.user_email, U.user_url '; 
    19431943          } 
    1944            
     1944 
    19451945          $strReq .= 
    19461946          'FROM '.$this->prefix.'comment C '. 
    19471947          'INNER JOIN '.$this->prefix.'post P ON C.post_id = P.post_id '. 
    19481948          'INNER JOIN '.$this->prefix.'user U ON P.user_id = U.user_id '; 
    1949            
     1949 
    19501950          if (!empty($params['from'])) { 
    19511951               $strReq .= $params['from'].' '; 
    19521952          } 
    1953            
     1953 
    19541954          $strReq .= 
    19551955          "WHERE P.blog_id = '".$this->con->escape($this->id)."' "; 
    1956            
     1956 
    19571957          if (!$this->core->auth->check('contentadmin',$this->id)) { 
    19581958               $strReq .= 'AND ((comment_status = 1 AND P.post_status = 1 '; 
    1959                 
     1959 
    19601960               if ($this->without_password) { 
    19611961                    $strReq .= 'AND post_password IS NULL '; 
    19621962               } 
    19631963               $strReq .= ') '; 
    1964                 
     1964 
    19651965               if ($this->core->auth->userID()) { 
    19661966                    $strReq .= "OR P.user_id = '".$this->con->escape($this->core->auth->userID())."')"; 
     
    19691969               } 
    19701970          } 
    1971            
     1971 
    19721972          if (!empty($params['post_type'])) 
    19731973          { 
    19741974               $strReq .= 'AND post_type '.$this->con->in($params['post_type']); 
    19751975          } 
    1976            
     1976 
    19771977          if (isset($params['post_id']) && $params['post_id'] !== '') { 
    19781978               $strReq .= 'AND P.post_id = '.(integer) $params['post_id'].' '; 
    19791979          } 
    1980            
     1980 
    19811981          if (isset($params['cat_id']) && $params['cat_id'] !== '') { 
    19821982               $strReq .= 'AND P.cat_id = '.(integer) $params['cat_id'].' '; 
    19831983          } 
    1984            
     1984 
    19851985          if (isset($params['comment_id']) && $params['comment_id'] !== '') { 
    1986                $strReq .= 'AND comment_id = '.(integer) $params['comment_id'].' '; 
    1987           } 
    1988            
     1986               if (is_array($params['comment_id'])) { 
     1987                    array_walk($params['comment_id'],create_function('&$v,$k','if($v!==null){$v=(integer)$v;}')); 
     1988               } else { 
     1989                    $params['comment_id'] = array((integer) $params['comment_id']); 
     1990               } 
     1991               $strReq .= 'AND comment_id '.$this->con->in($params['comment_id']); 
     1992          } 
     1993 
    19891994          if (isset($params['comment_site'])) { 
    19901995               $comment_site = $this->con->escape(str_replace('*','%',$params['comment_site'])); 
    19911996               $strReq .= "AND comment_site LIKE '".$comment_site."' "; 
    19921997          } 
    1993            
     1998 
    19941999          if (isset($params['comment_status'])) { 
    19952000               $strReq .= 'AND comment_status = '.(integer) $params['comment_status'].' '; 
    19962001          } 
    1997            
     2002 
    19982003          if (!empty($params['comment_status_not'])) 
    19992004          { 
    20002005               $strReq .= 'AND comment_status <> '.(integer) $params['comment_status_not'].' '; 
    20012006          } 
    2002            
     2007 
    20032008          if (isset($params['comment_trackback'])) { 
    20042009               $strReq .= 'AND comment_trackback = '.(integer) (boolean) $params['comment_trackback'].' '; 
    20052010          } 
    2006            
     2011 
    20072012          if (isset($params['comment_ip'])) { 
    20082013               $comment_ip = $this->con->escape(str_replace('*','%',$params['comment_ip'])); 
    20092014               $strReq .= "AND comment_ip LIKE '".$comment_ip."' "; 
    20102015          } 
    2011            
     2016 
    20122017          if (isset($params['q_author'])) { 
    20132018               $q_author = $this->con->escape(str_replace('*','%',strtolower($params['q_author']))); 
    20142019               $strReq .= "AND LOWER(comment_author) LIKE '".$q_author."' "; 
    20152020          } 
    2016            
     2021 
    20172022          if (!empty($params['search'])) 
    20182023          { 
    20192024               $words = text::splitWords($params['search']); 
    2020                 
     2025 
    20212026               if (!empty($words)) 
    20222027               { 
     
    20252030                         $this->core->callBehavior('coreCommentSearch',$this->core,array(&$words,&$strReq,&$params)); 
    20262031                    } 
    2027                      
     2032 
    20282033                    if ($words) 
    20292034                    { 
     
    20352040               } 
    20362041          } 
    2037            
     2042 
    20382043          if (!empty($params['sql'])) { 
    20392044               $strReq .= $params['sql'].' '; 
    20402045          } 
    2041            
     2046 
    20422047          if (!$count_only) 
    20432048          { 
     
    20482053               } 
    20492054          } 
    2050            
     2055 
    20512056          if (!$count_only && !empty($params['limit'])) { 
    20522057               $strReq .= $this->con->limit($params['limit']); 
     
    20562061               return $strReq; 
    20572062          } 
    2058            
     2063 
    20592064          $rs = $this->con->select($strReq); 
    20602065          $rs->core = $this->core; 
    20612066          $rs->extend('rsExtComment'); 
    2062            
     2067 
    20632068          # --BEHAVIOR-- coreBlogGetComments 
    20642069          $this->core->callBehavior('coreBlogGetComments',$rs); 
    2065            
     2070 
    20662071          return $rs; 
    20672072     } 
    2068       
     2073 
    20692074     /** 
    20702075     Creates a new comment. Takes a cursor as input and returns the new comment 
    20712076     ID. 
    2072       
     2077 
    20732078     @param    cur       <b>cursor</b>       Comment cursor 
    20742079     @return   <b>integer</b>      New comment ID 
     
    20822087               $rs = $this->con->select( 
    20832088                    'SELECT MAX(comment_id) '. 
    2084                     'FROM '.$this->prefix.'comment '  
     2089                    'FROM '.$this->prefix.'comment ' 
    20852090               ); 
    2086                 
     2091 
    20872092               $cur->comment_id = (integer) $rs->f(0) + 1; 
    20882093               $cur->comment_upddt = date('Y-m-d H:i:s'); 
    2089                 
     2094 
    20902095               $offset = dt::getTimeOffset($this->settings->system->blog_timezone); 
    20912096               $cur->comment_dt = date('Y-m-d H:i:s',time() + $offset); 
    20922097               $cur->comment_tz = $this->settings->system->blog_timezone; 
    2093                 
     2098 
    20942099               $this->getCommentCursor($cur); 
    2095                 
     2100 
    20962101               if ($cur->comment_ip === null) { 
    20972102                    $cur->comment_ip = http::realIP(); 
    20982103               } 
    2099                 
     2104 
    21002105               # --BEHAVIOR-- coreBeforeCommentCreate 
    21012106               $this->core->callBehavior('coreBeforeCommentCreate',$this,$cur); 
    2102                 
     2107 
    21032108               $cur->insert(); 
    21042109               $this->con->unlock(); 
     
    21092114               throw $e; 
    21102115          } 
    2111            
     2116 
    21122117          # --BEHAVIOR-- coreAfterCommentCreate 
    21132118          $this->core->callBehavior('coreAfterCommentCreate',$this,$cur); 
    2114            
     2119 
    21152120          $this->triggerComment($cur->comment_id); 
    21162121          if ($cur->comment_status != -2) { 
    21172122               $this->triggerBlog(); 
    2118           }     
     2123          } 
    21192124          return $cur->comment_id; 
    21202125     } 
    2121       
     2126 
    21222127     /** 
    21232128     Updates an existing comment. 
    2124       
     2129 
    21252130     @param    id        <b>integer</b>      Comment ID 
    21262131     @param    cur       <b>cursor</b>       Comment cursor 
     
    21312136               throw new Exception(__('You are not allowed to update comments')); 
    21322137          } 
    2133            
     2138 
    21342139          $id = (integer) $id; 
    2135            
     2140 
    21362141          if (empty($id)) { 
    21372142               throw new Exception(__('No such comment ID')); 
    21382143          } 
    2139            
     2144 
    21402145          $rs = $this->getComments(array('comment_id' => $id)); 
    2141            
     2146 
    21422147          if ($rs->isEmpty()) { 
    21432148               throw new Exception(__('No such comment ID')); 
    21442149          } 
    2145            
     2150 
    21462151          #If user is only usage, we need to check the post's owner 
    21472152          if (!$this->core->auth->check('contentadmin',$this->id)) 
     
    21512156               } 
    21522157          } 
    2153            
     2158 
    21542159          $this->getCommentCursor($cur); 
    2155            
     2160 
    21562161          $cur->comment_upddt = date('Y-m-d H:i:s'); 
    2157            
     2162 
    21582163          if (!$this->core->auth->check('publish,contentadmin',$this->id)) { 
    21592164               $cur->unsetField('comment_status'); 
    21602165          } 
    2161            
     2166 
    21622167          # --BEHAVIOR-- coreBeforeCommentUpdate 
    21632168          $this->core->callBehavior('coreBeforeCommentUpdate',$this,$cur,$rs); 
    2164            
     2169 
    21652170          $cur->update('WHERE comment_id = '.$id.' '); 
    2166            
     2171 
    21672172          # --BEHAVIOR-- coreAfterCommentUpdate 
    21682173          $this->core->callBehavior('coreAfterCommentUpdate',$this,$cur,$rs); 
    2169            
     2174 
    21702175          $this->triggerComment($id); 
    21712176          $this->triggerBlog(); 
    21722177     } 
    2173       
     2178 
    21742179     /** 
    21752180     Updates comment status. 
    2176       
     2181 
    21772182     @param    id        <b>integer</b>      Comment ID 
    21782183     @param    status    <b>integer</b>      Comment status 
     
    21822187          $this->updCommentsStatus($id,$status); 
    21832188     } 
    2184       
     2189 
    21852190     /** 
    21862191     Updates comments status. 
    2187       
     2192 
    21882193     @param    ids       <b>mixed</b>        Comment(s) ID(s) 
    21892194     @param    status    <b>integer</b>      Comment status 
     
    21942199               throw new Exception(__("You are not allowed to change this comment's status")); 
    21952200          } 
    2196            
     2201 
    21972202          $co_ids = dcUtils::cleanIds($ids); 
    21982203          $status = (integer) $status; 
    2199            
    2200           $strReq =  
     2204 
     2205          $strReq = 
    22012206               'UPDATE '.$this->prefix.'comment tc '; 
    2202            
     2207 
    22032208          # mySQL uses "JOIN" synthax 
    22042209          if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') { 
    2205                $strReq .=  
     2210               $strReq .= 
    22062211                    'JOIN '.$this->prefix.'post tp ON tc.post_id = tp.post_id '; 
    22072212          } 
    2208            
    2209           $strReq .=  
     2213 
     2214          $strReq .= 
    22102215               'SET comment_status = '.$status.' '; 
    2211            
     2216 
    22122217          # pgSQL uses "FROM" synthax 
    22132218          if ($this->con->driver() != 'mysql' && $this->con->driver() != 'mysqli') { 
    2214                $strReq .=  
     2219               $strReq .= 
    22152220                    'FROM '.$this->prefix.'post tp '; 
    22162221          } 
    2217            
     2222 
    22182223          $strReq .= 
    22192224               "WHERE blog_id = '".$this->con->escape($this->id)."' ". 
    22202225               'AND comment_id'.$this->con->in($co_ids); 
    2221            
     2226 
    22222227          # add pgSQL "WHERE" clause 
    22232228          if ($this->con->driver() != 'mysql' && $this->con->driver() != 'mysqli') { 
    2224                $strReq .=  
     2229               $strReq .= 
    22252230                    'AND tc.post_id = tp.post_id '; 
    22262231          } 
    2227            
     2232 
    22282233          #If user is only usage, we need to check the post's owner 
    22292234          if (!$this->core->auth->check('contentadmin',$this->id)) 
    22302235          { 
    2231                $strReq .=  
     2236               $strReq .= 
    22322237                    "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    22332238          } 
    2234            
     2239 
    22352240          $this->con->execute($strReq); 
    22362241          $this->triggerComments($co_ids); 
    22372242          $this->triggerBlog(); 
    22382243     } 
    2239       
     2244 
    22402245     /** 
    22412246     Delete a comment 
    2242       
     2247 
    22432248     @param    id        <b>integer</b>      Comment ID 
    22442249     */ 
     
    22472252          $this->delComments($id); 
    22482253     } 
    2249       
     2254 
    22502255     /** 
    22512256     Delete comments 
    2252       
     2257 
    22532258     @param    ids       <b>mixed</b>        Comment(s) ID(s) 
    22542259     */ 
     
    22582263               throw new Exception(__('You are not allowed to delete comments')); 
    22592264          } 
    2260            
     2265 
    22612266          $co_ids = dcUtils::cleanIds($ids); 
    2262            
     2267 
    22632268          if (empty($co_ids)) { 
    22642269               throw new Exception(__('No such comment ID')); 
    22652270          } 
    2266            
     2271 
    22672272          # Retrieve posts affected by comments edition 
    22682273          $affected_posts = array(); 
     
    22722277               'WHERE comment_id'.$this->con->in($co_ids). 
    22732278               'GROUP BY post_id'; 
    2274            
     2279 
    22752280          $rs = $this->con->select($strReq); 
    2276            
     2281 
    22772282          while ($rs->fetch()) { 
    22782283               $affected_posts[] = (integer) $rs->post_id; 
    22792284          } 
    2280            
     2285 
    22812286          # mySQL uses "INNER JOIN" synthax 
    22822287          if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') { 
    2283                $strReq =  
     2288               $strReq = 
    22842289                    'DELETE FROM tc '. 
    22852290                    'USING '.$this->prefix.'comment tc '. 
     
    22882293          # pgSQL uses nothing special 
    22892294          else { 
    2290                $strReq =  
     2295               $strReq = 
    22912296                    'DELETE FROM '.$this->prefix.'comment tc '. 
    22922297                    'USING '.$this->prefix.'post tp '; 
    22932298          } 
    2294            
    2295           $strReq .=  
     2299 
     2300          $strReq .= 
    22962301               'WHERE tc.post_id = tp.post_id '. 
    22972302               "AND tp.blog_id = '".$this->con->escape($this->id)."' ". 
    22982303               'AND comment_id'.$this->con->in($co_ids); 
    2299            
     2304 
    23002305          #If user can only delete, we need to check the post's owner 
    23012306          if (!$this->core->auth->check('contentadmin',$this->id)) 
    23022307          { 
    2303                $strReq .=  
     2308               $strReq .= 
    23042309                    "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    23052310          } 
    2306            
     2311 
    23072312          $this->con->execute($strReq); 
    23082313          $this->triggerComments($co_ids, true, $affected_posts); 
     
    23152320               throw new Exception(__('You are not allowed to delete comments')); 
    23162321          } 
    2317            
     2322 
    23182323          # mySQL uses "INNER JOIN" synthax 
    23192324          if ($this->con->driver() == 'mysql' || $this->con->driver() == 'mysqli') { 
    2320                $strReq =  
     2325               $strReq = 
    23212326                    'DELETE FROM tc '. 
    23222327                    'USING '.$this->prefix.'comment tc '. 
     
    23252330          # pgSQL uses nothing special 
    23262331          else { 
    2327                $strReq =  
     2332               $strReq = 
    23282333                    'DELETE FROM '.$this->prefix.'comment tc '. 
    23292334                    'USING '.$this->prefix.'post tp '; 
    23302335          } 
    2331            
    2332           $strReq .=  
     2336 
     2337          $strReq .= 
    23332338               'WHERE tc.post_id = tp.post_id '. 
    23342339               "AND tp.blog_id = '".$this->con->escape($this->id)."' ". 
    23352340               'AND comment_status = -2'; 
    2336            
     2341 
    23372342          #If user can only delete, we need to check the post's owner 
    23382343          if (!$this->core->auth->check('contentadmin',$this->id)) 
    23392344          { 
    2340                $strReq .=  
     2345               $strReq .= 
    23412346                    "AND user_id = '".$this->con->escape($this->core->auth->userID())."' "; 
    23422347          } 
    2343            
     2348 
    23442349          $this->con->execute($strReq); 
    23452350          $this->triggerBlog(); 
    23462351     } 
    2347       
     2352 
    23482353     private function getCommentCursor($cur) 
    23492354     { 
     
    23512356               throw new Exception(__('You must provide a comment')); 
    23522357          } 
    2353            
     2358 
    23542359          if ($cur->comment_author !== null && $cur->comment_author == '') { 
    23552360               throw new Exception(__('You must provide an author name')); 
    23562361          } 
    2357            
     2362 
    23582363          if ($cur->comment_email != '' && !text::isEmail($cur->comment_email)) { 
    23592364               throw new Exception(__('Email address is not valid.')); 
    23602365          } 
    2361            
     2366 
    23622367          if ($cur->comment_site !== null && $cur->comment_site != '') { 
    23632368               if (!preg_match('|^http(s?)://|i',$cur->comment_site, $matches)) { 
     
    23672372               } 
    23682373          } 
    2369            
     2374 
    23702375          if ($cur->comment_status === null) { 
    23712376               $cur->comment_status = (integer) $this->settings->system->comments_pub; 
    23722377          } 
    2373            
     2378 
    23742379          # Words list 
    23752380          if ($cur->comment_content !== null) 
Note: See TracChangeset for help on using the changeset viewer.

Sites map