1
2
3
4
5
6
7
8
9
10
11
12
13 """ Portal class
14
15 $Id: ZentinelPortal.py,v 1.17 2004/04/08 15:35:25 edahl Exp $
16 """
17
18 import os
19 import urllib
20
21 import Globals
22
23 from zExceptions import Redirect
24 from AccessControl.User import manage_addUserFolder
25 from AccessControl import getSecurityManager, ClassSecurityInfo
26
27 from Products.Sessions.BrowserIdManager import constructBrowserIdManager
28 from Products.Sessions.SessionDataManager import constructSessionDataManager
29
30 from Products.CMFCore.PortalObject import PortalObjectBase
31 from Products.CMFCore import PortalFolder
32 from Products.CMFCore.utils import getToolByName
33
34 from Products.ZenUtils import Security
35
36 from ZenossSecurity import *
37
38 from Products.AdvancedQuery import MatchGlob, Eq, Or, And, In
39
41 """
42 The *only* function this class should have is to help in the setup
43 of a new ZentinelPortal. It should not assist in the functionality at all.
44 """
45 meta_type = 'ZentinelPortal'
46
47 _properties = (
48 {'id':'title', 'type':'string'},
49 {'id':'description', 'type':'text'},
50 )
51 title = ''
52 description = ''
53
54 security = ClassSecurityInfo()
55
58
59
60 security.declareProtected(ZEN_COMMON, 'searchDevices')
62 """Returns the concatenation of a device name, ip and mac
63 search on the list of devices.
64 """
65 zcatalog = self.dmd.Devices.deviceSearch
66 glob = queryString.rstrip('*') + '*'
67 glob = MatchGlob('id', glob)
68 query = Or(glob, Eq('getDeviceIp', queryString))
69 brains = zcatalog.evalAdvancedQuery(query)
70 if REQUEST and len(brains) == 1:
71 raise Redirect(urllib.quote(brains[0].getPrimaryId))
72 try:
73 brains += self.dmd.Networks.ipSearch.evalAdvancedQuery(glob)
74 except AttributeError:
75 pass
76 return [ b.getObject() for b in brains ]
77
78
79 security.declareProtected(ZEN_COMMON, 'getOrganizerNames')
85
86 security.declareProtected(ZEN_COMMON, 'getRootOrganizerInfo')
91
92 security.declareProtected(ZEN_COMMON, 'jsonGetDeviceNames')
94 """Return a list of devices for the dashboard
95 """
96 return self.dmd.Devices.jsonGetDeviceNames()
97
98
106
107
109 """Check to see of a user has a role.
110 """
111 if obj is None: obj = self
112 user = getSecurityManager().getUser()
113 if user: return user.has_role(role, obj)
114
115
117 """Check to see of a user has a permission.
118 """
119 if obj is None: obj = self
120 user = getSecurityManager().getUser()
121 if user: return user.has_permission(perm, obj)
122
123
124 Globals.InitializeClass(ZentinelPortal)
125
126
128
129 klass = ZentinelPortal
130
135
136
138 p.manage_addProduct['MailHost'].manage_addMailHost(
139 'MailHost', smtp_host='localhost')
140
141
146
147
153
154
158
159
161
162 mp = p.manage_permission
163 mp(ZEN_CHANGE_SETTINGS,[ZEN_MANAGER_ROLE, OWNER_ROLE, MANAGER_ROLE,], 1)
164 mp(ZEN_CHANGE_DEVICE, [ZEN_MANAGER_ROLE, OWNER_ROLE, MANAGER_ROLE,], 1)
165 mp(ZEN_MANAGE_DMD, [ZEN_MANAGER_ROLE, OWNER_ROLE, MANAGER_ROLE,], 1)
166 mp(ZEN_DELETE, [ZEN_MANAGER_ROLE, OWNER_ROLE, MANAGER_ROLE,], 1)
167 mp(ZEN_ADD, [ZEN_MANAGER_ROLE, OWNER_ROLE, MANAGER_ROLE,], 1)
168 mp(ZEN_VIEW, [ZEN_USER_ROLE, ZEN_MANAGER_ROLE,
169 MANAGER_ROLE, OWNER_ROLE])
170 mp(ZEN_COMMON, ["Authenticated", ZEN_USER_ROLE, ZEN_MANAGER_ROLE,
171 MANAGER_ROLE, OWNER_ROLE], 1)
172 mp(ZEN_CHANGE_ALERTING_RULES,
173 [ZEN_MANAGER_ROLE, MANAGER_ROLE, OWNER_ROLE], 1)
174 mp(ZEN_CHANGE_ADMIN_OBJECTS, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
175 mp(ZEN_CHANGE_EVENT_VIEWS, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
176 mp(ZEN_ADMIN_DEVICE, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
177 mp(ZEN_MANAGE_DEVICE, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
178 mp(ZEN_ZPROPERTIES_EDIT, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
179 mp(ZEN_ZPROPERTIES_VIEW,
180 [ZEN_MANAGER_ROLE, MANAGER_ROLE, ZEN_USER_ROLE], 1)
181 mp(ZEN_EDIT_LOCAL_TEMPLATES, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
182 mp(ZEN_DEFINE_COMMANDS_EDIT, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
183 mp(ZEN_DEFINE_COMMANDS_VIEW,
184 [ZEN_MANAGER_ROLE, MANAGER_ROLE, ZEN_USER_ROLE], 1)
185 mp(ZEN_MAINTENANCE_WINDOW_EDIT, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
186 mp(ZEN_MAINTENANCE_WINDOW_VIEW,
187 [ZEN_MANAGER_ROLE, MANAGER_ROLE, ZEN_USER_ROLE], 1)
188 mp(ZEN_ADMINISTRATORS_EDIT, [ZEN_MANAGER_ROLE, MANAGER_ROLE], 1)
189 mp(ZEN_ADMINISTRATORS_VIEW,
190 [ZEN_MANAGER_ROLE, MANAGER_ROLE, ZEN_USER_ROLE], 1)
191
193 from Products.CMFCore.DirectoryView import addDirectoryViews
194 ps = getToolByName(p, 'portal_skins')
195 addDirectoryViews(ps, 'skins', globals())
196 ps.manage_addProduct['OFSP'].manage_addFolder(id='custom')
197 ps.addSkinSelection('Basic', "custom, zenmodel", make_default=1)
198 p.setupCurrentSkin()
199
200
202 """build a session manager and brower id manager for zport"""
203 constructBrowserIdManager(p, cookiepath="/zport")
204 constructSessionDataManager(p, "session_data_manager",
205 title="Session Data Manager",
206 path='/temp_folder/session_data')
207
208
209 - def setup(self, p, create_userfolder):
219
220
221 - def create(self, parent, id, create_userfolder):
229
230
231 - def setupDefaultProperties(self, p, title, description,
232 email_from_address, email_from_name,
233 validate_email,
234 ):
240
241
242 manage_addZentinelPortal = Globals.HTMLFile('dtml/addPortal', globals())
243 manage_addZentinelPortal.__name__ = 'addPortal'
244
245 -def manage_addZentinelPortal(self, id="zport", title='Zentinel Portal',
246 description='',
247 create_userfolder=True,
248 email_from_address='postmaster@localhost',
249 email_from_name='Portal Administrator',
250 validate_email=0, RESPONSE=None):
263