Function to check if a user exists in a specified group.
function mIsUserInGroup(iUIN: integer; sGroupName: string): boolean;
Parameter |
Type |
Value |
---|---|---|
iUIN |
integer |
user numeric ID; |
sGroupName |
string |
user's group name. The letter case is important. |
True — user in the group, false — group with such name does not exist or the user is not in the group.
const
USER_UIN = 6;
GROUPS_LIST = 'Administrators,Moderators,Others';
var
sData, sName, s, sUserName: string;
begin
sData := GROUPS_LIST;
sUserName := mGetUserAttribute(USER_UIN, 'DisplayName');
mLogScript('User "' + sUserName + '" is on the group list?', '');
while length(sData) > 0 do begin
sName := GetNextSt(sData, ',');
if mIsUserInGroup(USER_UIN, sName) then s := 'YES'
else s := 'NO';
mLogScript(sName, s);
end;
end.
[18:22:38] (Log "mIsUserInGroup"): User "Alexey Pikurov" is on the group list?
[18:22:38] (Log "mIsUserInGroup"): [YES] Administrators
[18:22:38] (Log "mIsUserInGroup"): [NO] Moderators
[18:22:38] (Log "mIsUserInGroup"): [NO] Others
[18:22:38] (Run "mIsUserInGroup"): Script operation time: 6 ms
[18:22:38] (Run "mIsUserInGroup"): Script done successfully.