/** * Recurse through the category table building an option list * sorted by id. * * @param integer $sel Category ID to be selected in list * @param integer $papa_id Parent category ID * @param string $char Separator characters * @param string $not 'NOT' to exclude $items, '' to include * @param string $items Optional comma-separated list of items to include or exclude * @return string HTML option list, without <select> tags */ public static function buildSelection($sel = 0, $papa_id = 0, $char = '', $not = '', $items = '') { global $_TABLES, $_GROUPS; $str = ''; // Locate the parent category of this one, or the root categories // if papa_id is 0. $sql = "SELECT cat_id, cat_name, papa_id, owner_id, group_id,\n perm_owner, perm_group, perm_members, perm_anon\n FROM {$_TABLES['ad_category']}\n WHERE papa_id = {$papa_id} "; if (!empty($items)) { $sql .= " AND cat_id {$not} IN ({$items}) "; } $sql .= COM_getPermSQL('AND') . ' ORDER BY cat_name ASC '; //echo $sql;die; //COM_errorLog($sql); $result = DB_query($sql); // If there is no parent, just return. if (!$result) { return ''; } while ($row = DB_fetchArray($result, false)) { $txt = $char . $row['cat_name']; $selected = $row['cat_id'] == $sel ? 'selected' : ''; if ($row['papa_id'] == 0) { $style = 'class="adCatRoot"'; } else { $style = ''; } if (SEC_hasAccess($row['owner_id'], $row['group_id'], $row['perm_owner'], $row['perm_group'], $row['perm_members'], $row['perm_anon']) < 3) { $disabled = 'disabled="true"'; } else { $disabled = ''; } $str .= "<option value=\"{$row['cat_id']}\" {$style} {$selected} {$disabled}>"; $str .= $txt; $str .= "</option>\n"; $str .= adCategory::buildSelection($sel, $row['cat_id'], $char . '-', $not, $items); } //echo $str;die; return $str; }