Beispiel #1
0
## Script (Python) "validatePassword"
##parameters=password='', confirm='', **kw
##title=
##
from Products.CMFCore.utils import getToolByInterfaceName

ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')

if ptool.getProperty('validate_email'):
    password = rtool.generatePassword()
    return context.setStatus(True, password=password)
else:
    result = rtool.testPasswordValidity(password, confirm)
    if result:
        return context.setStatus(False, result)
    else:
        return context.setStatus(True)
Beispiel #2
0
##parameters=
##
from ZTUtils import Batch
from ZTUtils import LazyFilter
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode

stool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.ISyndicationTool'
                              )


if not stool.isSyndicationAllowed(context):
    context.REQUEST.RESPONSE.redirect(context.absolute_url() +
             '/rssDisabled?portal_status_message=Syndication+is+Disabled')
    return


options = {}

options['channel_info'] = { 'base': stool.getHTML4UpdateBase(context),
                            'description': context.Description(),
                            'frequency': stool.getUpdateFrequency(context),
                            'period': stool.getUpdatePeriod(context),
                            'title': context.Title(),
                            'url': context.absolute_url() }

key, reverse = context.getDefaultSorting()
items = stool.getSyndicatableContent(context)
items = sequence.sort( items, ((key, 'cmp', reverse and 'desc' or 'asc'),) )
items = LazyFilter(items, skip='View')
Beispiel #3
0
##parameters=
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import Message as _

mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
stool = getToolByInterfaceName('Products.CMFCore.interfaces.ISkinsTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()


if stool.updateSkinCookie():
    context.setupCurrentSkin()


options = {}

isAnon = mtool.isAnonymousUser()
if isAnon:
    context.REQUEST.RESPONSE.expireCookie('__ac', path='/')
    options['is_anon'] = True
    options['title'] = _(u'Login failure')
    options['admin_email'] = ptool.getProperty('email_from_address')
else:
    mtool.createMemberArea()
    member = mtool.getAuthenticatedMember()
    now = context.ZopeTime()
    last_login = member.getProperty('login_time', None)
    member.setProperties(last_login_time=last_login, login_time=now)
Beispiel #4
0
##parameters=password, confirm, domains=None, **kw
##title=Action to change password
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _

mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')

result = rtool.testPasswordValidity(password, confirm)
if result:
    return context.setStatus(False, result)

member = mtool.getAuthenticatedMember()
mtool.setPassword(password, domains)
if member.getProperty('last_login_time') == DateTime('1999/01/01'):
    member.setProperties(last_login_time='2000/01/01')

mtool.credentialsChanged(password)

return context.setStatus(True, _(u'Password changed.'))
Beispiel #5
0
##parameters=
##
from Products.CMFCore.utils import getToolByInterfaceName

mtool = getToolByInterfaceName(script,
                               'Products.CMFCore.interfaces.IMembershipTool')

home = mtool.getHomeFolder()
if not hasattr(home, 'Favorites'):
    home.manage_addPortalFolder(id='Favorites', title='Favorites')
favorites = getattr(home, 'Favorites')

f_id = 'fav_' + str(int(context.ZopeTime()))
f_title = context.TitleOrId()
f_url = context.absolute_url()
favorites.invokeFactory('Favorite', id=f_id, title=f_title, remote_url=f_url)

context.setRedirect(context, 'object/view')
Beispiel #6
0
##parameters=member=None, password='******', email='*****@*****.**'
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import makeEmail
from Products.CMFDefault.utils import Message as _

atool = getToolByInterfaceName(script,
                               'Products.CMFCore.interfaces.IActionsTool')
ptool = getToolByInterfaceName(script,
                               'Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByInterfaceName(script, 'Products.CMFCore.interfaces.IURLTool')
portal_url = utool()

options = {}

options['portal_title'] = ptool.title()
options['portal_description'] = ptool.getProperty('description')
options['portal_url'] = portal_url

member_id = member and member.getId() or 'foo'
options['member_id'] = member_id
options['password'] = password

target = atool.getActionInfo('user/login')['url']
options['login_url'] = '%s' % target

email_from_name = ptool.getProperty('email_from_name')
options['signature'] = email_from_name

headers = {}
Beispiel #7
0
##parameters=b_start=0, key='', reverse=0, ids=(), new_ids=(), rename='', cancel=''
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _

utool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IURLTool'
                              )
portal_url = utool()


form = context.REQUEST.form
default_kw = {'b_start': b_start, 'key': key, 'reverse': reverse}
if rename and \
        context.folder_rename_control(**form) and \
        context.setRedirect(context, 'object/folderContents', **default_kw):
    return
elif cancel and \
        context.setRedirect(context, 'object/folderContents', **default_kw):
    return


options = {}

c = context.aq_explicit
raw_items = [ getattr(c, id) for id in ids if hasattr(c, id) ]
raw_items = [ item for item in raw_items if item.cb_isMoveable() ]
items = []
for item in raw_items:
Beispiel #8
0
##parameters=**kw
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _

ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')

if not ptool.hasProperty('default_charset'):
    ptool.manage_addProperty('default_charset', '', 'string')
if not ptool.hasProperty('email_charset'):
    ptool.manage_addProperty('email_charset', '', 'string')
ptool.editProperties(kw)

return context.setStatus(True, _(u'CMF Settings changed.'))
Beispiel #9
0
# Get the year and month that the calendar should display.

from Products.CMFCore.utils import getToolByInterfaceName

caltool = getToolByInterfaceName(
    'Products.CMFCalendar.interfaces.ICalendarTool')
current = DateTime()
session = None

# First priority goes to the data in the request
year = context.REQUEST.get('year', None)
month = context.REQUEST.get('month', None)

# Next get the data from the SESSION
if caltool.getUseSession():
    session = context.REQUEST.get('SESSION', None)
    if session:
        if not year:
            year = session.get('calendar_year', None)
        if not month:
            month = session.get('calendar_month', None)

# Last resort to today
if not year:
    year = current.year()
if not month:
    month = current.month()

# Then store the results in the session for next time
if session:
    session.set('calendar_year', year)
Beispiel #10
0
## Script (Python) "permalink"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Returns an object by unique id
##
from Products.CMFCore.utils import getToolByInterfaceName

subpath = traverse_subpath[0]
uid_handler=getToolByInterfaceName('Products.CMFUid.interfaces.UniqueIDHandler')

# appending 'isAvailable' instead of a unique id returns if
# the site permalink feature is available.
if str(subpath).strip() == 'isAvailable':
    # no permalink feature without an uid handler tool being installed
    if uid_handler is None:
        return '0'
    ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
    isAvailable = getattr(ptool, 'enable_permalink', 0)
    return str(int(isAvailable))

obj = uid_handler.getObject(subpath)

ti = obj.getTypeInfo()
method_id = ti and ti.queryMethodID('view', context=self)
if method_id:
    return getattr(obj, method_id)()
return obj()
Beispiel #11
0
##parameters=b_start=0, key='', reverse=0, ids=(), delta=1, items_copy='', items_cut='', items_delete='', items_new='', items_paste='', items_rename='', items_up='', items_down='', items_top='', items_bottom='', items_sort=''
##
from ZTUtils import Batch
from ZTUtils import make_query
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import AddPortalContent
from Products.CMFDefault.permissions import DeleteObjects
from Products.CMFDefault.permissions import ListFolderContents
from Products.CMFDefault.permissions import ManageProperties
from Products.CMFDefault.permissions import ViewManagementScreens
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _

mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()


form = context.REQUEST.form
default_target = 'object/folderContents'
default_kw = {'b_start': b_start, 'key': key, 'reverse': reverse}
if items_copy and \
        context.validateItemIds(**form) and \
        context.folder_copy_control(**form) and \
        context.setRedirect(context, default_target, **default_kw):
    return
elif items_cut and \
        context.validateItemIds(**form) and \
        context.folder_cut_control(**form) and \
        context.setRedirect(context, default_target, **default_kw):
Beispiel #12
0
##parameters=
##

from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import getBrowserCharset

atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
caltool_iface = 'Products.CMFCalendar.interfaces.ICalendarTool'
caltool = getToolByInterfaceName(caltool_iface, None)
mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
wtool = getToolByInterfaceName(wtool_iface)
portal_object = utool.getPortalObject()

if not 'charset' in context.REQUEST.RESPONSE.getHeader('content-type'):
    # Some newstyle views set a different charset - don't override it.
    # Oldstyle views need the default_charset.
    default_charset = ptool.getProperty('default_charset', None)
    if default_charset:
        context.REQUEST.RESPONSE.setHeader('content-type',
                                    'text/html; charset=%s' % default_charset)

message = context.REQUEST.get('portal_status_message')
if message and isinstance(message, str):
    # portal_status_message uses always the browser charset.
    message = message.decode(getBrowserCharset(context.REQUEST))

globals = {'utool': utool,
Beispiel #13
0
## Script (Python) "permalink"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Returns an object by unique id
##
from Products.CMFCore.utils import getToolByInterfaceName

subpath = traverse_subpath[0]
uid_handler = getToolByInterfaceName(
    'Products.CMFUid.interfaces.UniqueIDHandler')

# appending 'isAvailable' instead of a unique id returns if
# the site permalink feature is available.
if str(subpath).strip() == 'isAvailable':
    # no permalink feature without an uid handler tool being installed
    if uid_handler is None:
        return '0'
    ptool = getToolByInterfaceName(
        'Products.CMFCore.interfaces.IPropertiesTool')
    isAvailable = getattr(ptool, 'enable_permalink', 0)
    return str(int(isAvailable))

obj = uid_handler.getObject(subpath)

ti = obj.getTypeInfo()
method_id = ti and ti.queryMethodID('view', context=self)
if method_id:
Beispiel #14
0
##parameters=transaction_info
##title=Undo transactions
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _

utool = getToolByInterfaceName(script, 'Products.CMFCore.interfaces.IUndoTool')

utool.undo(context, transaction_info)

context.setStatus(True, _(u'Transaction(s) undone.'))
context.setRedirect(context, 'object/folderContents')
Beispiel #15
0
##parameters=
##title=Delete reply
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _

dtool = getToolByInterfaceName('Products.CMFCore.interfaces.IDiscussionTool')

parent = context.inReplyTo()
talkback = dtool.getDiscussionFor(parent)
talkback.deleteReply(context.getId())

context.setStatus(True, _(u'Reply deleted.'))
context.setRedirect(parent, 'object/view')
Beispiel #16
0
## Script (Python) "permalink"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Returns an object by unique id
##
from Products.CMFCore.utils import getToolByInterfaceName

subpath = traverse_subpath[0]
iface = 'Products.CMFUid.interfaces.UniqueIDHandler'
uid_handler = getToolByInterfaceName(context, iface)

# appending 'isAvailable' instead of a unique id returns if
# the site permalink feature is available.
if str(subpath).strip() == 'isAvailable':
    # no permalink feature without an uid handler tool being installed
    if uid_handler is None:
        return '0'
    ptool = getToolByInterfaceName(
        script, 'Products.CMFCore.interfaces.IPropertiesTool')
    isAvailable = getattr(ptool, 'enable_permalink', 0)
    return str(int(isAvailable))

obj = uid_handler.getObject(subpath)

ti = obj.getTypeInfo()
method_id = ti and ti.queryMethodID('view', context=self)
if method_id:
Beispiel #17
0
##parameters=member=None, password='******', email='*****@*****.**'
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import makeEmail
from Products.CMFDefault.utils import Message as _

atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()


options = {}

options['portal_title'] = ptool.title()
options['portal_description'] = ptool.getProperty('description')
options['portal_url'] = portal_url

member_id = member and member.getId() or 'foo'
options['member_id'] = member_id
options['password'] = password

target = atool.getActionInfo('user/login')['url']
options['login_url'] = '%s' % target

email_from_name = ptool.getProperty('email_from_name')
options['signature'] = email_from_name

headers = {}
headers['Subject'] = _(u'${portal_title}: Your Membership Information',
Beispiel #18
0
## Script (Python) "get_permalink"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Returns the permalink url or None
##
from Products.CMFCore.utils import getToolByInterfaceName

# calculate the permalink if the uid handler tool exists, permalinks
# are configured to be shown and the object is not folderish
uidtool = getToolByInterfaceName( context
                                , 'Products.CMFUid.interfaces.IUniqueIdHandler'
                                , default=None
                                )

if uidtool is not None:
    ptool = getToolByInterfaceName( script
                                  , 'Products.CMFCore.interfaces.IPropertiesTool'
                                  )
    showPermalink = getattr(ptool, 'enable_permalink', None)
    isFolderish = getattr(context.aq_explicit, 'isPrincipiaFolderish', None)
    
    if showPermalink and not isFolderish:
        # returns the uid (generates one if necessary)
        utool = getToolByInterfaceName( script
                                      , 'Products.CMFCore.interfaces.IURLTool'
                                      )
        uid = uidtool.register(context)
Beispiel #19
0
##parameters=member_id, password, member_email, send_password=False, **kw
##title=Add a member
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import ManageUsers
from Products.CMFDefault.utils import Message as _

mtool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IMembershipTool'
                              )
ptool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IPropertiesTool'
                              )
rtool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IRegistrationTool'
                              )

