coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: Steve-R on November 17, 2007, 06:22:13 PM

Title: Possible bug? or my crap code?
Post by: Steve-R on November 17, 2007, 06:22:13 PM
I have the following code working at the link below the code, you can see its set to Top Rated but I wonder if I have found a bug of sorts. Today I went through and removed al votes from the gallery and coppermine does not show any of the photos in its Top Rated area, but this script still does and it can be seen that all Pic ratings and votes are set at zero.

Is this a bug? Or is there a way to get round this.


<?php    

  
include_once "./cpmfetch/cpmfetch.php";
  
$objCpm = new cpm("./cpmfetch/cpmfetch_config.php");
  
$options = array("subtitle" => "{{pTitle}} <br />by {{pOwner_name}}<br /><br />{{pCtimeFormatted}}<br />  Pic Rating : {{pPic_Rating}} <br /> Votes : {{pVotes}} <hr />",
                
"imagesize" => "thumb");
  
$objCpm->cpm_viewTopRatedMediaFrom ("cat=1",100,1,$options);
  
$objCpm->cpm_close();

?>




The above code in use

http://www.photocumbria.com/SdGall/bbbbb.php


Coppermines "Top Rated" area

http://www.photocumbria.com/SdGall/thumbnails.php?album=toprated&cat=0


Steve...:)
Title: Re: Possible bug? or my crap code?
Post by: Steve-R on November 21, 2007, 01:18:53 PM
Anyone any ideas why the files with votes removed are still showing in cpmfetch but not in the top rated area of coppermine?

Steve...:)
Title: Re: Possible bug? or my crap code?
Post by: Nibbler on November 21, 2007, 03:15:20 PM
Top rated meta album in Coppermine has a definable lower limit on the number of votes a file must have to be displayed. I expect cpmFetch does not do this, and simply sorts by rating/votes including the zeros.
Title: Re: Possible bug? or my crap code?
Post by: Steve-R on January 07, 2008, 12:37:11 PM
The php file is in the first post, would it be possible to add some php at the end of the file to stop images showing that have zero votes?

OR

Is it possible to edit CPM Fetch to add the definable lower limit that must exist to display the pictures?

Many thanks in advance!

Steve...:)
Title: Re: Possible bug? or my crap code?
Post by: Infernal on January 07, 2008, 06:29:42 PM
files with 0 votes still show because you have less pictures with votes then you want to show there
it happened to me to and that was the cause
and another thing if a picture has 1 vote of 5 it will appear above a picture that had 10 votes and 4.8
Title: Re: Possible bug? or my crap code?
Post by: Steve-R on January 08, 2008, 11:35:33 AM
I've solved this one, topic can be marked as such. Here is how I did it.


In cpmfetch_dao.php

Find:


function getTopRatedMediaFrom ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

$sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.votes DESC LIMIT 0,$count";

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}


Change to:


function getTopRatedMediaFrom ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

$sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' AND p.pic_rating > 0 "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.votes DESC LIMIT 0,$count";

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}




This now only shows pictures that have one or more votes (and therefore has a pic-rating too) on it.

@ Infernal: Look at this line above . " ORDER BY p.votes DESC LIMIT 0,$count"; I changed it from p.pic_rating to p.votes  My list now shows in vote order.


Steve...:)