- Publicity: Public Only All
group-procs.tcl
Procs to manage groups
- Location:
- packages/acs-subsite/tcl/group-procs.tcl
- Created:
- Thu Dec 7 18:13:56 2000
- Author:
- mbryzek@arsdigita.com
- CVS Identification:
$Id: group-procs.tcl,v 1.60.2.18 2024/08/07 15:36:22 mischa Exp $
Procedures in this file
- group::add_member (public)
- group::admin_p (public)
- group::default_member_state (public)
- group::delete (public)
- group::description (public)
- group::get (public)
- group::get_element (public)
- group::get_id (public)
- group::get_join_policy_options (public)
- group::get_member_state_pretty (public)
- group::get_members (public)
- group::get_rel_segment (public)
- group::get_rel_types_options (public)
- group::join_policy (public)
- group::member_p (public)
- group::new (public)
- group::party_member_p (public)
- group::permission_p (public, deprecated)
- group::possible_member_states (public)
- group::remove_member (public)
- group::title (public)
- group::update (public)
Detailed information
group::add_member (public)
group::add_member [ -no_perm_check ] [ -no_automatic_membership_rel ] \ -group_id group_id -user_id user_id [ -rel_type rel_type ] \ [ -member_state member_state ]
Adds a user to a group, checking that the rel_type is permissible given the user's privileges, Can default both the rel_type and the member_state to their relevant values.
- Switches:
- -no_perm_check (optional, boolean)
- avoid permission check
- -no_automatic_membership_rel (optional, boolean)
- Use this flag, when we do not want to add automatically a membership_rel (e.g. in DotLRN)
- -group_id (required)
- group, to which a member should be added
- -user_id (required)
- user, which should be added to a group
- -rel_type (optional)
- relationship type to be used (defaults to membership_rel)
- -member_state (optional)
- state, in which member should be added (gets default via group::default_member_state)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_expose_bug_1144, acs_subsite_check_composite_group, subsite_api, test_inheritance_and_custom_permissions
group::admin_p (public)
group::admin_p -group_id group_id -user_id user_id
- Switches:
- -group_id (required)
- -user_id (required)
- Returns:
- 1 if user_id is in the admin_rel for group_id
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_check_composite_group
group::default_member_state (public)
group::default_member_state [ -join_policy join_policy ] \ [ -create_p create_p ] [ -no_complain ]
If user has 'create' privilege on group_id OR the group's join policy is 'open', then default_member_state will return "approved". If the group's join policy is 'needs approval' then default_member_state will return 'needs approval'. If the group's join policy is closed then an error will be thrown, unless the no_complain flag is set, in which case empty string is returned.
- Switches:
- -join_policy (optional)
- - the group's join policy (one of 'open', 'closed', or 'needs approval')
- -create_p (optional, defaults to
"false"
)- - 1 if the user has 'create' privilege on the group, 0 otherwise.
- -no_complain (optional, boolean)
- Author:
- Oumi Mehrotra <oumi@arsdigita.com>
- Created:
- 10/2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
group::delete (public)
group::delete group_id
Deletes the group specified by group_id, including all relational segments specified for the group and any relational constraint that depends on this group in any way.
- Parameters:
- group_id (required)
- The group to delete
- Returns:
object_type
of the deleted group, if it was actually deleted. Returns the empty string if the object didn't exist to begin with- Author:
- Michael Bryzek <mbryzek@arsdigita.com>
- Created:
- 10/2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- group_localization, acs_subsite_expose_bug_775
group::description (public)
group::description -group_id group_id
Returns a group's description
- Switches:
- -group_id (required)
- Created:
- 09/2008
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_group_type
group::get (public)
group::get -group_id group_id [ -array array ]
Get basic info about a group: group_name, join_policy.
- Switches:
- -group_id (required)
- -array (optional)
- The name of an array in the caller's namespace where the info gets delivered.
- Returns:
- dict containing group_name, title, join_policy, and description
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_group_type
group::get_element (public)
group::get_element -group_id group_id -element element
Get an element from the basic info about a group: group_name, join_policy.
- Switches:
- -group_id (required)
- -element (required)
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- subsite_api
group::get_id (public)
group::get_id -group_name group_name [ -subsite_id subsite_id ] \ [ -application_group_id application_group_id ]
Retrieve the group_id to a given group-name. If you have more than one group with this name, it will return the first one it finds. Keep that in mind when using this procedure.
- Switches:
- -group_name (required)
- the name of the group to look for
- -subsite_id (optional)
- the ID of the subsite to search for the group name
- -application_group_id (optional)
- the ID of the application group to search for the group name
- Returns:
- the first group_id of the groups found for that group_name.
- Authors:
- Christian Langmann <C_Langmann@gmx.de>
- Malte Sussdorff <openacs@sussdorff.de>
- Created:
- 2005-06-09
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_group_type
group::get_join_policy_options (public)
group::get_join_policy_options
Returns a list of valid join policies in a format suitable for a form builder drop-down.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- subsite_api
group::get_member_state_pretty (public)
group::get_member_state_pretty -member_state member_state \ [ -component component ] [ -user_name user_name ] \ [ -community_name community_name ] [ -site_name site_name ] \ [ -url url ] [ -locale locale ]
Returns the pretty-name of a member state.
- Switches:
- -member_state (required)
- -component (optional, defaults to
"pretty_name"
)- -user_name (optional)
- -community_name (optional)
- -site_name (optional)
- -url (optional)
- -locale (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
group::get_members (public)
group::get_members -group_id group_id [ -type type ] \ [ -rel_type rel_type ] [ -member_state member_state ]
Get party_ids of all members from cache.
- Switches:
- -group_id (required)
- -type (optional, defaults to
"party"
)- Type of members - party, person, user
- -rel_type (optional)
- -member_state (optional)
- when specified, return only members in this membership state
- Author:
- Timo Hentschel <timo@timohentschel.de>
- Created:
- 2005-07-26
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- subsite_api
group::get_rel_segment (public)
group::get_rel_segment -group_id group_id -type type
Get a segment for a particular relation type for a given group.
- Switches:
- -group_id (required)
- -type (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_rel_segment_new, test_inheritance_and_custom_permissions
group::get_rel_types_options (public)
group::get_rel_types_options -group_id group_id \ [ -object_type object_type ]
Get the valid relationship-types for this group in a format suitable for a select widget in the form builder. The label used is the name of the role for object two.
- Switches:
- -group_id (required)
- The ID of the group for which to get options.
- -object_type (optional, defaults to
"person"
)- The object type which must occupy side two of the relationship. Typically 'person' or 'group'.
- Returns:
- a list of lists with label (role two pretty name) and ID (rel_type)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
group::join_policy (public)
group::join_policy -group_id group_id
Returns a group's join policy ('open', 'closed', or 'needs approval')
- Switches:
- -group_id (required)
- Author:
- Oumi Mehrotra <oumi@arsdigita.com>
- Created:
- 10/2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- subsite_api
group::member_p (public)
group::member_p [ -user_id user_id ] [ -group_name group_name ] \ [ -group_id group_id ] [ -subsite_id subsite_id ] [ -cascade ]
Return 1 if the user is a member of the group specified. You can specify a group name or group id. If there is more than one group with this name, it will use the first one. If cascade is true, check to see if the user is a member of the group by virtue of any other component group. (e.g. if group B is a component of group A then if a user is a member of group B then he is automatically a member of A also.) If cascade is false, then the user must have specifically been granted membership on the group in question.
- Switches:
- -user_id (optional)
- -group_name (optional)
- -group_id (optional)
- -subsite_id (optional)
- Only useful when using group_name. Marks the subsite in which to search for the group_id that belongs to the group_name
- -cascade (optional, boolean)
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_check_composite_group
group::new (public)
group::new [ -form_id form_id ] [ -variable_prefix variable_prefix ] \ [ -creation_user creation_user ] [ -creation_ip creation_ip ] \ [ -group_id group_id ] [ -context_id context_id ] \ [ -group_name group_name ] [ -pretty_name pretty_name ] \ [ group_type ]
Creates a group of this type by calling the .new function for the package associated with the given group_type. This function will fail if there is no package.
There are now several ways to create a group of a given type. You can use this Tcl API with or without a form from the form system, or you can directly use the PL/SQL API for the group type.
Examples:
# OPTION 1: Create the group using the Tcl Procedure. Useful if the # only attribute you need to specify is the group name db_transaction { set group_id [group::new -group_name "Author" $group_type] } # OPTION 2: Create the group using the Tcl API with a templating # form. Useful when there are multiple attributes to specify for the # group template::form create add_group template::element create add_group group_name -value "Publisher" db_transaction { set group_id [group::new -form_id add_group $group_type ] } # OPTION 3: Create the group using the PL/SQL package automatically # created for it # creating the new group set group_id [db_exec_plsql add_group " begin :1 := ${group_type}.new (group_name => 'Editor'); end; "]
- Switches:
- -form_id (optional)
- The form id from templating form system (see example above)
- -variable_prefix (optional)
- -creation_user (optional)
- -creation_ip (optional)
- -group_id (optional)
- -context_id (optional)
- -group_name (optional)
- The name of this group. This is a required variable, though it may be specified either explicitly or through
form_id
- -pretty_name (optional)
- Parameters:
- group_type (optional, defaults to
"group"
)- The type of group we are creating. Defaults to group which is what you want in most cases.
- Returns:
group_id
of the newly created group- Author:
- Michael Bryzek <mbryzek@arsdigita.com>
- Created:
- 10/2000
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- group_localization, acs_subsite_expose_bug_775, acs_subsite_check_composite_group, acs_subsite_group_type, acs_subsite_rel_segment_new
group::party_member_p (public)
group::party_member_p [ -party_id party_id ] [ -group_id group_id ] \ [ -group_name group_name ] [ -subsite_id subsite_id ]
Return 1 if the party is an approved member of the group specified. One can specify a group_id (preferred) or a group name. Note: The group name is not unique by definition, and if you call this function with a duplicate group name it will return the first one (arbitrary)!!! Using the group name as a parameter is thus strongly discouraged unless you are really, really sure the name is unique.
The party must have specifically been granted membership on the group in question.
- Switches:
- -party_id (optional)
- -group_id (optional)
- -group_name (optional)
- -subsite_id (optional)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- subsite_api
group::permission_p (public, deprecated)
group::permission_p [ -user_id user_id ] [ -privilege privilege ] \ group_id
Deprecated. Invoking this procedure generates a warning.
THIS PROC SHOULD GO AWAY! All calls to group::permission_p can be replaced with permission::permission_p Wrapper for ad_permission to allow us to bypass having to specify the read privilege
- Switches:
- -user_id (optional)
- -privilege (optional, defaults to
"read"
)- Parameters:
- group_id (required)
- Author:
- Michael Bryzek <mbryzek@arsdigita.com>
- Created:
- 10/2000
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
group::possible_member_states (public)
group::possible_member_states
Returns the list of possible member states: approved, needs approval, banned, merged, rejected, deleted.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
group::remove_member (public)
group::remove_member -group_id group_id -user_id user_id
Removes a user from a group. No permission checking.
- Switches:
- -group_id (required)
- -user_id (required)
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- subsite_api
group::title (public)
group::title [ -group_name group_name ] [ -group_id group_id ]
Get the title of a group based either on group_name or on the group_id.
- Switches:
- -group_name (optional)
- The name of the group. Note this is not the I18N title we want to retrieve with this procedure
- -group_id (optional)
- The group_id of the group
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- acs_subsite_group_type
group::update (public)
group::update -group_id group_id [ -array array ] [ dict ]
Updates a group.The updated values can be either specified as dict or as array. Valid columns are group_name, join_policy and description. Valid join_policy values are 'open', 'closed', 'needs approval'.
- Switches:
- -group_id (required)
- The ID of the group to update.
- -array (optional)
- Name of array containing the columns to update.
- Parameters:
- dict (optional)
- dict for columns to update.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.