try:
    rtool.addMember( id=member_id, password=password,
                     properties={'username': member_id,
                                 'email': member_email} )
except ValueError, errmsg:
    return context.setStatus(False, errmsg)
else:
    if ptool.getProperty('validate_email') or send_password:
        rtool.registeredNotify(member_id)
    if mtool.checkPermission(ManageUsers, mtool):
        return context.setStatus(True, _(u'Member registered.'))
    else:
        return context.setStatus(False, _(u'Success!'), is_newmember=True)
Beispiel #20
0
##parameters=
##
from Products.CMFCore.utils import getToolByInterfaceName

mtool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IMembershipTool'
                              )

home = mtool.getHomeFolder()
if not hasattr(home, 'Favorites'):
    home.manage_addPortalFolder(id='Favorites', title='Favorites')
favorites = getattr(home, 'Favorites')

f_id = 'fav_' + str( int( context.ZopeTime() ) )
f_title = context.TitleOrId()
f_url = context.absolute_url()
favorites.invokeFactory('Favorite', id=f_id, title=f_title, remote_url=f_url)

context.setRedirect(context, 'object/view')
Beispiel #21
0
##parameters=b_start=0, key='', reverse=0, ids=(), delta=1, items_copy='', items_cut='', items_delete='', items_new='', items_paste='', items_rename='', items_up='', items_down='', items_top='', items_bottom='', items_sort=''
##
from ZTUtils import Batch
from ZTUtils import make_query
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import AddPortalContent
from Products.CMFDefault.permissions import DeleteObjects
from Products.CMFDefault.permissions import ListFolderContents
from Products.CMFDefault.permissions import ManageProperties
from Products.CMFDefault.permissions import ViewManagementScreens
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _

mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()

form = context.REQUEST.form
default_target = 'object/folderContents'
default_kw = {'b_start': b_start, 'key': key, 'reverse': reverse}
if items_copy and \
        context.validateItemIds(**form) and \
        context.folder_copy_control(**form) and \
        context.setRedirect(context, default_target, **default_kw):
    return
elif items_cut and \
        context.validateItemIds(**form) and \
        context.folder_cut_control(**form) and \
        context.setRedirect(context, default_target, **default_kw):
    return
Beispiel #22
0
##parameters=add='', edit='', preview=''
##
from Products.PythonScripts.standard import structured_text
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _

atool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IActionsTool'
                              )


form = context.REQUEST.form
is_preview = False
if add and \
        context.validateHTML(**form) and \
        context.discussion_reply(**form):
    return
elif preview and \
        context.validateHTML(**form):
    is_preview = True


options = {}

title = form.get('title', context.Title())
text = form.get('text', '')
options['is_preview'] = is_preview
options['title'] = title
options['text'] = text
Beispiel #23
0
 def _getToolByInterfaceName(self, dotted_name):
     return getToolByInterfaceName(self.context, dotted_name)
Beispiel #24
0
##parameters=
##
from ZTUtils import Batch
from ZTUtils import LazyFilter
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode

stool = getToolByInterfaceName('Products.CMFCore.interfaces.ISyndicationTool')

