Lua → VBScript SwxWare v13.10
This function searches for a user or multiple users and returns its results as list (indexed table).
local oUsers = PBXScript.GetUserByAddress(sNumber)
This function returns an indexed table with PBXConfigUser elements.
Parameter
sNumber
string. An internal number of a user or group, user name, group name, H.323 alias or SIP user ID to search for.
The result PBXConfigUser element contains a number of information regarding the found user:
:UserID() : number
:Name() : string
:EMailAddress() : string
:State() : number, PBXUserState (see PBXConfigUser)
:DataFolder() : string (***obsolete***)
:Numbers() : indexed table of strings
:MobileIdentificationNumbers() : indexed table of strings (***obsolete***)
:IsMobileExtensionEnabled() : boolean (***obsolete***)
:MobilePhoneNumber() : string (***obsolete***)
:NumberOfNewVoicemails() : number
:FreeStatusText() : string
The following is an example making use of the PBXScript.GetUserByAddress() function to return the current status of a given user:
------------------------------------------------------------------ -- GetUserStatus -- -- Returns the status of the given user. -- If being used on a user group it returns the status of the last user in the group. -- -- Parameter: -- sNumber extension of user or user group -- -- Return: -- number - PBXUserStateValue -- -- PBXUserStateUnavailable = 0 -- PBXUserStateLoggedOff = 1 -- PBXUserStateLoggedOn = 2 -- PBXUserStateSpeakingExternal = 3 -- PBXUserStateAlerting = 4 -- PBXUserStateSpeakingInternal = 5 -- PBXUserStateAway = 6 -- PBXUserStateDoNotDisturb = 7 -- PBXUserStateActive3rdParty = 8 ------------------------------------------------------------------ function GetUserStatus(sNumber) PBXScript.OutputTrace ("-------------> GetUserStatus(sNumber = " .. sNumber .. ")") local nReturn = 0 local oUsers = nil oUsers = PBXScript.GetUserByAddress(sNumber) if (oUsers ~= nil) then for i = 1, #oUsers do PBXScript.OutputTrace ("Found user " .. oUsers[i]:Name() .. " with current state " .. oUsers[i]:State()) nReturn = oUsers[i]:State() end end PBXScript.OutputTrace ("nReturn = " .. nReturn) PBXScript.OutputTrace ("<------------- GetUserStatus") return nReturn end
Examples from the Function Collection
:Name()
:State()
- GetUserStatus()
- IsAtLeastOneMemberOfGroupBusy()
- IsAtLeastOneMemberOfGroupLoggedOff()
- IsGroupLoggedOff()
- IsUserFree()
- IsUserLoggedOff()
- IsUserLoggedOn()
:NumberOfNewVoicemails()
By Tom Wellige