Task:
Add access checks or process documents pending deletion.
Sample Solution:
Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim acl As NotesACL
Dim entry As NotesACLEntry
Dim level As Integer ' ACL level
Dim c As NotesDocumentCollection ' Collection of Deleted Documents to be processed
Dim doc As NotesDocument ' Current doc being deleted
Dim item As NotesItem ' Authors field on document
Dim f As String
Dim ami As Integer ' Success or Failure integer
' Get User
Dim user As String
user = session.UserName
' Get current ACL for user
Set db = session.CurrentDatabase
Set acl = db.acl
If acl Is Nothing Then
' If acl is nothing then the person has no access to the database and is only in because of public documents
Continue=False
Messagebox( "Your access level does not allow you to delete documents." )
Exit Sub
End If
Set entry = acl.GetEntry( user)
level = entry.level
' If ACL level less than author...
If level <3 Then
Continue=False
Messagebox( "Your access level does not allow you to delete documents." )
Exit Sub
End If
' If ACL delete documents checkbox is not selected
If entry.CanDeleteDocuments=False Then
Continue=False
Messagebox( "Your access level does not include the check box to delete documents." )
Exit Sub
End If
' If ACL level is designer or manager...
If level >4 Then
Continue=True
Goto SkipToEnd
End If
' At this point only authors and editors are left. These will follow the standard author's field values
' We only need to now test any special document forms that we don't want deleted at all this way
Set c = source.documents
Set doc = c.GetFirstDocument
Do
f = doc.Form(0)
If f = "StatDoc" Or f="Portal" Or f="GenericOnePortal" Or f="YahooPortal" Or f="YahooPortal2" Or f="SearchPortal" Or f="CalendarPortal" Then
Continue=False
Else
Continue=True
End If
Set doc = c.getnextdocument(doc)
Loop Until doc Is Nothing
Exit Sub
SkipToEnd:
Exit Sub
End Sub
previous page
|