if not stool.isSyndicationAllowed(context):
    context.REQUEST.RESPONSE.redirect(
        context.absolute_url() +
        '/rssDisabled?portal_status_message=Syndication+is+Disabled')
    return

options = {}

options['channel_info'] = {
    'base': stool.getHTML4UpdateBase(context),
    'description': context.Description(),
    'frequency': stool.getUpdateFrequency(context),
    'period': stool.getUpdatePeriod(context),
    'title': context.Title(),
    'url': context.absolute_url()
}

key, reverse = context.getDefaultSorting()
items = stool.getSyndicatableContent(context)
items = sequence.sort(items, ((key, 'cmp', reverse and 'desc' or 'asc'), ))
items = LazyFilter(items, skip='View')
b_size = stool.getMaxItems(context)
Beispiel #25
0
##parameters=provider, action_path, **kw
##
from ZTUtils import make_query
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import getBrowserCharset

utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()

try:
    target = provider.getActionInfo(action_path)['url']
except ValueError:
    target = portal_url

message = context.REQUEST.other.get('portal_status_message', '')
if message:
    if isinstance(message, unicode):
        message = unicode(message).encode(getBrowserCharset(context.REQUEST))
    kw['portal_status_message'] = message
for k, v in kw.items():
    if not v:
        del kw[k]

query = kw and ('?%s' % make_query(kw)) or ''
context.REQUEST.RESPONSE.redirect('%s%s' % (target, query))

return True
Beispiel #26
0
##parameters=search=''
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import ReviewPortalContent
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import Message as _

ctool = getToolByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
ttool = getToolByInterfaceName('Products.CMFCore.interfaces.ITypesTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()


options = {}
options['title'] = context.Title()

is_review_allowed = mtool.checkPermission(ReviewPortalContent, context)
options['is_review_allowed'] = is_review_allowed
options['listAvailableSubjects'] = ctool.uniqueValuesFor('Subject')

created = []
today = context.ZopeTime().earliestTime()
created.append({'value': '1970/01/01 00:00:01 GMT', 'title': _(u'Ever')})
if not mtool.isAnonymousUser():
    created.append({'value': mtool.getAuthenticatedMember().last_login_time,
                    'title': _(u'Last login')})
created.append({'value': (today-1).Date(), 'title': _(u'Yesterday')})
created.append({'value': (today-7).Date(), 'title': _(u'Last week')})
created.append({'value': (today-31).Date(), 'title': _(u'Last month')})
options['listCreatedInfos'] = tuple(created)
Beispiel #27
0
##parameters=
##
from ZTUtils import Batch
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode

ctool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.ICatalogTool'
                              )

options = {}

items = ctool.searchResults(portal_type='News Item', sort_on='Date',
                            sort_order='reverse', review_state='published')
batch_obj = Batch(items, 10, 0, orphan=1)
items = [ {'title': item.Title,
           'date': item.Date,
           'url': item.getURL()}
          for item in batch_obj ]
options['listItemInfos'] = items

return context.news_box_template(**decode(options, script))
Beispiel #28
0
## Script (Python) "rejectItems"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=items, comment=''
##title=
##

from Products.CMFCore.utils import getToolByInterfaceName

wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
wtool = getToolByInterfaceName(wtool_iface)

for path in items:
    object = context.restrictedTraverse( path )
    wtool.doActionFor( object, 'reject', comment=comment )

context.REQUEST[ 'RESPONSE' ].redirect( '%s/review?%s'
                   % ( context.portal_url()
                     , 'portal_status_message=Items+rejected.'
                     ) )
