From a578cf1960642fcd5b76c40704875c500bb0d50e Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Wed, 23 Feb 2005 16:54:15 +0000
Subject: [PATCH] Bug fix: modified isMemberOf to check if a category is a
 sub-category.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2549 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/CMFCategory/CategoryTool.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/product/CMFCategory/CategoryTool.py b/product/CMFCategory/CategoryTool.py
index f8a06ddcfd..f5149d910e 100755
--- a/product/CMFCategory/CategoryTool.py
+++ b/product/CMFCategory/CategoryTool.py
@@ -981,8 +981,16 @@ class CategoryTool( UniqueObject, Folder, Base ):
             return 1
       else:
         for c in self.getAcquiredCategoryMembershipList(context, base_category = base_category):
-          if c.find(category) >= 0:
-            return 1
+          if c.find(category) == 0:
+            # The names begin with the same string
+            c_right_split = c.split(category)[1]
+            if (len(c_right_split) > 0):
+              # Be sure that we have a sub category, and not name like this: 'europe1' in 'europe10'
+              if c_right_split[0] == '/':
+                return 1
+            else:
+              # Same category
+              return 1
       return 0
 
     security.declareProtected( Permissions.AccessContentsInformation, 'isAcquiredMemberOf' )
-- 
2.30.9