Changeset 1127
- Timestamp:
- 06/27/08 09:37:47
- Files:
-
- qPloneComments/branches/plone-3.0/patch.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/branches/plone-3.0/patch.py
r1121 r1127 1 from Products.CMFDefault.DiscussionItem import DiscussionItemContainer, DiscussionItem2 from AccessControl import getSecurityManager, Unauthorized3 1 from DateTime import DateTime 2 from Globals import InitializeClass 3 from AccessControl import Unauthorized 4 from AccessControl import getSecurityManager 4 5 from Products.CMFCore.utils import getToolByName 5 from AccessControl import ClassSecurityInfo 6 from Globals import InitializeClass 7 import rfc822 8 from StringIO import StringIO 9 from utils import * 6 from Products.CMFDefault.DiscussionItem import DiscussionItem 7 from Products.CMFDefault.DiscussionItem import DiscussionItemContainer 10 8 11 # Patching createReply method of 9 from Products.qPloneComments.utils import getProp 10 11 # Patching createReply method of 12 12 # Products.CMFDefault.DiscussionItem.DiscussionItemContainer 13 def createReply( self, title, text, Creator=None, email=''): 14 """ 15 Create a reply in the proper place 13 def createReply(self, title, text, Creator=None, email=''): 14 """Create a reply in the proper place. 16 15 """ 17 16 container = self._container 18 17 19 18 id = int(DateTime().timeTime()) 20 while self._container.get( str(id), None) is not None:21 id = id +122 id = str( id)19 while self._container.get(str(id), None) is not None: 20 id += 1 21 id = str(id) 23 22 24 item = DiscussionItem( id, title=title, description=title ) 25 item.setFormat('structured-text') 26 item._edit(text) 23 item = DiscussionItem(id, title=title, description=title) 27 24 28 25 if Creator: 29 if hasattr(item, 'addCreator'):26 if getattr(item, 'addCreator', None) is not None: 30 27 item.addCreator(Creator) 31 28 else: 32 29 item.creator = Creator 33 30 31 self._container[id] = item 32 item = item.__of__(self) 33 34 item.setFormat('structured-text') 35 item._edit(text) 36 34 37 pm = getToolByName(self, 'portal_membership') 35 36 38 if pm.isAnonymousUser(): 37 39 item.manage_addProperty(id='email', value=email, type='string') 38 40 39 item.review_state="private" 40 41 item.setReplyTo( self._getDiscussable() ) 42 self._container[ id ] = item 41 item.review_state = 'private' 43 42 44 43 # Control of performing moderation 45 ifModerate = getProp(self, "enable_moderation", marker=False) 46 if ifModerate: 44 if getProp(self, 'enable_moderation', marker=False): 47 45 roles = [role['name'] for role in self.acl_users.rolesOfPermission('Moderate Discussion') 48 46 if role['selected']== 'SELECTED'] … … 51 49 item.manage_permission('View', roles, acquire=0) 52 50 else: 53 item.review_state = "published"51 item.review_state = 'published' 54 52 55 item.__of__( self ).indexObject() 53 item.setReplyTo(self._getDiscussable()) 54 item.indexObject() 55 56 56 return id 57 57 58 58 def getReplies( self ): 59 """Return a sequence of the DiscussionResponse objects which are 60 associated with this Discussable. 59 61 """ 60 Return a sequence of the DiscussionResponse objects which are61 associated with this Discussable62 """63 64 62 objects = [] 65 a = objects.append66 63 validate = getSecurityManager().validate 67 64 68 65 result_ids = self._getReplyResults() 69 66 for id in result_ids: 70 object = self._container.get( id ).__of__( self)67 comment = self._container.get(id).__of__(self) 71 68 try: 72 if validate(self, self, id, object):73 a( object)69 if validate(self, self, id, comment): 70 objects.append(comment) 74 71 except Unauthorized: 75 72 pass … … 82 79 funcs = item[1] 83 80 if 'deleteReply' in funcs: 84 new_perms.append( (perm_name, [f for f in funcs if f != 'deleteReply']))85 new_perms.append( ('Moderate Discussion', ('deleteReply', )))81 new_perms.append((perm_name, [f for f in funcs if f != 'deleteReply'])) 82 new_perms.append(('Moderate Discussion', ('deleteReply',))) 86 83 else: 87 84 new_perms.append(item)
