Gestion affichage lors de l'écrasement.
[Plinn.git] / MembershipTool.py
index 3e45cb8..166d42a 100755 (executable)
@@ -19,8 +19,8 @@
 #######################################################################################
 """ Plinn portal_membership
 
 #######################################################################################
 """ Plinn portal_membership
 
-$Id: MembershipTool.py 1524 2009-07-02 14:47:53Z pin $
-$URL: http://svn.cri.ensmp.fr/svn/Plinn/branches/CMF-2.1/MembershipTool.py $
+
+
 """
 
 from AccessControl import ClassSecurityInfo, getSecurityManager
 """
 
 from AccessControl import ClassSecurityInfo, getSecurityManager
@@ -74,29 +74,29 @@ class MembershipTool( BaseTool ):
        security.declareProtected(ListPortalMembers, 'getMemberById')
        
        
        security.declareProtected(ListPortalMembers, 'getMemberById')
        
        
-       memberareaPortalType = 'Folder'
+       memberareaPortalType = 'Huge Plinn Folder'
        
 
        
 
-       security.declareProtected(SetOwnPassword, 'setPassword')
-       def setPassword(self, password, domains=None):
-               '''Allows the authenticated member to set his/her own password.
-               '''
-               user_folder = self.__getPUS()
-               if user_folder.meta_type == 'Group User Folder' :
-                       registration = getToolByName(self, 'portal_registration', None)
-                       if not self.isAnonymousUser():
-                               member = self.getAuthenticatedMember()
-                               if registration:
-                                       failMessage = registration.testPasswordValidity(password)
-                                       if failMessage is not None:
-                                               raise 'Bad Request', failMessage
-                               member.setSecurityProfile(password=password, domains=domains)
-                               member.changePassword(password)
-                       else:
-                               raise 'Bad Request', 'Not logged in.'
-                       
-               else :
-                       BaseTool.setPassword(self, password, domains=None)
+#      security.declareProtected(SetOwnPassword, 'setPassword')
+#      def setPassword(self, password, domains=None):
+#              '''Allows the authenticated member to set his/her own password.
+#              '''
+#              user_folder = self.__getPUS()
+#              if user_folder.meta_type == 'Group User Folder' :
+#                      registration = getToolByName(self, 'portal_registration', None)
+#                      if not self.isAnonymousUser():
+#                              member = self.getAuthenticatedMember()
+#                              if registration:
+#                                      failMessage = registration.testPasswordValidity(password)
+#                                      if failMessage is not None:
+#                                              raise 'Bad Request', failMessage
+#                              member.setSecurityProfile(password=password, domains=domains)
+#                              member.changePassword(password)
+#                      else:
+#                              raise 'Bad Request', 'Not logged in.'
+#                      
+#              else :
+#                      BaseTool.setPassword(self, password, domains=None)
 
 
 
 
 
 
@@ -243,7 +243,7 @@ class MembershipTool( BaseTool ):
                                return userid
                        memberName = getattr(member, 'name', '')
                        memberGivenName = getattr(member, 'given_name', '')
                                return userid
                        memberName = getattr(member, 'name', '')
                        memberGivenName = getattr(member, 'given_name', '')
-                       memberId = member.id
+                       memberId = member.getId()
                        memberFullName = formatFullName(memberName, memberGivenName, memberId, nameBefore = nameBefore)
                        
                return memberFullName
                        memberFullName = formatFullName(memberName, memberGivenName, memberId, nameBefore = nameBefore)
                        
                return memberFullName
@@ -379,42 +379,49 @@ class MembershipTool( BaseTool ):
                ttool = getToolByName(self, 'portal_types')
                info = getattr(ttool, self.memberareaPortalType)
                
                ttool = getToolByName(self, 'portal_types')
                info = getattr(ttool, self.memberareaPortalType)
                
-               f = info._constructInstance( members, member_id )
                memberFullName = self.getMemberFullNameById(member_id, nameBefore = 0)
                memberFullName = self.getMemberFullNameById(member_id, nameBefore = 0)
+               f = info._constructInstance( members, member_id, title=memberFullName )
                
                # Grant Ownership and Owner role to Member
                f.changeOwnership(user)
                f.__ac_local_roles__ = None
                f.manage_setLocalRoles(member_id, ['Owner'])
 
                
                # Grant Ownership and Owner role to Member
                f.changeOwnership(user)
                f.__ac_local_roles__ = None
                f.manage_setLocalRoles(member_id, ['Owner'])
 
-               f.setTitle(memberFullName)
-               info._finishConstruction(f)
+               f.reindexObjectSecurity()
                
                
-               def _(message, context, expand=()) :
-                       trmessage = decode(translate(message, context), context)
-                       expand = tuple([decode(e, context) for e in expand])
-                       return (trmessage % expand).encode('utf-8')
-                                       
-               # Create Member's home page.
-               addDocument( f
-                                       , 'index_html'
-                                       , title = _("%s's Home", self, (memberFullName,))
-                                       , description = _("%s's front page", self, (memberFullName,))
-                                       , text_format = "html"
-                                       , text = self.default_member_content(memberFullName=memberFullName).encode('utf-8')
-                                       )
-
-               # Grant Ownership and Owner role to Member
-               f.index_html.changeOwnership(user)
-               f.index_html.__ac_local_roles__ = None
-               f.index_html.manage_setLocalRoles(member_id, ['Owner'])
-
-               f.index_html._setPortalTypeName( 'Document' )
-
-               # Overcome an apparent catalog bug.
-               f.index_html.reindexObject()
-               wftool = getToolByName( f, 'portal_workflow' )
-               wftool.notifyCreated( f.index_html )
+               # Create Member's initial content.
+               if hasattr(self, 'createMemberContent') :
+                       self.createMemberContent(member=user,
+                                                                        member_id=member_id,
+                                                                        member_folder=f)
+               else :
+                       def _(message, context, expand=()) :
+                               trmessage = decode(translate(message, context), context)
+                               expand = tuple([decode(e, context) for e in expand])
+                               return (trmessage % expand).encode('utf-8')
+                                               
+                       # Create Member's home page.
+                       addDocument( f
+                                               , 'index_html'
+                                               , title = _("%s's Home", self, (memberFullName,))
+                                               , description = _("%s's front page", self, (memberFullName,))
+                                               , text_format = "html"
+                                               , text = self.default_member_content(memberFullName=memberFullName).encode('utf-8')
+                                               )
+       
+                       # Grant Ownership and Owner role to Member
+                       f.index_html.changeOwnership(user)
+                       f.index_html.__ac_local_roles__ = None
+                       f.index_html.manage_setLocalRoles(member_id, ['Owner'])
+       
+                       f.index_html._setPortalTypeName( 'Document' )
+       
+                       # Overcome an apparent catalog bug.
+                       f.index_html.reindexObject()
+                       wftool = getToolByName( f, 'portal_workflow' )
+                       wftool.notifyCreated( f.index_html )
+               
+               return f
        
 
        security.declareProtected(ListPortalMembers, 'looseSearchMembers')
        
 
        security.declareProtected(ListPortalMembers, 'looseSearchMembers')