Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Unique Last comments mod  (Read 4917 times)

0 Members and 1 Guest are viewing this topic.

RadioErewan

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Unique Last comments mod
« on: August 27, 2007, 08:08:55 pm »

getLastImagesWithComments returns non unique result. So, it is often strip or table full of same pictures.
We struggled with this problem, and now we have good working solution.
Replace function getLastImagesWithComments($limit) with following version, and all lastComments will be unique across selection.
Thanks Cra3y!
This verison is "optimized", and configurable.
Working model you can find here: http://forum.olympusclub.pl

Code: [Select]
function getLastImagesWithComments($limit) {
   $resultset = array();
   if (is_numeric($limit)) {
       $sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect
           . ", m.msg_body AS mMsg_body, m.msg_author AS mMsg_author "
           . " FROM "
           . $this->sqlTableSelect. ", "
           . "(SELECT MAX( msg_id ) AS latest, pid AS pido "
           . "FROM ". $this->cfg['table_prefix'] . "comments "
           . "GROUP BY pid"
           . ") AS x "
           . "INNER JOIN " . $this->cfg['table_prefix'] . "comments AS m ON m.pid = pido "
           . "AND m.msg_id = x.latest"
           . " WHERE m.pid = p.pid "
           . $this->sqlUserDataLink
           . $this->filetypefilter
           . " AND p.approved='YES' {$this->privacyfilter}"
           . " ORDER BY m.msg_date DESC LIMIT 0,$limit";
           
       $resultset = $this->dbExecuteSql($sqlcode);
       $this->addPathInfo($resultset);
   }   
Regards
Logged

RadioErewan

  • Coppermine newbie
  • Offline Offline
  • Posts: 10
Re: Unique Last comments mod
« Reply #1 on: August 27, 2007, 08:13:16 pm »

Forgot, this function comes from cpmfetch_dao.php.

Regards
Logged
Pages: [1]   Go Up
 

Page created in 0.016 seconds with 16 queries.