From be012da6e8717dcf6c58d787562540ee96f49308 Mon Sep 17 00:00:00 2001 From: Michael Joseph Date: Wed, 9 Jul 2003 13:46:45 +0000 Subject: [PATCH] (#2725) added check for existence of category document field before using --- lib/browse/CategoryBrowser.inc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/browse/CategoryBrowser.inc b/lib/browse/CategoryBrowser.inc index 5f3c9fe..da73881 100644 --- a/lib/browse/CategoryBrowser.inc +++ b/lib/browse/CategoryBrowser.inc @@ -52,18 +52,18 @@ class CategoryBrowser extends Browser { $default->log->debug("CategoryBrowser::browse() categoryFieldID=$categoryFieldID"); if ($sCategoryName == "") { - $default->log->debug("CategoryBrowser::browse() no category supplied, returning list"); - // no category value supplied, so return a list of categories - // set the first value to "categories" - $results["categories"][] = "Categories"; - - // get a list of category values - $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table WHERE document_field_id=$categoryFieldID ORDER BY value " . ($this->sSortField == "name" ? $this->sSortDirection : "ASC"); - $default->log->info("CategoryBrowser::browse() category listing query=$query; $this->sSortField"); - $sql->query($query); - // loop through resultset, build array and return - while ($sql->next_record()) { - $results["categories"][] = $sql->f("value"); + if ($categoryFieldID) { + // no category value supplied, so return a list of categories + // set the first value to "categories" + $results["categories"][] = "Categories"; + // get a list of category values + $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table WHERE document_field_id=$categoryFieldID ORDER BY value " . ($this->sSortField == "name" ? $this->sSortDirection : "ASC"); + $default->log->info("CategoryBrowser::browse() category listing query=$query; $this->sSortField"); + $sql->query($query); + // loop through resultset, build array and return + while ($sql->next_record()) { + $results["categories"][] = $sql->f("value"); + } } // its ok if we return an empty array- the UI's responsibility to check and print an error return $results; -- libgit2 0.21.4