Beispiel #29
0
##parameters=change='', change_and_edit='', change_and_view=''
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import Message as _

mdtool = getToolByInterfaceName( script
                               , 'Products.CMFCore.interfaces.IMetadataTool'
                               )


form = context.REQUEST.form
if change and \
        context.metadata_edit_control(**form) and \
        context.setRedirect(context, 'object/metadata'):
    return
elif change_and_edit and \
        context.metadata_edit_control(**form) and \
        context.setRedirect(context, 'object/edit'):
    return
elif change_and_view and \
        context.metadata_edit_control(**form) and \
        context.setRedirect(context, 'object/view'):
    return


options = {}

allow_discussion = getattr(context, 'allow_discussion', None)
if allow_discussion is not None:
    allow_discussion = bool(allow_discussion)
Beispiel #30
0
##parameters=
##

from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import getBrowserCharset

atool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IActionsTool'
                              )
mtool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IMembershipTool'
                              )
ptool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IPropertiesTool'
                              )
utool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IURLTool'
                              )
wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
wtool = getToolByInterfaceName(script, wtool_iface)
portal_object = utool.getPortalObject()

if not 'charset' in context.REQUEST.RESPONSE.getHeader('content-type'):
    # Some newstyle views set a different charset - don't override it.
    # Oldstyle views need the default_charset.
    default_charset = ptool.getProperty('default_charset', None)
    if default_charset:
        context.REQUEST.RESPONSE.setHeader('content-type',
                                    'text/html; charset=%s' % default_charset)
Beispiel #31
0
##parameters=b_start=0, member_id='', member_email='', password='', confirm='', send_password='', add='', cancel=''
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import ManageUsers
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import Message as _

atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
validate_email = ptool.getProperty('validate_email')
is_anon = mtool.isAnonymousUser()
is_newmember = False
is_usermanager = mtool.checkPermission(ManageUsers, mtool)

form = context.REQUEST.form
if add and \
        context.validatePassword(**form) and \
        context.members_add_control(**form) and \
        context.setRedirect(atool, 'user/join', b_start=b_start):
    return
elif cancel and \
        context.setRedirect(atool, 'global/manage_members', b_start=b_start):
    return

options = {}

if context.REQUEST.get('is_newmember', False) == True:
    is_anon = False
Beispiel #32
0
# Get the year and month that the calendar should display.

from Products.CMFCore.utils import getToolByInterfaceName

caltool = getToolByInterfaceName( script
                                , 'Products.CMFCalendar.interfaces.ICalendarTool'
                                )
current = DateTime()
session = None

# First priority goes to the data in the request
year = context.REQUEST.get('year', None)
month = context.REQUEST.get('month', None)

# Next get the data from the SESSION
if caltool.getUseSession():
    session = context.REQUEST.get('SESSION', None)
    if session:
        if not year:
            year = session.get('calendar_year', None)
        if not month:
            month = session.get('calendar_month', None)

# Last resort to today
if not year:
    year = current.year()
if not month:
    month = current.month()

# Then store the results in the session for next time
Beispiel #33
0
##parameters=b_start=0
##
from Products.PythonScripts.standard import structured_text
from ZTUtils import Batch
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode

ctool = getToolByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()


options = {}

target = '%s/recent_news' % portal_url
items = ctool.searchResults(portal_type='News Item', sort_on='Date',
                            sort_order='reverse', review_state='published')
batch_obj = Batch(items, 10, b_start, orphan=1)

items = [ {'creators': item.listCreators,
           'date': item.Date,
           'description': structured_text(item.Description),
           'title': item.Title,
           'url': item.getURL()}
          for item in batch_obj ]

navigation = context.getBatchNavigation(batch_obj, target)
options['batch'] = {'listItemInfos': items,
                    'navigation': navigation}

return context.recent_news_template(**decode(options, script))
Beispiel #34
0
##parameters=
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import Message as _

mtool = getToolByInterfaceName(script,
                               'Products.CMFCore.interfaces.IMembershipTool')
ptool = getToolByInterfaceName(script,
                               'Products.CMFCore.interfaces.IPropertiesTool')
