eggification
[GroupUserFolder.git] / Products / GroupUserFolder / __init__.py
1 # -*- coding: utf-8 -*-
2 ## GroupUserFolder
3 ## Copyright (C)2006 Ingeniweb
4
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2 of the License, or
8 ## (at your option) any later version.
9
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
14
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; see the file COPYING. If not, write to the
17 ## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 """
19
20 """
21 __version__ = "$Revision: $"
22 # $Source: $
23 # $Id: __init__.py 40111 2007-04-01 09:12:57Z alecm $
24 __docformat__ = 'restructuredtext'
25
26 # postonly protections
27 try:
28 # Zope 2.8.9, 2.9.7 and 2.10.3 (and up)
29 from AccessControl.requestmethod import postonly
30 except ImportError:
31 try:
32 # Try the hotfix too
33 from Products.Hotfix_20070320 import postonly
34 except:
35 def postonly(callable): return callable
36
37
38 import GroupUserFolder
39 import GRUFFolder
40 import PatchCatalogTool
41 try:
42 import Products.LDAPUserFolder
43 hasLDAP = 1
44 except ImportError:
45 hasLDAP = 0
46 from global_symbols import *
47
48 # Plone import try/except
49 try:
50 from Products.CMFCore.DirectoryView import registerDirectory
51 import GroupsToolPermissions
52 except:
53 # No registerdir available -> we ignore
54 pass
55
56 # Used in Extension/install.py
57 global groupuserfolder_globals
58 groupuserfolder_globals=globals()
59
60 # LDAPUserFolder patching
61 if hasLDAP:
62 import LDAPGroupFolder
63
64 def patch_LDAPUF():
65 # Now we can patch LDAPUF
66 from Products.LDAPUserFolder import LDAPUserFolder
67 import LDAPUserFolderAdapter
68 LDAPUserFolder._doAddUser = LDAPUserFolderAdapter._doAddUser
69 LDAPUserFolder._doDelUsers = LDAPUserFolderAdapter._doDelUsers
70 LDAPUserFolder._doChangeUser = LDAPUserFolderAdapter._doChangeUser
71 LDAPUserFolder._find_user_dn = LDAPUserFolderAdapter._find_user_dn
72 LDAPUserFolder.manage_editGroupRoles = LDAPUserFolderAdapter.manage_editGroupRoles
73 LDAPUserFolder._mangleRoles = LDAPUserFolderAdapter._mangleRoles
74
75 # Patch LDAPUF : XXX FIXME: have to find something cleaner here?
76 patch_LDAPUF()
77
78 def initialize(context):
79
80 try:
81 registerDirectory('skins', groupuserfolder_globals)
82 except:
83 # No registerdir available => we ignore
84 pass
85
86 context.registerClass(
87 GroupUserFolder.GroupUserFolder,
88 permission='Add GroupUserFolders',
89 constructors=(GroupUserFolder.manage_addGroupUserFolder,),
90 icon='www/GroupUserFolder.gif',
91 )
92
93 if hasLDAP:
94 context.registerClass(
95 LDAPGroupFolder.LDAPGroupFolder,
96 permission='Add GroupUserFolders',
97 constructors=(LDAPGroupFolder.addLDAPGroupFolderForm, LDAPGroupFolder.manage_addLDAPGroupFolder,),
98 icon='www/LDAPGroupFolder.gif',
99 )
100
101 context.registerClass(
102 GRUFFolder.GRUFUsers,
103 permission='Add GroupUserFolder',
104 constructors=(GRUFFolder.manage_addGRUFUsers,),
105 visibility=None,
106 icon='www/GRUFUsers.gif',
107 )
108
109 context.registerClass(
110 GRUFFolder.GRUFGroups,
111 permission='Add GroupUserFolder',
112 constructors=(GRUFFolder.manage_addGRUFGroups,),
113 visibility=None,
114 icon='www/GRUFGroups.gif',
115 )
116
117 try:
118 from Products.CMFCore.utils import ToolInit, ContentInit
119 from GroupsTool import GroupsTool
120 from GroupDataTool import GroupDataTool
121 ToolInit( meta_type='CMF Groups Tool'
122 , tools=( GroupsTool, GroupDataTool, )
123 , icon="tool.gif"
124 ).initialize( context )
125
126 except ImportError:
127 Log(LOG_NOTICE, "Unable to import GroupsTool and/or GroupDataTool. \
128 This won't disable GRUF but if you use CMF/Plone you won't get benefit of its special features.")