/** * albumselect() * * return the HTML code for a listbox with name $id that contains the list * of all albums * * @param string $id the name of the listbox * @return the HTML code */ function albumselect($id = "album") { global $CONFIG, $lang_search_new_php; static $select = ""; if ($select == "") { $result = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 0 ORDER BY title"); $rowset = db_fetch_rowset($result); mysql_free_result($result); $result = 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 . "' ORDER BY cname,title"); while ($row = mysql_fetch_array($result)) { $row['title'] = $row['cname'] . " - " . $row['title']; $rowset[] = $row; } mysql_free_result($result); if (defined('UDB_INTEGRATION')) { $sql = udb_get_admin_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) " . "ORDER BY title"; } $result = db_query($sql); while ($row = mysql_fetch_array($result)) { $rowset[] = $row; } mysql_free_result($result); $select = '<option value="0">' . $lang_search_new_php['select_album'] . '</option>\\n'; foreach ($rowset as $row) { $select .= "<option value=\"" . $row["aid"] . "\">" . $row["title"] . "</option>\n"; } } return "\n<select name=\"{$id}\" class=\"listbox\">\n{$select}</select>\n"; }
function alb_list_box() { global $CONFIG, $album, $PHP_SELF; if (GALLERY_ADMIN_MODE) { $result = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category < '" . FIRST_USER_CAT . "' ORDER BY title"); $rowset = db_fetch_rowset($result); mysql_free_result($result); if (defined('UDB_INTEGRATION')) { $sql = udb_get_admin_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) " . "ORDER BY title"; } $result = db_query($sql); while ($row = mysql_fetch_array($result)) { $rowset[] = $row; } mysql_free_result($result); } else { $result = db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = '" . (FIRST_USER_CAT + USER_ID) . "' ORDER BY title"); $rowset = db_fetch_rowset($result); mysql_free_result($result); } if (count($rowset)) { $lb = "<select name=\"album_listbox\" class=\"listbox\" onChange=\"if(this.options[this.selectedIndex].value) window.location.href='{$PHP_SELF}?album='+this.options[this.selectedIndex].value;\">\n"; foreach ($rowset as $row) { $selected = $row['aid'] == $album ? "SELECTED" : ""; $lb .= " <option value=\"" . $row['aid'] . "\" {$selected}>" . $row['title'] . "</option>\n"; } $lb .= "</select>\n"; return $lb; } }