Group Bean - Mura Docs v7.0

Group Bean

The group bean/object includes group-specific data, and includes a number of helper methods. For example, you can obtain an iterator of the users who belong to the group, etc.

Note: The group bean/object merely uses the user bean/object. However, it contains only group-specific information, and group-specific helper methods. 

Syntax

The following examples illustrate how to "get" and/or "set" various attributes of the group bean/object. Use whichever syntax feels best to you.

Loading the Bean

You can load a group bean/object by any of the following attributes:

  • groupid
  • groupname
  • remoteid
<cfset groupBean = m.getBean('group').loadBy(groupname='admin')>

Note: As mentioned in the previous note above, the group bean/object leverages the user bean/object. The type attribute will be 1 if a group, and 2 if a user.

The group bean/object's loadBy method allows for an optional second argument, labeled siteid. This is necessary when working with a group assigned to a different siteid than the site you are currently working with. For example, if you are working on "Site B" and your group was created under the "default" site, then you would have to load the user similar to the example below.

<cfset groupBean = m.getBean('group').loadBy(groupname='admin', siteid='default')>

Once you have a variable to reference the desired bean/object, you can use the example Getters and Setters below.

Getters

groupBean.get('attributeName')
groupBean.get{AttributeName}()
groupBean.getValue('attributeName')

Setters

groupBean.set('attributeName', 'someValue')
groupBean.set{AttributeName}('someValue')
groupBean.setValue('attributeName', 'someValue')

Usage

Use the group bean/object to access and/or manipulate a Mura group.

Attributes

The table below lists available attributes.

Attribute Description
created Date/time the user was created.
email The groups's email address.
groupid The GroupID is a unique identifier for the group.
groupname The name of the group.
inactive Whether the group is inactive.
isnew Whether the group bean is new.
ispublic Whether the group is a Member Group (1) or System Group (0).
lastupdate Date/time the group was last updated.
lastupdateby Name of the user who last updated the user.
lastupdatebyid UserID of the user who last updated the user.
remoteid A special field for developer's to use. May load the group by this field. It does not have to be unique. Typically, used to store a unique identifier to associate the group to an external data store.
siteid SiteID the group belongs to.
subtype The group's subtype.
tablist A comma-delimited list of content editing tabs the group has access to.
type Whether the user is a group (1) or user (2).

Helper Methods

When working with groups, the following group bean/object's helper methods may be quite useful.

getMembersIterator()

Returns an iterator of the users who belong to the group.

<cfset it = groupBean.getMembersIterator()>
<h3>Group Members</h3>
<!--- Loop over the iterator --->
<cfif it.hasNext()>
<ul>
<cfloop condition="it.hasNext()">
<cfset user = it.next()>
  <li>
#esapiEncode('html', user.getFullName())#
  </li>
  </cfloop>
  </ul>
<cfelse>
  <p>Group does not have any members.</p>
</cfif>

getMembersQuery()

Returns a recordset of the users who belong to the group.

<cfset rsMembers = groupBean.getMembersQuery()>