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
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{CGscriptClass_Template
{{CGscriptClass_Template
|Name=GroupBuilderGroupVariable
|Name=<nowiki>GroupBuilderGroupVariable</nowiki>
|Description=Represents a group builder variable for group membership.
|Description=<nowiki>Represents a group builder variable for group membership.</nowiki>
|Constructors=
|InheritsFrom=GroupBuilderVariable|Constructors=
{{CGscriptConstructors_Template|Parameters=
{{CGscriptConstructors_Template|Parameters=
{{CGscriptParameters_Template|Type=bool|Name=include|Description=Include users, or if false exclude users}}
{{CGscriptParameters_Template|Type=bool|Name=<nowiki>include</nowiki>|Description=<nowiki>Include users, or if false exclude users</nowiki>}}
|Description=Create new variable}}
|Description=<nowiki>Create new variable</nowiki>}}
|Methods=
|Methods=
{{CGscriptMethods_Template|ReturnType=Empty|Name=Add|Parameters=
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Add</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=int|Name=groupResourceId|Description=Group resource id to add}}
{{CGscriptParameters_Template|Type=int|Name=<nowiki>groupResourceId</nowiki>|Description=<nowiki>Group resource id to add</nowiki>}}
|Description=Add a new group}}
|Description=<nowiki>Add a new group</nowiki>}}
{{CGscriptMethods_Template|ReturnType=int|Name=this[] { get; }|Parameters=
{{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>this[] { get; }</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=int|Name=index|Description=Index}}
{{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>}}
|Description=Get group resource id at index}}
|Description=<nowiki>Get group resource id at index</nowiki>}}
{{CGscriptMethods_Template|ReturnType=bool|Name=Remove|Parameters=
{{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Remove</nowiki>|Parameters=
{{CGscriptParameters_Template|Type=int|Name=groupResourceId|Description=Group resource id to remove}}
{{CGscriptParameters_Template|Type=int|Name=<nowiki>groupResourceId</nowiki>|Description=<nowiki>Group resource id to remove</nowiki>}}
|Description=Remove group. Return true if removed}}
|Description=<nowiki>Remove group. Return true if removed</nowiki>}}
{{CGscriptMethods_Template|ReturnType=string|Name=ToString|Description=The string representation of the object.}}
{{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=object|Description=<nowiki>The string representation of the object.</nowiki>}}
|Properties=
|Properties=
{{CGscriptProperties_Template|ReturnType=int|Name=Count|HasGetter=1|Description=Number of groups}}
{{CGscriptProperties_Template|ReturnType=int|Name=<nowiki>Count</nowiki>|HasGetter=1|Description=<nowiki>Number of groups</nowiki>}}
{{CGscriptProperties_Template|ReturnType=bool|Name=Include|HasGetter=1|Description=Include users that match rule, or exclude}}
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Include</nowiki>|HasGetter=1|Description=<nowiki>Include users that match rule, or exclude</nowiki>}}
{{CGscriptProperties_Template|ReturnType=string|Name=ObjectTypeName|HasGetter=1|Description=The name of the type of object.}}
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=TypeInformation|HasGetter=1|Description=Get information about this class.}}
{{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}}
}}
}}


=== <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>

Latest revision as of 07:26, 2 July 2020

GroupBuilderGroupVariable


Represents a group builder variable for group membership.

Parent class

Inherits from GroupBuilderVariable

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
  • object 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
  • (From object) 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.
  • (From 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();