Back to index

plone3  3.1.7
currentauthor.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # ATContentTypes http://plone.org/products/atcontenttypes/
00004 # Archetypes reimplementation of the CMF core types
00005 #
00006 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
00007 # Copyright (c) 2003-2006 AT Content Types development team
00008 #
00009 # This software is subject to the provisions of the Zope Public License,
00010 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
00011 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00012 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00013 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00014 # FOR A PARTICULAR PURPOSE
00015 #
00016 ##############################################################################
00017 """ Topic:
00018 
00019 
00020 """
00021 
00022 __author__  = 'Alec Mitchell <apm13@columbia.edu>'
00023 __docformat__ = 'restructuredtext'
00024 __old_name__ = 'Products.ATContentTypes.types.criteria.ATCurrentAuthorCriterion'
00025 
00026 from Products.CMFCore.permissions import View
00027 from Products.CMFCore.utils import getToolByName
00028 from AccessControl import ClassSecurityInfo
00029 
00030 from Products.ATContentTypes.criteria import registerCriterion, \
00031                                              LIST_INDICES
00032 from Products.ATContentTypes.interfaces import IATTopicSearchCriterion
00033 from Products.ATContentTypes.criteria.base import ATBaseCriterion
00034 from Products.ATContentTypes.criteria.schemata import ATBaseCriterionSchema
00035 
00036 ATCurrentAuthorSchema = ATBaseCriterionSchema
00037 
00038 class ATCurrentAuthorCriterion(ATBaseCriterion):
00039     """A criterion that searches for the currently logged in user's id"""
00040 
00041     __implements__ = ATBaseCriterion.__implements__ + (IATTopicSearchCriterion, )
00042     security       = ClassSecurityInfo()
00043     schema         = ATCurrentAuthorSchema
00044     meta_type      = 'ATCurrentAuthorCriterion'
00045     archetype_name = 'Current Author Criterion'
00046     shortDesc      = 'Restrict to current user'
00047 
00048     security.declareProtected(View, 'getCriteriaItems')
00049     def getCriteriaItems(self):
00050         result = []
00051 
00052         user = getToolByName(self, 'portal_membership').getAuthenticatedMember().getId()
00053 
00054         if user is not '':
00055             result.append((self.Field(), user))
00056 
00057         return tuple( result )
00058 
00059 registerCriterion(ATCurrentAuthorCriterion, LIST_INDICES)