"""\
Plone Hotfix 2006-04-10

Adds security declarations to hitherto unprotected MembershipTool methods:

    - changeMemberPortrait
    - deletePersonalPortrait
    - testCurrentPassword

This Hotfix applies to all versions of Plone 2. At the time of this writing
these are Plone 2.0.5, 2.1.2, and 2.5-beta1.

Fixes http://dev.plone.org/plone/ticket/5432. These fixes will be included in
Plone versions 2.0.6, 2.1.3, and 2.5-beta2, at which point you can remove this
Hotfix.
"""

from AccessControl.PermissionRole import PermissionRole

try:
    from Products.CMFCore.permissions import SetOwnProperties
    from Products.CMFCore.permissions import SetOwnPassword
except ImportError: # CMF 1.4 aka Plone 2.0
    from Products.CMFCore.CMFCorePermissions import SetOwnProperties
    from Products.CMFCore.CMFCorePermissions import SetOwnPassword

SetOwnPropertiesRoles = PermissionRole(SetOwnProperties)
SetOwnPasswordRoles = PermissionRole(SetOwnPassword)

from Products.CMFPlone.MembershipTool import MembershipTool
MembershipTool.changeMemberPortrait__roles__ = SetOwnPropertiesRoles
MembershipTool.deletePersonalPortrait__roles__ = SetOwnPropertiesRoles
MembershipTool.testCurrentPassword__roles__ = SetOwnPasswordRoles

