1- #$Id: actions.py,v 1.50 2006-01-13 03:33:29 richard Exp $
1+ #$Id: actions.py,v 1.51 2006-01-13 03:50:03 richard Exp $
22
33import re , cgi , StringIO , urllib , Cookie , time , random , csv
44
@@ -435,7 +435,7 @@ def _editnodes(self, all_props, all_links):
435435 def _changenode (self , cn , nodeid , props ):
436436 """Change the node based on the contents of the form."""
437437 # check for permission
438- if not self .editItemPermission (props ):
438+ if not self .editItemPermission (props , classname = cn , itemid = nodeid ):
439439 raise exceptions .Unauthorised , self ._ (
440440 'You do not have permission to edit %(class)s'
441441 ) % {'class' : cn }
@@ -447,7 +447,7 @@ def _changenode(self, cn, nodeid, props):
447447 def _createnode (self , cn , props ):
448448 """Create a node based on the contents of the form."""
449449 # check for permission
450- if not self .newItemPermission (props ):
450+ if not self .newItemPermission (props , classname = cn ):
451451 raise exceptions .Unauthorised , self ._ (
452452 'You do not have permission to create %(class)s'
453453 ) % {'class' : cn }
@@ -461,7 +461,8 @@ def isEditingSelf(self):
461461 return (self .nodeid == self .userid
462462 and self .db .user .get (self .nodeid , 'username' ) != 'anonymous' )
463463
464- def editItemPermission (self , props ):
464+ _cn_marker = []
465+ def editItemPermission (self , props , classname = _cn_marker , itemid = None ):
465466 """Determine whether the user has permission to edit this item.
466467
467468 Base behaviour is to check the user can edit this class. If we're
@@ -475,17 +476,23 @@ def editItemPermission(self, props):
475476 "You do not have permission to edit user roles" )
476477 if self .isEditingSelf ():
477478 return 1
478- if self .hasPermission ('Edit' , itemid = self .nodeid ):
479+ if itemid is None :
480+ itemid = self .nodeid
481+ if classname is self ._cn_marker :
482+ classname = self .classname
483+ if self .hasPermission ('Edit' , itemid = itemid , classname = classname ):
479484 return 1
480485 return 0
481486
482- def newItemPermission (self , props ):
487+ def newItemPermission (self , props , classname = None ):
483488 """Determine whether the user has permission to create this item.
484489
485490 Base behaviour is to check the user can edit this class. No additional
486491 property checks are made.
487492 """
488- return self .hasPermission ('Create' )
493+ if not classname :
494+ classname = self .client .classname
495+ return self .hasPermission ('Create' , classname = classname )
489496
490497class EditItemAction (EditCommon ):
491498 def lastUserActivity (self ):
0 commit comments