Paver posted a general solution here:
http://forum.coppermine-gallery.net/index.php?topic=31146
But I'm having the same problem as the question at the bottom... I can't apply the solution to searchnew.php.
Mostly because I don't understand how to change this:
if ($select == "") {
$result = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 0");
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $lang_search_new_php['albums_no_category'];
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
$result = cpg_db_query("SELECT DISTINCT a.aid as aid, a.title as title, c.name as cname FROM {$CONFIG['TABLE_ALBUMS']} as a, {$CONFIG['TABLE_CATEGORIES']} as c WHERE a.category = c.cid AND a.category < '" . FIRST_USER_CAT . "'");
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $row['cname'];
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
//if (defined('UDB_INTEGRATION')) {
$sql = $cpg_udb->get_batch_add_album_list();
/*} else {
$sql = "SELECT aid, CONCAT('(', user_name, ') ', title) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$CONFIG['TABLE_USERS']} AS u ON category = (" . FIRST_USER_CAT . " + user_id)";
}*/
$result = cpg_db_query($sql);
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $lang_search_new_php['personal_albums'];
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
Into this:
// Cycle through the User albums
foreach($user_albums_list as $album) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $lang_upload_php['personal_albums'];
$listArray[$list_count]['aid'] = $album['aid'];
$listArray[$list_count]['title'] = $album['title'];
$list_count++;
}
// Cycle through the public albums
foreach($public_albums_list as $album) {
// Set $album_id to the actual album ID
$album_id = $album['aid'];
// Get the category name
$vQuery = "SELECT cat.name, cat.cid FROM " . $CONFIG['TABLE_CATEGORIES'] . " cat, " . $CONFIG['TABLE_ALBUMS'] . " alb WHERE alb.aid='" . $album_id . "' AND cat.cid=alb.category";
$vResult = cpg_db_query($vQuery);
$vRes = cpg_db_fetch_row($vResult);
mysql_free_result($vResult);
// Add to multi-dim array for sorting later
if ($vRes['name']) {
$listArray[$list_count]['cat'] = $catAnces[$vRes['cid']] . ' - ' . $vRes['name'];
$listArray[$list_count]['cid'] = $vRes['cid'];
} else {
$listArray[$list_count]['cat'] = $lang_upload_php['albums_no_category'];
$listArray[$list_count]['cid'] = 0;
}
$listArray[$list_count]['aid'] = $album['aid'];
$listArray[$list_count]['title'] = $album['title'];
$list_count++;
}
...as a concept.
If I just replace it with the mod version, it gives me "select album" and nothing else on the drop-down box.
I think I'm missing something... help?
Got it. Although I skipped over the "integration" part... I have no integration. And so I just left it. >.>
In searchnew.php, under function albumselect:
Below
static $select = "";
Add:
// Get the ancestry of the categories
$vQuery = "SELECT cid, parent, name FROM " . $CONFIG['TABLE_CATEGORIES'] . " WHERE 1";
$vResult = cpg_db_query($vQuery);
$vRes = cpg_db_fetch_rowset($vResult);
mysql_free_result($vResult);
foreach ($vRes as $vResI => $vResV) {
$vResRow = $vRes[$vResI];
$catParent[$vResRow['cid']] = $vResRow['parent'];
$catName[$vResRow['cid']] = $vResRow['name'];
}
$catAnces = array();
foreach ($catParent as $cid => $cid_parent) {
$catAnces[$cid] = '';
while ($cid_parent != 0) {
$catAnces[$cid] = $catName[$cid_parent] . ($catAnces[$cid]?' - '.$catAnces[$cid]:'');
$cid_parent = $catParent[$cid_parent];
}
}
Replace:
$result = cpg_db_query("SELECT DISTINCT a.aid as aid, a.title as title, c.name as cname FROM {$CONFIG['TABLE_ALBUMS']} as a, {$CONFIG['TABLE_CATEGORIES']} as c WHERE a.category = c.cid AND a.category < '" . FIRST_USER_CAT . "'");
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
$listArray[$list_count]['cat'] = $row['cname'];
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
with
$result = cpg_db_query("SELECT DISTINCT a.aid as aid, a.title as title, c.name as cname, c.cid as ccid FROM
{$CONFIG['TABLE_ALBUMS']} as a, {$CONFIG['TABLE_CATEGORIES']} as c WHERE a.category = c.cid AND a.category <
'" . FIRST_USER_CAT . "'");
while ($row = mysql_fetch_array($result)) {
// Add to multi-dim array for later sorting
if ($row['cname']) {
$listArray[$list_count]['cat'] = $catAnces[$row['ccid']] . ' - ' . $row['cname'];
$listArray[$list_count]['cid'] = $row['ccid'];
} else {
$listArray[$list_count]['cat'] = $lang_upload_php['albums_no_category'];
$listArray[$list_count]['cid'] = 0;
}
$listArray[$list_count]['aid'] = $row['aid'];
$listArray[$list_count]['title'] = $row['title'];
$list_count++;
}
mysql_free_result($result);
I think that's it.