Description
Returns the logon or full name of the user who's holding in use the specified object, or empty string.
Syntax
dim UserName as String = UtilsBase.GetObjCurEditorName(iObjId, bMeIncluded, bFull) |
iObjId
Id of the object you want to know who's using it
bmeIncluded
If True, it will return your ID as well, if you're the user of the object iObjId.; if False, it will return 0 if you're the user of the object iObjId.
bFull
If True, it will return the full name, otherwise the logon name.
Code
Public Shared Function GetObjCurEditorName(ByVal iObjId As Integer, ByVal bMeIncluded As Boolean, ByVal bFull As Boolean) As String
'returns the name or fullname of the object's current user - possibly excluding the logged user (you)
'v1 on 7/Nov/12 (BS)
Dim objlist = New List(Of Integer)
Dim userlist As List(Of Integer)
objlist.Add(iObjId) ' txtlist.Add(article.GetTxtNode(iCurTxt).Id) - that would be for the current
userlist = EditorialLogin.Get().ObjIsCheckedOut(objlist, CheckOutCode.Content)
Dim userid = userlist(0)
' if nobody is using it, return ""
If userid = 0 Then Return ""
' if you are excluded, and you're using it, return ""
If Not bMeIncluded And userid = EditorialLogin.GetLogin.GetContext().UserId Then Return ""
' return specified attrib
If bFull Then
Dim UserFullName As String = UtilsBase.GetObjAttrValue(userid, "fullName")
' if fullname is not defined for an user, return name
If UserFullName = "" Then
Return UtilsBase.GetObjAttrValue(userid, "name")
Else
Return UserFullName
End If
Else
Return UtilsBase.GetObjAttrValue(userid, "name")
End If
End Function
See also