stool = getToolByInterfaceName(script,
                               'Products.CMFCore.interfaces.ISkinsTool')
utool = getToolByInterfaceName(script, 'Products.CMFCore.interfaces.IURLTool')
portal_url = utool()

if stool.updateSkinCookie():
    context.setupCurrentSkin()

options = {}

isAnon = mtool.isAnonymousUser()
if isAnon:
    context.REQUEST.RESPONSE.expireCookie('__ac', path='/')
    options['is_anon'] = True
    options['title'] = _(u'Login failure')
    options['admin_email'] = ptool.getProperty('email_from_address')
else:
    mtool.createMemberArea()
    member = mtool.getAuthenticatedMember()
    now = context.ZopeTime()
    last_login = member.getProperty('login_time', None)
Beispiel #35
0
##parameters=ids, b_start=0, delete='', cancel=''
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _

atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')

form = context.REQUEST.form
if delete and \
        context.members_delete_control(**form) and \
        context.setRedirect(atool, 'global/manage_members', b_start=b_start):
    return
elif cancel and \
        context.setRedirect(atool, 'global/manage_members', b_start=b_start):
    return

options = {}

target = atool.getActionInfo('global/members_delete')['url']
hidden_vars = []
for name, value in html_marshal(b_start=b_start, ids=ids):
    hidden_vars.append({'name': name, 'value': value})
