[CMF-checkins] CVS: Products/CMFDefault - MembershipTool.py:1.15

Jens Vagelpohl jens@zope.com
Wed, 26 Sep 2001 13:25:31 -0400


Update of /cvs-repository/Products/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv12946/CMFDefault

Modified Files:
	MembershipTool.py 
Log Message:
Moved generation of the "Add to Favorites" and "My Favorites" links 
from the CMFCore/ActionsTool into the CMFDefault/MembershipTool, which
is a more logical location for it because it relies on information 
from the membership tool.




=== Products/CMFDefault/MembershipTool.py 1.14 => 1.15 ===
     def listActions(self, info):
         '''Lists actions available to the user.'''
+        user_actions = None
+
         if not info.isAnonymous:
+            home_folder = self.getHomeFolder()
             homeUrl = self.getHomeUrl()
             if homeUrl is not None:
-                return (
+                content_url = info.content_url
+                user_actions = (
+                    {'name': 'Add to Favorites',
+                     'url': ( content_url + '/addtoFavorites' ),
+                     'permissions' : [],
+                     'category': 'user'},
                     {'name': 'My Stuff',
                      'url': homeUrl + '/folder_contents',
                      'permissions': [],
                      'category': 'user'},
                     )
-        return None
+
+                if hasattr( home_folder, 'Favorites' ):
+                    added_actions = (
+                      {'name': 'My Favorites',
+                       'url' : homeUrl + '/Favorites/folder_contents',
+                       'permissions': [],
+                       'category': 'user'},) 
+                    
+                    user_actions = added_actions + user_actions
+
+        return user_actions
+
 
 InitializeClass(MembershipTool)