Retreiving calendar security for a given user

I was recently asked how to determine if a user has access to another users calendar and  if they do what rights they have.  The following 2 functions can be used to determine this. 

The function CalendarAccessForUser accepts one paremeter, the userid to check to see if calendar access exists.  It will return true if the current user has access to the specified user and return false if they do not.

The next function CalendarRightForUser accepts 2 parameters, the first being the user ID again and the second being the feature access to check against.  The options are Add, Edit, or Delete.  It will return true if the current user has the specified feature access and false if they do not.

The final function is used within both other functions as a means of retrieving the data from the SalesLogix database.

public function CalendarAccessForUser(byval userid)
    Dim res
    Dim voption

    res = true

    vption = getscalarvalue(“userid”,”usercalendar”,”userid='” & application.BasicFunctions.CurrentUserID & “‘ and caluserid='” & userid & “‘”) & “”
    if voption = “” then res = false
    CalendarAccessForUser = res
end function

 public function CalendarRightForUser(byval userid, byval CalendarType)
    Dim res
    Dim voption
    Dim fieldname
    res = false
    fieldname = “allowadd”

    if ucase(CalendarType) = “ADD” then fieldname = “allowadd”
    if ucase(CalendarType) = “EDIT” then fieldname = “allowedit”
    if ucase(CalendarType) = “DELETE” then fieldname = “allowdelete”
    vption = getscalarvalue(fieldname,”usercalendar”,”userid='” & application.BasicFunctions.CurrentUserID & “‘ and caluserid='” & userid & “‘”) & “”
    if ucase(voption) = “T” then res = true
    CalendarAddForUser= res
end function

 Function GetScalarValue(Field, Table, Condition)
Dim rs
Dim ret

    Set rs = Application.GetNewConnection.Execute(“select ” & Field & ” from ” & Table & ” where ” & Condition)
    If Not (rs.EOF Or rs.BOF) Then
        ret = rs.Fields(0).Value
    End If
    Set rs = Nothing
    GetScalarValue = ret
End Function

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!