##############################################################################
#
# __init__.py	Initialization code for the LDAPUserFolder
#
# This software is governed by a license. See
# LICENSE.txt for the terms of this license.
# 
##############################################################################
__version__ = '$Revision: 1415 $'[11:-2]

from AccessControl.Permissions import add_user_folders

from Products.LDAPUserFolder.LDAPUserFolder import LDAPUserFolder
from Products.LDAPUserFolder.LDAPUserFolder import manage_addLDAPUserFolder
from Products.LDAPUserFolder.LDAPUserSatellite import addLDAPUserSatelliteForm
from Products.LDAPUserFolder.LDAPUserSatellite import manage_addLDAPUserSatellite
from Products.LDAPUserFolder.LDAPUserSatellite import LDAPUserSatellite 

try:
    from Products.CMFCore.DirectoryView import registerDirectory
    from Products.CMFCore.interfaces import ISiteRoot
    registerDirectory('skins', globals())

    from Products.GenericSetup import EXTENSION
    from Products.GenericSetup import profile_registry

    have_cmf = True
except ImportError:
    have_cmf = False


def initialize(context):
    context.registerClass( LDAPUserFolder
                         , permission=add_user_folders
                         , constructors=(manage_addLDAPUserFolder,)
                         , icon='www/ldapuserfolder.gif'
                         )

    context.registerClass( LDAPUserSatellite
                         , permission=add_user_folders
                         , constructors=( addLDAPUserSatelliteForm
                                        , manage_addLDAPUserSatellite
                                        )
                         , icon='www/ldapusersatellite.gif'
                         )

    context.registerHelp()

    if have_cmf:
        profile_registry.registerProfile( 'default'
                                        , 'LDAPUserFolder CMF Tools'
                                        , 'Adds LDAP support to the CMF.'
                                        , 'profiles/default'
                                        , 'LDAPUserFolder'
                                        , EXTENSION
                                        , for_=ISiteRoot
                                        )
