1 # -*- coding: utf-8 -*-
3 ## Copyright (C)2006 Ingeniweb
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2 of the License, or
8 ## (at your option) any later version.
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; see the file COPYING. If not, write to the
17 ## Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ## Copyright (c) 2003 The Connexions Project, All Rights Reserved
20 ## initially written by J Cameron Cooper, 11 June 2003
21 ## concept with Brent Hendricks, George Runyan
22 """Groups tool interface
24 Goes along the lines of portal_membership, but for groups.
26 __version__
= "$Revision: $"
28 # $Id: portal_groups.py 30098 2006-09-08 12:35:01Z encolpe $
29 __docformat__
= 'restructuredtext'
32 from Interface
import Attribute
34 from Interface
import Interface
36 # for Zope versions before 2.6.0
37 from Interface
import Base
as Interface
39 class portal_groups(Interface
):
40 """Defines an interface for working with groups in an abstract manner.
41 Parallels the portal_membership interface of CMFCore"""
42 ## id = Attribute('id','Must be set to "portal_groups"')
45 """Test if a user/group object is a group or not.
46 You must pass an object you get earlier with wrapUser() or wrapGroup()
50 """Returns the portal_groupdata-ish object for a group corresponding
53 def getGroupsByUserId(userid
):
54 """Returns a list of the groups the user corresponding to 'userid' belongs to."""
57 """Returns a list of the available portal_groupdata-ish objects."""
60 """Returns a list of the available groups' ids (WITHOUT prefixes)."""
63 """Returns a list of the available groups' names (ie. without prefixes)."""
65 ## def getPureUserNames():
66 ## """Get the usernames (ids) of only users. """
68 ## def getPureUsers():
69 ## """Get the actual (unwrapped) user objects of only users. """
71 def searchForGroups(REQUEST
, **kw
): # maybe searchGroups()?
72 """Return a list of groups meeting certain conditions. """
73 # arguments need to be better refined?
75 def addGroup(id, roles
= [], groups
= [], **kw
):
76 """Create a group with the supplied id, roles, and groups.
78 Underlying user folder must support adding users via the usual Zope API.
79 Passwords for groups seem to be currently irrelevant in GRUF."""
81 def editGroup(id, roles
= [], groups
= [], **kw
):
82 """Edit the given group with the supplied roles.
84 Underlying user folder must support editing users via the usual Zope API.
85 Passwords for groups seem to be currently irrelevant in GRUF.
86 One can supply additional named parameters to set group properties."""
88 def removeGroups(ids
, keep_workspaces
=0):
89 """Remove the group in the provided list (if possible).
91 Will by default remove this group's GroupWorkspace if it exists. You may
92 turn this off by specifying keep_workspaces=true.
93 Underlying user folder must support removing users via the usual Zope API."""
95 def setGroupOwnership(group
, object):
96 """Make the object 'object' owned by group 'group' (a portal_groupdata-ish object)"""
98 def setGroupWorkspacesFolder(id=""):
99 """ Set the location of the Group Workspaces folder by id.
101 The Group Workspaces Folder contains all the group workspaces, just like the
102 Members folder contains all the member folders.
104 If anyone really cares, we can probably make the id work as a path as well,
105 but for the moment it's only an id for a folder in the portal root, just like the
106 corresponding MembershipTool functionality. """
108 def getGroupWorkspacesFolderId():
109 """ Get the Group Workspaces folder object's id.
111 The Group Workspaces Folder contains all the group workspaces, just like the
112 Members folder contains all the member folders. """
114 def getGroupWorkspacesFolder():
115 """ Get the Group Workspaces folder object.
117 The Group Workspaces Folder contains all the group workspaces, just like the
118 Members folder contains all the member folders. """
120 def toggleGroupWorkspacesCreation():
121 """ Toggles the flag for creation of a GroupWorkspaces folder upon first
122 use of the group. """
124 def getGroupWorkspacesCreationFlag():
125 """Return the (boolean) flag indicating whether the Groups Tool will create a group workspace
126 upon the next use of the group (if one doesn't exist). """
128 def getGroupWorkspaceType():
129 """Return the Type (as in TypesTool) to make the GroupWorkspace."""
131 def setGroupWorkspaceType(type):
132 """Set the Type (as in TypesTool) to make the GroupWorkspace. Expects the name of a Type."""
134 def createGrouparea(id):
135 """Create a space in the portal for the given group, much like member home
138 def getGroupareaFolder(id):
139 """Returns the object of the group's work area."""
141 def getGroupareaURL(id):
142 """Returns the full URL to the group's work area."""
144 # and various roles things...