Пример #1
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id. None if group does not exist here!
        """
        group_id = decode_utf8(group_id)
        groups = self.groups
        if not groups or group_id not in groups.keys():
            return None
        ugmgroup = self.groups[group_id]
        title = ugmgroup.attrs.get("title", None)
        group = PloneGroup(ugmgroup.id, title).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins
        # add properties
        for propfinder_id, propfinder in plugins.listPlugins(pas_interfaces.IPropertiesPlugin):

            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, data)
        # add subgroups
        group._addGroups(pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        for rolemaker_id, rolemaker in plugins.listPlugins(pas_interfaces.IRolesPlugin):

            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
Пример #2
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)
            plugins = self._getPAS()._getOb('plugins')
            propfinders = plugins.listPlugins(IPropertiesPlugin)
            for propfinder_id, propfinder in propfinders:

                data = propfinder.getPropertiesForUser(group, request=None)
                if data:
                    group.addPropertysheet(propfinder_id, data)

            groups = self._getPAS()._getGroupsForPrincipal(
                group, request=None, plugins=plugins)
            group._addGroups(groups)

            rolemakers = plugins.listPlugins(IRolesPlugin)

            for rolemaker_id, rolemaker in rolemakers:
                roles = rolemaker.getRolesForPrincipal(group, request=None)
                if roles:
                    group._addRoles(roles)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None
Пример #3
0
    def _get_group_by_info(self, info):
        if info is None:
            return None
        group = PloneGroup(info['id'], info['id']).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins

        # add properties
        # 1.) shortcut to own properties
        data = self._get_propertysheet_of_info(info)
        group.addPropertysheet(self.getId(), data)

        properties_provider = plugins.listPlugins(
            pas_interfaces.IPropertiesPlugin)

        # 2.) other possible plugins
        for propfinder_id, propfinder in properties_provider:
            if propfinder_id == self.getId():
                continue
            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, data)

        # add subgroups
        group._addGroups(
            pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        role_provider = plugins.listPlugins(pas_interfaces.IRolesPlugin)
        for rolemaker_id, rolemaker in role_provider:
            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
Пример #4
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)
            plugins = self._getPAS()._getOb('plugins')
            propfinders = plugins.listPlugins(IPropertiesPlugin)
            for propfinder_id, propfinder in propfinders:

                data = propfinder.getPropertiesForUser(group, request=None)
                if data:
                    group.addPropertysheet(propfinder_id, data)

            groups = self._getPAS()._getGroupsForPrincipal(group,
                                                           request=None,
                                                           plugins=plugins)
            group._addGroups(groups)

            rolemakers = plugins.listPlugins(IRolesPlugin)

            for rolemaker_id, rolemaker in rolemakers:
                roles = rolemaker.getRolesForPrincipal(group, request=None)
                if roles:
                    group._addRoles(roles)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None
Пример #5
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id. None if group does not exist here!
        """
        groups = self.groups
        if not groups or group_id not in self.getGroupIds():
            return None
        ugmgroup = self.groups[group_id]
        title = ugmgroup.attrs.get('title', None)
        group = PloneGroup(ugmgroup.id, title).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins
        # add properties
        for propfinder_id, propfinder in \
                plugins.listPlugins(pas_interfaces.IPropertiesPlugin):

            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, decode(data))
        # add subgroups
        group._addGroups(
            pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        for rolemaker_id, rolemaker in \
                plugins.listPlugins(pas_interfaces.IRolesPlugin):

            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
    def getGroupById(self, groupid, default=None):

        group = PloneGroup(groupid)
        group = group.__of__(self)
        
        # add UserPropertySheet with title
        # We assume the title is the same as the id
        data = {'title': groupid}
        group.addPropertysheet(self.getId(), data)

        return group
Пример #7
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id. None if group does not exist here!
        """
        default = None
        if not self.is_plugin_active(
                plonepas_interfaces.group.IGroupIntrospection):
            return default
        if group_id is None:
            return None
        if not isinstance(group_id, six.text_type):
            group_id = group_id.decode("utf8")
        groups = self.groups
        if not groups or group_id not in list(groups.keys()):
            return default
        ugmgroup = self.groups[group_id]
        title = ugmgroup.attrs.get("title", None)
        group = PloneGroup(ugmgroup.id, title).__of__(self)
        pas = self._getPAS()
        plugins = pas.plugins
        # add properties
        for propfinder_id, propfinder in plugins.listPlugins(
                pas_interfaces.IPropertiesPlugin):

            data = propfinder.getPropertiesForUser(group, None)
            if not data:
                continue
            group.addPropertysheet(propfinder_id, data)
        # add subgroups
        group._addGroups(
            pas._getGroupsForPrincipal(group, None, plugins=plugins))
        # add roles
        for rolemaker_id, rolemaker in plugins.listPlugins(
                pas_interfaces.IRolesPlugin):

            roles = rolemaker.getRolesForPrincipal(group, None)
            if not roles:
                continue
            group._addRoles(roles)
        return group
Пример #8
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)

            for name, data in self._get_properties_for_user_from_pas(group):
                group.addPropertysheet(name, data)

            for roles in self._get_roles_for_principal_from_pas(group):
                group._addRoles(roles)

            for groups in self._get_groups_for_principal_from_pas(group):
                group._addGroups(groups)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None
Пример #9
0
    def getGroupById(self, group_id):
        """
        Returns the portal_groupdata-ish object for a group
        corresponding to this id.
        """

        if group_id and self.enumerateGroups(group_id):
            group = PloneGroup(group_id, None)

            for name, data in self._get_properties_for_user_from_pas(group):
                group.addPropertysheet(name, data)

            for roles in self._get_roles_for_principal_from_pas(group):
                group._addRoles(roles)

            for groups in self._get_groups_for_principal_from_pas(group):
                group._addGroups(groups)

            group._addRoles(['Authenticated'])

            return group.__of__(self)
        else:
            return None