Commit be012da6e8717dcf6c58d787562540ee96f49308
1 parent
e036fc28
(#2725) added check for existence of category document field before using
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2333 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
12 additions
and
12 deletions
lib/browse/CategoryBrowser.inc
| @@ -52,18 +52,18 @@ class CategoryBrowser extends Browser { | @@ -52,18 +52,18 @@ class CategoryBrowser extends Browser { | ||
| 52 | $default->log->debug("CategoryBrowser::browse() categoryFieldID=$categoryFieldID"); | 52 | $default->log->debug("CategoryBrowser::browse() categoryFieldID=$categoryFieldID"); |
| 53 | 53 | ||
| 54 | if ($sCategoryName == "") { | 54 | if ($sCategoryName == "") { |
| 55 | - $default->log->debug("CategoryBrowser::browse() no category supplied, returning list"); | ||
| 56 | - // no category value supplied, so return a list of categories | ||
| 57 | - // set the first value to "categories" | ||
| 58 | - $results["categories"][] = "Categories"; | ||
| 59 | - | ||
| 60 | - // get a list of category values | ||
| 61 | - $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table WHERE document_field_id=$categoryFieldID ORDER BY value " . ($this->sSortField == "name" ? $this->sSortDirection : "ASC"); | ||
| 62 | - $default->log->info("CategoryBrowser::browse() category listing query=$query; $this->sSortField"); | ||
| 63 | - $sql->query($query); | ||
| 64 | - // loop through resultset, build array and return | ||
| 65 | - while ($sql->next_record()) { | ||
| 66 | - $results["categories"][] = $sql->f("value"); | 55 | + if ($categoryFieldID) { |
| 56 | + // no category value supplied, so return a list of categories | ||
| 57 | + // set the first value to "categories" | ||
| 58 | + $results["categories"][] = "Categories"; | ||
| 59 | + // get a list of category values | ||
| 60 | + $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table WHERE document_field_id=$categoryFieldID ORDER BY value " . ($this->sSortField == "name" ? $this->sSortDirection : "ASC"); | ||
| 61 | + $default->log->info("CategoryBrowser::browse() category listing query=$query; $this->sSortField"); | ||
| 62 | + $sql->query($query); | ||
| 63 | + // loop through resultset, build array and return | ||
| 64 | + while ($sql->next_record()) { | ||
| 65 | + $results["categories"][] = $sql->f("value"); | ||
| 66 | + } | ||
| 67 | } | 67 | } |
| 68 | // its ok if we return an empty array- the UI's responsibility to check and print an error | 68 | // its ok if we return an empty array- the UI's responsibility to check and print an error |
| 69 | return $results; | 69 | return $results; |