예제 #1
0
파일: GRUFUser.py 프로젝트: dtgit/dtedu
    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
예제 #2
0
    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
예제 #3
0
 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)
예제 #4
0
파일: GRUFUser.py 프로젝트: dtgit/dtedu
 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)
예제 #5
0
    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
예제 #6
0
파일: GRUFUser.py 프로젝트: dtgit/dtedu
    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