coppermine-gallery.com/forum

Dev Board => cpg1.4 Testing/Bugs => cpg1.4 Testing/Bugs: FIXED/CLOSED => Topic started by: Titooy on February 17, 2006, 10:31:04 AM

Title: [BUG+FIX] Cat and overall image counts includes unapproved pictures
Post by: Titooy on February 17, 2006, 10:31:04 AM
The picture count in the categories list and the overal stats includes non-admin-approved images. While it's shown correctly on the album's picture count.


Fix:

index.php
Find (142):$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p, {$CONFIG['TABLE_ALBUMS']} as a WHERE p.aid = a.aid AND category >= " . FIRST_USER_CAT . $album_filter);
Replace with:$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p, {$CONFIG['TABLE_ALBUMS']} as a WHERE p.aid = a.aid AND approved='YES' AND category >= " . FIRST_USER_CAT . $album_filter);


Find (164):$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p, {$CONFIG['TABLE_ALBUMS']} as a WHERE p.aid = a.aid AND category = {$subcat['cid']}" . $album_filter);
Replace with:$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p, {$CONFIG['TABLE_ALBUMS']} as a WHERE p.aid = a.aid AND approved='YES' AND category = {$subcat['cid']}" . $album_filter);


Find (272):$sql = "SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter;
Replace with:$sql = "SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} as p " . 'LEFT JOIN ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'ON a.aid=p.aid ' . 'WHERE 1' . $pic_filter . ' AND approved=\'YES\'';


Find (315):$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set");
Replace with:$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set AND approved='YES'");


Find (362):$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='$user_thumb_pid'";
Replace with:$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='$user_thumb_pid' AND approved='YES'";



By the way, I don't understand why un-approved pictures should be shown in the albums to the admins...
functions.inc.php (931)
$approved = GALLERY_ADMIN_MODE ? '' : 'AND approved=\'YES\'';
???
Title: Re: [BUG+FIX] Cat and overall image counts includes unapproved pictures
Post by: Abbas Ali on February 17, 2006, 01:16:06 PM
@Devs: Is it a bug or feature?
Title: Re: [BUG+FIX] Cat and overall image counts includes unapproved pictures
Post by: Joachim Müller on February 17, 2006, 06:33:36 PM
hehe, bug imo, although you could argue on that. Moving to bugs board anyway... ;)
Title: Re: [BUG+FIX] Cat and overall image counts includes unapproved pictures
Post by: Joachim Müller on May 17, 2006, 09:54:17 PM
comitted to stable and devel. Will be in cpg1.4.6