forum.coppermine-gallery.net

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):
Code: [Select]
$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:
Code: [Select]
$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):
Code: [Select]
$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:
Code: [Select]
$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):
Code: [Select]
$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:
Code: [Select]
$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):
Code: [Select]
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set");Replace with:
Code: [Select]
$result = cpg_db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set AND approved='YES'");

Find (362):
Code: [Select]
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='$user_thumb_pid'";Replace with:
Code: [Select]
$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)
Code: [Select]
$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