Groups
A group is a permission group that can be used when you setup permissions for other modules, such as Litium Studio Media Archive or Litium Studio Web Publishing. A group will have its own field template, so it is possible for the editor to specify group information.
A group created inside Litium Studio Relations can also be found under the Control panel.
Namespace: Litium.Foundation.Modules.Relations.Groups
Group object contains all information about a group. All the groups can be reached by the Group collection of a Relations module instance.
Get a specific Group object
Group group = ModuleRelations.Instance.Groups[groupID];
Core functionality of the Group object
Collections of the Group object
Group object has two collections:
group.CustomFields
Custom field collection contains all the custom fields of the group object.
Example
Get names and values of all the custom fields of type string. Create a custom string field with name “Test” (assuming that the field template has a field definition for the field “Test”), if it does not exist and set its value to “Test value”. To create only fields that the template (group.FieldTemplate) of the group contains a field definition for is recommended since only those fields are handled by the web controls and administration pages in the Relations module.
List<string> groupFields = new List<string>();
Litium.Foundation.Modules.Relations.Fields.StringField testField = group.CustomFields.GetField("Test") as Litium.Foundation.Modules.Relations.Fields.StringField;
if (testField == null)
{
Litium.Foundation.Modules.Relations.FieldTemplates.FieldTemplateField testTemplateField = group.FieldTemplate.FieldDefinitions.GetFieldDefinition("Test");
if (testField != null && testField.FieldDefinition is Litium.Foundation.Modules.Relations.FieldDefinitions.StringFieldDefinition)
testField = group.CustomFields.CreateStringField(testTemplateField.FieldDefinition as Litium.Foundation.Modules.Relations.FieldDefinitions.StringFieldDefinition, FoundationContext.Token);
}
if (testField != null)
testField.SetValue("Test value", FoundationContext.Token);
foreach (Litium.Foundation.Modules.Relations.Fields.Field field in group.CustomFields)
{
if (field is Litium.Foundation.Modules.Relations.Fields.StringField)
{
Litium.Foundation.Modules.Relations.Fields.StringField stringField = field as Litium.Foundation.Modules.Relations.Fields.StringField;
groupFields.Add(stringField.Name + ": " + stringField.Value);
}
}
group.Members
Member collection contains all the persons that belong to the group.
Example
Get names of all the persons that belong to the group.
List<string> groupMembers = new List<string>();
foreach (Litium.Foundation.Modules.Relations.Persons.Person currentPerson in group.Members)
groupMembers.Add(currentPerson.FirstName + " " + currentPerson.LastName);
FoundationGroup
Returns the Foundation group that was automatically created in the Foundation when the group was created. See "Permissions" for more information about the relation between FoundationGroup and permissions.
CompareTo(Group other)
Method to compare two Group objects, overrides the base class method. The comparison is based on the group name.