def allowEmbedTags(self, portal):
     """
     Allows embed, object, and param tags by default.
     """
     
     adapter = IFilterSchema(portal)
     nasty_tags = adapter.nasty_tags
     if 'object' in nasty_tags:
         nasty_tags.remove('object')
     if 'embed' in nasty_tags:
         nasty_tags.remove('embed')
         
     stripped_tags = adapter.stripped_tags
     if 'object' in stripped_tags:
         stripped_tags.remove('object')
     if 'param' in stripped_tags:
         stripped_tags.remove('param')
         
     custom_tags = adapter.custom_tags
     if not 'embed' in custom_tags:
         custom_tags.append('embed')
         
     adapter.nasty_tags = nasty_tags
     adapter.stripped_tags = stripped_tags
     adapter.custom_tags = custom_tags
     logger.info("Allowing embed, object, param tags in site content.")
def allow_embed_tags(portal):
    filtering = IFilterSchema(portal)
    nasty_tags = filtering.nasty_tags
    for t in ['embed','param','iframe','object','script']:
        if t in nasty_tags:
            nasty_tags.remove(t)
    filtering.nasty_tags = nasty_tags
    custom_tags = filtering.custom_tags
    for t in ['iframe']:
        if t not in custom_tags:
            custom_tags.append(t)
    filtering.custom_tags = custom_tags
Exemple #3
0
def setup_html_filter(portal):
    """Setup HTML filtering for resultsinterpretations
    """
    logger.info("*** Setup HTML Filter ***")
    # bypass the broken API from portal_transforms
    adapter = IFilterSchema(portal)
    style_whitelist = adapter.style_whitelist
    for style in ALLOWED_STYLES:
        logger.info("Allow style '{}'".format(style))
        if style not in style_whitelist:
            style_whitelist.append(style)
    adapter.style_whitelist = style_whitelist
Exemple #4
0
def upgrade_230_240_1(context, logger=None):
    if logger is None:
        logger = LOG
    # Run GS steps
    portal = api.portal.get()
    setup = api.portal.get_tool('portal_setup')
    setup.runImportStepFromProfile(PROFILE_ID, 'rolemap')
    setup.runImportStepFromProfile(PROFILE_ID, 'actions')
    setup.runImportStepFromProfile(PROFILE_ID, 'typeinfo')
    setup.runImportStepFromProfile(PROFILE_ID, 'workflow')
    setup.runImportStepFromProfile(PROFILE_ID, 'viewlets')
    setup.runImportStepFromProfile(PROFILE_ID, 'plone.app.registry')
    setup.runImportStepFromProfile(PROFILE_ID, 'org.bccvl.site.content')
    setup.runImportStepFromProfile(PROFILE_ID, 'org.bccvl.site.facet')

    # install new dependencies
    qi = getToolByName(portal, 'portal_quickinstaller')
    installable = [p['id'] for p in qi.listInstallableProducts()]
    for product in ['collective.emailconfirmationregistration',
                    'plone.formwidget.captcha',
                    'collective.z3cform.norobots']:
        if product in installable:
            qi.installProduct(product)

    # enable self registration
    from plone.app.controlpanel.security import ISecuritySchema
    security = ISecuritySchema(portal)
    security.enable_self_reg = True
    security.enable_user_pwd_choice = True

    # setup userannotation storage
    from org.bccvl.site.userannotation.utility import init_user_annotation
    from org.bccvl.site.userannotation.interfaces import IUserAnnotationsUtility
    init_user_annotation()
    # migrate current properties into userannotations
    pm = api.portal.get_tool('portal_membership')
    pmd = api.portal.get_tool('portal_memberdata')
    custom_props = [p for p in pmd.propertyIds() if '_oauth_' in p]
    ut = getUtility(IUserAnnotationsUtility)
    for member in pm.listMembers():
        member_annots = ut.getAnnotations(member)
        for prop in custom_props:
            if not member.hasProperty(prop):
                continue
            value = member.getProperty(prop)
            if not value:
                continue
            member_annots[prop] = value
            member.setMemberProperties({prop: ''})
    # remove current properties
    pmd.manage_delProperties(custom_props)

    # setup html filtering
    from plone.app.controlpanel.filter import IFilterSchema
    filters = IFilterSchema(portal)
    # remove some nasty tags:
    current_tags = filters.nasty_tags
    for tag in ('embed', 'object'):
        if tag in current_tags:
            current_tags.remove(tag)
    filters.nasty_tags = current_tags
    # remove some stripped tags:
    current_tags = filters.stripped_tags
    for tag in ('button', 'object', 'param'):
        if tag in current_tags:
            current_tags.remove(tag)
    filters.stripped_tags = current_tags
    # add custom allowed tags
    current_tags = filters.custom_tags
    for tag in ('embed', ):
        if tag not in current_tags:
            current_tags.append(tag)
    filters.custom_tags = current_tags
    # add custom allowed styles
    current_styles = filters.style_whitelist
    for style in ('border-radius', 'padding', 'margin-top', 'margin-bottom', 'background', 'color'):
        if style not in current_styles:
            current_styles.append(style)
    filters.style_whitelist = current_styles

    # configure TinyMCE plugins (can't be done zia tinymce.xml
    tinymce = getToolByName(portal, 'portal_tinymce')
    current_plugins = tinymce.plugins
    if 'media' in current_plugins:
        current_plugins.remove('media')
    tinymce.plugins = current_plugins
