2be03aef455026761e0d305ed340d64ac0cccdce
[GroupUserFolder.git] / interfaces / portal_groups.py
1 # -*- coding: utf-8 -*-
2 ## GroupUserFolder
3 ## Copyright (C)2006 Ingeniweb
4
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.
9
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.
14
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.
18
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
23
24 Goes along the lines of portal_membership, but for groups.
25 """
26 __version__ = "$Revision: $"
27 # $Source: $
28 # $Id: portal_groups.py 30098 2006-09-08 12:35:01Z encolpe $
29 __docformat__ = 'restructuredtext'
30
31
32 from Interface import Attribute
33 try:
34 from Interface import Interface
35 except ImportError:
36 # for Zope versions before 2.6.0
37 from Interface import Base as Interface
38
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"')
43
44 def isGroup(u):
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()
47 """
48
49 def getGroupById(id):
50 """Returns the portal_groupdata-ish object for a group corresponding
51 to this id."""
52
53 def getGroupsByUserId(userid):
54 """Returns a list of the groups the user corresponding to 'userid' belongs to."""
55
56 def listGroups():
57 """Returns a list of the available portal_groupdata-ish objects."""
58
59 def listGroupIds():
60 """Returns a list of the available groups' ids (WITHOUT prefixes)."""
61
62 def listGroupNames():
63 """Returns a list of the available groups' names (ie. without prefixes)."""
64
65 ## def getPureUserNames():
66 ## """Get the usernames (ids) of only users. """
67
68 ## def getPureUsers():
69 ## """Get the actual (unwrapped) user objects of only users. """
70
71 def searchForGroups(REQUEST, **kw): # maybe searchGroups()?
72 """Return a list of groups meeting certain conditions. """
73 # arguments need to be better refined?
74
75 def addGroup(id, roles = [], groups = [], **kw):
76 """Create a group with the supplied id, roles, and groups.
77
78 Underlying user folder must support adding users via the usual Zope API.
79 Passwords for groups seem to be currently irrelevant in GRUF."""
80
81 def editGroup(id, roles = [], groups = [], **kw):
82 """Edit the given group with the supplied roles.
83
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."""
87
88 def removeGroups(ids, keep_workspaces=0):
89 """Remove the group in the provided list (if possible).
90
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."""
94
95 def setGroupOwnership(group, object):
96 """Make the object 'object' owned by group 'group' (a portal_groupdata-ish object)"""
97
98 def setGroupWorkspacesFolder(id=""):
99 """ Set the location of the Group Workspaces folder by id.
100
101 The Group Workspaces Folder contains all the group workspaces, just like the
102 Members folder contains all the member folders.
103
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. """
107
108 def getGroupWorkspacesFolderId():
109 """ Get the Group Workspaces folder object's id.
110
111 The Group Workspaces Folder contains all the group workspaces, just like the
112 Members folder contains all the member folders. """
113
114 def getGroupWorkspacesFolder():
115 """ Get the Group Workspaces folder object.
116
117 The Group Workspaces Folder contains all the group workspaces, just like the
118 Members folder contains all the member folders. """
119
120 def toggleGroupWorkspacesCreation():
121 """ Toggles the flag for creation of a GroupWorkspaces folder upon first
122 use of the group. """
123
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). """
127
128 def getGroupWorkspaceType():
129 """Return the Type (as in TypesTool) to make the GroupWorkspace."""
130
131 def setGroupWorkspaceType(type):
132 """Set the Type (as in TypesTool) to make the GroupWorkspace. Expects the name of a Type."""
133
134 def createGrouparea(id):
135 """Create a space in the portal for the given group, much like member home
136 folders."""
137
138 def getGroupareaFolder(id):
139 """Returns the object of the group's work area."""
140
141 def getGroupareaURL(id):
142 """Returns the full URL to the group's work area."""
143
144 # and various roles things...