Toggle menu
862
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

GroupBuilderGroupVariable class: Difference between revisions

From Catglobe Wiki
Nguyenduyan (talk | contribs)
No edit summary
Nguyenduyan (talk | contribs)
No edit summary
Line 26: Line 26:
=== <span style="color:#DF8621">'''Examples'''</span> ===
=== <span style="color:#DF8621">'''Examples'''</span> ===


'''Example: Add group variable''' <source lang="javascript">
'''Example: Add group variable'''  
<source lang="javascript">
//Create a new group
//Create a new group
string groupName = "Test Group Builder: groupVariable";
string groupName = "Test Group Builder: groupVariable";
Line 52: Line 53:
//Rebuild group
//Rebuild group
Group_rebuildGroup(groupRId,true);
Group_rebuildGroup(groupRId,true);
</source><br/>'''Example: Remove group variable''' <source lang="javascript">
</source>
<br/>
'''Example: Remove group variable'''  
<source lang="javascript">
number groupRId = 15560550;
number groupRId = 15560550;


Line 60: Line 64:
GroupBuilderRule rule = ruleColection[0];
GroupBuilderRule rule = ruleColection[0];
GroupBuilderGroupVariable groupVariable = rule[0];
GroupBuilderGroupVariable groupVariable = rule[0];
print(groupVariable.Count);
groupVariable.Remove(15085949);
groupVariable.Remove(15085949);


root.Save();
root.Save();
</source>
</source>

Revision as of 04:56, 30 March 2017

GroupBuilderGroupVariable



Represents a group builder variable for group membership.

Constructors

  • (bool include "Include users, or if false exclude users") - Create new variable

Methods

  • Empty Add(int groupResourceId "Group resource id to add") - Add a new group
  • int this[] { get; }(int index "Index") - Get group resource id at index
  • bool Remove(int groupResourceId "Group resource id to remove") - Remove group. Return true if removed
  • string ToString() - The string representation of the object.

Properties

  • int Count { get; } - Number of groups
  • bool Include { get; } - Include users that match rule, or exclude
  • string ObjectTypeName { get; } - The name of the type of object.
  • TypeInformation TypeInformation { get; } - Get information about this class.


Examples

Example: Add group variable

//Create a new group
string groupName = "Test Group Builder: groupVariable";
number groupTemplateResourceId=2066;
number parentResourceId = 11088827;
array group = Group_new(groupName, groupTemplateResourceId, parentResourceId);
Group_save(group);
number groupRId = group[GROUP_RESOURCE_ID ];

//Create rule for the group
GroupBuilderRoot root = new GroupBuilderRoot (groupRId);

GroupBuilderGroupVariable groupVariable = new GroupBuilderGroupVariable (true);//true: include; false: exclude
groupVariable.Add(15547043);// 15547043: resourceId of group want to add to
groupVariable.Add(15085949);// 15085949: resourceId of group want to add to 

GroupBuilderRule rule = new GroupBuilderRule (root);
rule.Add(groupVariable);

GroupBuilderRuleCollection ruleColection = root.RootRules;
ruleColection.Add(rule);

root.Save();

//Rebuild group
Group_rebuildGroup(groupRId,true);


Example: Remove group variable

number groupRId = 15560550;

GroupBuilderRoot root = new GroupBuilderRoot (groupRId);

GroupBuilderRuleCollection ruleColection = root.RootRules;
GroupBuilderRule rule = ruleColection[0];
GroupBuilderGroupVariable groupVariable = rule[0];
print(groupVariable.Count);
groupVariable.Remove(15085949);

root.Save();