Exemple #5
0
def setupVarious(context, logger=None):
    if logger is None:
        logger = LOG
    logger.info('BCCVL site package setup handler')

    # only run for this product
    if context.readDataFile('org.bccvl.site.marker.txt') is None:
        return
    portal = context.getSite()

    # install Products.AutoUserMakerPASPLugin
    qi = getToolByName(portal, 'portal_quickinstaller')
    if 'AutoUserMakerPASPLugin' in (p['id'] for
                                    p in qi.listInstallableProducts()):
        qi.installProduct('AutoUserMakerPASPlugin')

    # set default front-page
    portal.setDefaultPage('front-page')

    # Setup cookie settings
    sess = portal.acl_users.session
    sess.manage_changeProperties(
        mod_auth_tkt=True,
    )
    # set cookie secret from celery configuration
    from org.bccvl.tasks.celery import app
    cookie_cfg = app.conf.get('bccvl', {}).get('cookie', {})
    if cookie_cfg.get('secret', None):
        sess._shared_secret = cookie_cfg.get('secret').encode('utf-8')
        sess.manage_changeProperties(
            secure=cookie_cfg.get('secure', True)
        )

    # setup default groups
    groups = [
        {'id': 'Knowledgebase Contributor',
         'title': 'Knowledgebase Contributor',
         #'roles': ['...', '...']
         'description': 'Users in this group can contribute to knowledge base'
         },
        {'id': 'Knowledgebase Editor',
         'title': 'Knowledgebase Editor',
         'description': 'Users in this group can manage knowledgebase content'
         }]
    gtool = getToolByName(portal, 'portal_groups')
    for group in groups:
        if gtool.getGroupById(group['id']):
            gtool.editGroup(**group)
        else:
            gtool.addGroup(**group)

    # enable self registration
    from plone.app.controlpanel.security import ISecuritySchema
    security = ISecuritySchema(portal)
    security.enable_self_reg = True
    security.enable_user_pwd_choice = True

    # setup html filtering
    from plone.app.controlpanel.filter import IFilterSchema
    filters = IFilterSchema(portal)
    # remove some nasty tags:
    current_tags = filters.nasty_tags
    for tag in ('embed', 'object'):
        if tag in current_tags:
            current_tags.remove(tag)
    filters.nasty_tags = current_tags
    # remove some stripped tags:
    current_tags = filters.stripped_tags
    for tag in ('button', 'object', 'param'):
        if tag in current_tags:
            current_tags.remove(tag)
    filters.stripped_tags = current_tags
    # add custom allowed tags
    current_tags = filters.custom_tags
    for tag in ('embed', ):
        if tag not in current_tags:
            current_tags.append(tag)
    filters.custom_tags = current_tags
    # add custom allowed styles
    current_styles = filters.style_whitelist
    for style in ('border-radius', 'padding', 'margin-top', 'margin-bottom', 'background', 'color'):
        if style not in current_styles:
            current_styles.append(style)
    filters.style_whitelist = current_styles

    # configure TinyMCE plugins (can't be done zia tinymce.xml
    tinymce = getToolByName(portal, 'portal_tinymce')
    current_plugins = tinymce.plugins
    if 'media' in current_plugins:
        # disable media plugin which get's in the way all the time
        current_plugins.remove('media')
    tinymce.plugins = current_plugins