MODULE: Album 0.9.2
BUG: Create a category, add a few albums (at least 3), click the up-arrow for the lowest album to move it up. The album will move up to the top instead of just one place up. This bug includes other reordering issues and this is only one example that's easy to reproduce.
REASON: In action.updatealbum.php the function ListingCount from Album/classes/module/class.Album.php is called which due to an error in implementation always returns 0. Thus in the table cms_module_album_category_listings the column listing_number is always initialized as 1 which leads to severe reordering problems.
SOLUTION: change 2 places in 2 functions:
1) Album/action.updatealbum.php line 40
Code: Select all
$listing_number = $this->ListingCount($album_id)+1;
Code: Select all
$listing_number = $this->ListingCount($category_id)+1;
Code: Select all
function ListingCount($album_id)
{
global $gCms;
$db = $this->GetDb();
$query = 'SELECT listing_id FROM '.cms_db_prefix().'module_album_category_listings WHERE listing_album_id='.intval($album_id);
$dbresult = $db->Execute($query);
if ($dbresult)
return $dbresult->RecordCount();
else
return 0;
}
Code: Select all
function ListingCount($category_id)
{
global $gCms;
$db = $this->GetDb();
$query = 'SELECT MAX(listing_number) FROM '.cms_db_prefix().'module_album_category_listings
WHERE listing_category_id='.intval($category_id);
$dbresult = $db->Execute($query);
if ($dbresult)
{
$row = $dbresult->FetchRow();
return $row['MAX(listing_number)'];
}
else
return 0;
}
I'd be glad if anyone could double check this implementation (it works for me so far) and post any anomalies.
Cheers,
Cerno