This seems to fix the issue in my testbed. Please open include/functions.inc.php and replace the whole function album_selection_options with
function album_selection_options($selected = 0)
{
global $CONFIG, $lang_common, $cpg_udb, $LINEBREAK;
// html string of options to be returned
$options = '';
$albums = array();
// load all albums
$uploads_yes = defined('EDITPICS_PHP') || defined('UPLOAD_PHP') ? ' OR uploads = "YES"' : '';
if (GALLERY_ADMIN_MODE) {
$result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} ORDER BY pos");
} elseif (USER_ID) {
$result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (FIRST_USER_CAT + USER_ID) . " OR owner = " . USER_ID . $uploads_yes . " ORDER BY pos");
} else {
$result = cpg_db_query("SELECT aid, title, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE 0 " . $uploads_yes . " ORDER BY pos");
}
while ( ($row = mysql_fetch_assoc($result)) ) {
$albums[$row['category']][$row['aid']] = $row['title'];
}
if (!empty($albums[0])) {
// Albums in no category
$options .= '<optgroup label="' . $lang_common['albums_no_category'] . '">';
foreach ($albums[0] as $aid => $title) {
$options .= sprintf('<option value="%d"%s>%s</option>'.$LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $title);
}
$options .= '</optgroup>';
}
// Load all categories
if (GALLERY_ADMIN_MODE) {
$result = cpg_db_query("SELECT cid, rgt, name FROM {$CONFIG['TABLE_CATEGORIES']} ORDER BY lft");
} elseif (USER_ID) {
$result = cpg_db_query("SELECT DISTINCT c.cid, c.rgt, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a RIGHT JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE c.cid = " . USER_GAL_CAT . " OR a.owner = ". USER_ID . $uploads_yes . " ORDER BY lft");
} else {
$result = cpg_db_query("SELECT DISTINCT c.cid, c.rgt, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a RIGHT JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE 0 " . $uploads_yes . " ORDER BY lft");
}
$cats = array();
// Loop through all categories
while ( ($row = mysql_fetch_assoc($result))) {
// Determine category hierarchy
if (count($cats)) {
while ($cats && $cats[count($cats)-1]['rgt'] < $row['rgt']) {
array_pop($cats);
}
}
$cats[] = $row;
// Add this category to the hierarchy
if ($row['cid'] == USER_GAL_CAT) {
// User galleries
$options .= '<optgroup label="' . $lang_common['personal_albums'] . '">' . $LINEBREAK;
if (GALLERY_ADMIN_MODE) {
$result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
. "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}", $cpg_udb->link_id);
$users = cpg_db_fetch_rowset($result2);
mysql_free_result($result2);
} else {
$users = array(array('user_id' => USER_ID, 'user_name' => USER_NAME));
}
foreach ($users as $user) {
if (!empty($albums[$user['user_id'] + FIRST_USER_CAT])) {
$options .= '<optgroup label=" ' . $user['user_name'] . '">' . $LINEBREAK;
foreach ($albums[$user['user_id'] + FIRST_USER_CAT] as $aid => $title) {
$options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', ' '.$title);
}
$options .= '</optgroup>';
}
}
$options .= '</optgroup>';
unset($users);
continue;
}
// calculate indent for this level
$indent = str_repeat(' ', (count($cats) - 1));
// albums in the category
if (!empty($albums[$row['cid']])) {
// category header
$options .= '<optgroup label="' . $indent . $row['name'] . '">' . $LINEBREAK;
foreach ($albums[$row['cid']] as $aid => $title) {
$options .= sprintf('<option value="%d"%s>%s</option>' . $LINEBREAK, $aid, $aid == $selected ? ' selected="selected"' : '', $indent . $title);
}
$options .= '</optgroup>';
}
}
mysql_free_result($result);
return $options;
}