// fetch data and prepare data - took out WHERE album.userid = $userinfo[userid]
$albums = $db->query_read("
SELECT album.*,
picture.pictureid, picture.extension, picture.idhash,
picture.thumbnail_dateline, picture.thumbnail_width, picture.thumbnail_height
$hook_query_fields
FROM " . TABLE_PREFIX . "album AS album
LEFT JOIN " . TABLE_PREFIX . "picture AS picture ON (album.coverpictureid = picture.pictureid AND picture.thumbnail_filesize > 0)
$hook_query_joins
WHERE album.userid = $userinfo[userid]
AND album.state IN ('" . implode("', '", $state) . "')
$hook_query_where
ORDER BY album.lastpicturedate DESC
LIMIT $start, $perpage
");