From 0720d7675f93aba096ac6d3d2e8ee4ed0ca95a0c Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Fri, 11 Feb 2005 15:50:43 +0000
Subject: [PATCH] the include_if_child parameter was only working on base
 category, not on category

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2461 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFCategory/Category.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/product/CMFCategory/Category.py b/product/CMFCategory/Category.py
index 07d8950095..d7793ec044 100755
--- a/product/CMFCategory/Category.py
+++ b/product/CMFCategory/Category.py
@@ -170,16 +170,19 @@ class Category(Folder):
 
     security.declareProtected(Permissions.AccessContentsInformation,
                                                     'getCategoryChildValueList')
-    def getCategoryChildValueList(self, recursive=1,**kw):
+    def getCategoryChildValueList(self, recursive=1,include_if_child=1,**kw):
       """
           List the child objects of this category and all its subcategories.
 
           recursive - if set to 1, list recursively
       """
-      value_list = [self]
+      if not(include_if_child) and len(self.objectValues(self.allowed_types))>0:
+        value_list = []
+      else:
+        value_list = [self]
       if recursive:
         for c in self.objectValues(self.allowed_types):
-          value_list.extend(c.getCategoryChildValueList(recursive = 1))
+          value_list.extend(c.getCategoryChildValueList(recursive = 1,include_if_child=include_if_child))
       else:
         for c in self.objectValues(self.allowed_types):
           value_list.append(c)
@@ -264,7 +267,7 @@ class Category(Folder):
 
       recursive -- if set to 0 do not apply recursively
       """
-      value_list = self.getCategoryChildValueList(recursive=recursive)
+      value_list = self.getCategoryChildValueList(recursive=recursive,**kw)
       return Renderer(base=base, **kw).render(value_list)
 
     # Alias for compatibility
@@ -515,7 +518,7 @@ class BaseCategory(Category):
       value_list = []
       if recursive:
         for c in self.objectValues(self.allowed_types):
-          value_list.extend(c.getCategoryChildValueList(recursive = 1))
+          value_list.extend(c.getCategoryChildValueList(recursive = 1,indlude_if_child=include_if_child))
       else:
         for c in self.objectValues(self.allowed_types):
           if include_if_child:
-- 
2.30.9