1
2
3
4
5
6
7
8
9
10
11
12
13 """
14 AdministrativeRoleable.py
15
16 Created by Marc Irlandez on 2007-04-05.
17 """
18
19 import types
20 from AccessControl import ClassSecurityInfo
21 from Products.ZenModel.AdministrativeRole import AdministrativeRole
22 from Globals import InitializeClass
23 from ZenossSecurity import *
24 from Products.ZenWidgets import messaging
25
27
28 security = ClassSecurityInfo()
29
30 security.declareProtected(ZEN_ADMINISTRATORS_VIEW,
31 'getAdministrativeRoles')
33 "Get the Admin Roles on this device"
34 return self.adminRoles.objectValuesAll()
35
36 security.declareProtected(ZEN_ADMINISTRATORS_EDIT,
37 'manage_addAdministrativeRole')
50
51 security.declareProtected(ZEN_ADMINISTRATORS_EDIT,
52 'manage_editAdministrativeRoles')
72
73
74 security.declareProtected(ZEN_ADMINISTRATORS_EDIT,
75 'manage_deleteAdministrativeRole')
77 "Delete a admin role to this device"
78 if type(delids) in types.StringTypes:
79 delids = [delids]
80 for userid in delids:
81 ar = self.adminRoles._getOb(userid, None)
82 if ar is not None: ar.delete()
83 self.manage_delLocalRoles((userid,))
84 self.setAdminLocalRoles()
85 if REQUEST:
86 if delids:
87 messaging.IMessageSender(self).sendToBrowser(
88 'Admin Roles Deleted',
89 ('The following administrative roles have been deleted: '
90 '%s' % ", ".join(delids))
91 )
92 return self.callZenScreen(REQUEST)
93
95 """List the user and their roles on an object"""
96 return [ (ar.id, (ar.role,)) for ar in self.adminRoles() ]
97
98
100 """Hook for setting permissions"""
101 pass
102
103
104 InitializeClass(AdministrativeRoleable)
105