buttons = []
buttons.append({'name': 'delete', 'value': _(u'Delete')})
buttons.append({'name': 'cancel', 'value': _(u'Cancel')})
options['form'] = {
    'action': target,
    'members': ', '.join(ids),
    'listHiddenVarInfos': tuple(hidden_vars),
Beispiel #36
0
 def _getToolByInterfaceName(self, dotted_name):
     return getToolByInterfaceName(self.context, dotted_name)
Beispiel #37
0
##parameters=b_start=0, ids=(), members_new='', members_delete=''
##
from ZTUtils import Batch
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _

atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')


form = context.REQUEST.form
if members_delete and \
        context.validateMemberIds(**form) and \
        context.setRedirect(atool, 'global/members_delete', b_start=b_start,
                            ids=ids):
    return
elif members_new and \
        context.setRedirect(atool, 'user/join', b_start=b_start):
    return


options = {}

target = atool.getActionInfo('global/manage_members')['url']

members = mtool.listMembers()
batch_obj = Batch(members, 25, b_start, orphan=0)
items = []
for member in batch_obj:
Beispiel #38
0
##parameters=transaction_info
##title=Undo transactions
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _

utool = getToolByInterfaceName('Products.CMFCore.interfaces.IUndoTool')

utool.undo(context, transaction_info)

context.setStatus(True, _(u'Transaction(s) undone.'))
context.setRedirect(context, 'object/folderContents')
Beispiel #39
0
##parameters=
##
from ZTUtils import Batch
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode

ctool = getToolByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')

options = {}

items = ctool.searchResults(portal_type='News Item',
                            sort_on='Date',
                            sort_order='reverse',
                            review_state='published')
batch_obj = Batch(items, 10, 0, orphan=1)
items = [{
    'title': item.Title,
    'date': item.Date,
    'url': item.getURL()
} for item in batch_obj]
options['listItemInfos'] = items

return context.news_box_template(**decode(options, script))
Beispiel #40
0
## Script (Python) "rejectItems"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=items, comment=''
##title=
##

from Products.CMFCore.utils import getToolByInterfaceName

wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
wtool = getToolByInterfaceName(script, wtool_iface)

for path in items:
    object = context.restrictedTraverse( path )
    wtool.doActionFor( object, 'reject', comment=comment )

context.REQUEST[ 'RESPONSE' ].redirect( '%s/review?%s'
                   % ( context.portal_url()
                     , 'portal_status_message=Items+rejected.'
                     ) )
Beispiel #41
0
##parameters=
##title=Delete reply
##
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _

dtool = getToolByInterfaceName( script
                              , 'Products.CMFCore.interfaces.IDiscussionTool'
                              )

parent = context.inReplyTo()
talkback = dtool.getDiscussionFor(parent)
talkback.deleteReply( context.getId() )

context.setStatus(True, _(u'Reply deleted.'))
context.setRedirect(parent, 'object/view')
Beispiel #42
0
##parameters=
##

from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import getBrowserCharset

atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
caltool_iface = 'Products.CMFCalendar.interfaces.ICalendarTool'
caltool = getToolByInterfaceName(caltool_iface, None)
mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
wtool = getToolByInterfaceName(wtool_iface)
portal_object = utool.getPortalObject()

if not 'charset' in context.REQUEST.RESPONSE.getHeader('content-type'):
    # Some newstyle views set a different charset - don't override it.
    # Oldstyle views need the default_charset.
    default_charset = ptool.getProperty('default_charset', None)
    if default_charset:
        context.REQUEST.RESPONSE.setHeader(
            'content-type', 'text/html; charset=%s' % default_charset)

message = context.REQUEST.get('portal_status_message')
if message and isinstance(message, str):
    # portal_status_message uses always the browser charset.
    message = message.decode(getBrowserCharset(context.REQUEST))

globals = {
Beispiel #43
0
##parameters=b_start=0
##
from Products.PythonScripts.standard import structured_text
from ZTUtils import Batch
from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode

ctool = getToolByInterfaceName(script,
                               'Products.CMFCore.interfaces.ICatalogTool')
utool = getToolByInterfaceName(script, 'Products.CMFCore.interfaces.IURLTool')
portal_url = utool()

options = {}

target = '%s/recent_news' % portal_url
items = ctool.searchResults(portal_type='News Item',
                            sort_on='Date',
                            sort_order='reverse',
                            review_state='published')
batch_obj = Batch(items, 10, b_start, orphan=1)

items = [{
    'creators': item.listCreators,
    'date': item.Date,
    'description': structured_text(item.Description),
    'title': item.Title,
    'url': item.getURL()
} for item in batch_obj]

navigation = context.getBatchNavigation(batch_obj, target)
options['batch'] = {'listItemInfos': items, 'navigation': navigation}
Beispiel #44
0
## Script (Python) "rejectItems"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=items, comment=''
##title=
##

from Products.CMFCore.utils import getToolByInterfaceName

wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
wtool = getToolByInterfaceName(wtool_iface)

for path in items:
    object = context.restrictedTraverse(path)
    wtool.doActionFor(object, 'reject', comment=comment)

context.REQUEST['RESPONSE'].redirect(
    '%s/review?%s' %
    (context.portal_url(), 'portal_status_message=Items+rejected.'))
Beispiel #45
0
## Script (Python) "permalink"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Returns an object by unique id
##
from Products.CMFCore.utils import getToolByInterfaceName

subpath = traverse_subpath[0]
iface = 'Products.CMFUid.interfaces.UniqueIDHandler'
uid_handler = getToolByInterfaceName(context, iface)

# appending 'isAvailable' instead of a unique id returns if
# the site permalink feature is available.
if str(subpath).strip() == 'isAvailable':
    # no permalink feature without an uid handler tool being installed
    if uid_handler is None:
        return '0'
    ptool = getToolByInterfaceName( script
                                  , 'Products.CMFCore.interfaces.IPropertiesTool'
                                  )
    isAvailable = getattr(ptool, 'enable_permalink', 0)
    return str(int(isAvailable))

obj = uid_handler.getObject(subpath)

ti = obj.getTypeInfo()
method_id = ti and ti.queryMethodID('view', context=self)
Beispiel #46
0
## Script (Python) "rejectItems"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=items, comment=''
##title=
##

from Products.CMFCore.utils import getToolByInterfaceName

wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
wtool = getToolByInterfaceName(script, wtool_iface)

for path in items:
    object = context.restrictedTraverse(path)
    wtool.doActionFor(object, 'reject', comment=comment)

context.REQUEST['RESPONSE'].redirect(
    '%s/review?%s' %
    (context.portal_url(), 'portal_status_message=Items+rejected.'))