def getRoles(self): """ Return the list (tuple) of roles assigned to a user. THIS IS WHERE THE ATHENIANS REACHED ! """ if self._all_roles is not None: return self._all_roles # Return user and groups roles self._all_roles = GroupUserFolder.unique(self.getUserRoles() + self.getGroupRoles()) return self._all_roles
def addMember(self, userid): """Add a user the the current group""" gruf = self.aq_parent groupid = self.getId() usr = gruf.getUser(userid) if not usr: raise ValueError, "Invalid user: '******'" % (userid, ) if not groupid in gruf.getGroupNames() + gruf.getGroupIds(): raise ValueError, "Invalid group: '%s'" % (groupid, ) groups = list(usr.getGroups()) groups.append(groupid) groups = GroupUserFolder.unique(groups) return gruf._updateUser(userid, groups=groups)
def addMember(self, userid): """Add a user the the current group""" gruf = self.aq_parent groupid = self.getId() usr = gruf.getUser(userid) if not usr: raise ValueError, "Invalid user: '******'" % (userid,) if not groupid in gruf.getGroupNames() + gruf.getGroupIds(): raise ValueError, "Invalid group: '%s'" % (groupid,) groups = list(usr.getGroups()) groups.append(groupid) groups = GroupUserFolder.unique(groups) return gruf._updateUser(userid, groups=groups)
def getGroupRoles(self, ): """ Return the tuple of roles belonging to this user's group(s) """ if self._group_roles is not None: return self._group_roles ret = [] acl_users = self._GRUF.acl_users groups = acl_users.getGroupIds() # XXX We can have a cache here for group in self.getGroups(): if not group in groups: Log("Group", group, "is invalid. Ignoring.") # This may occur when groups are deleted # Ignored silently continue ret.extend(acl_users.getGroup(group).getUserRoles()) self._group_roles = GroupUserFolder.unique(ret) return self._group_roles
def getGroupRoles(self,): """ Return the tuple of roles belonging to this user's group(s) """ if self._group_roles is not None: return self._group_roles ret = [] acl_users = self._GRUF.acl_users groups = acl_users.getGroupIds() # XXX We can have a cache here for group in self.getGroups(): if not group in groups: Log("Group", group, "is invalid. Ignoring.") # This may occur when groups are deleted # Ignored silently continue ret.extend(acl_users.getGroup(group).getUserRoles()) self._group_roles = GroupUserFolder.unique(ret) return self._group_roles