我有一个数据库保存合同,每个合同都有一个附加的文档文件。
我的任务是让没有访问数据库的用户能够访问特定的合同及其附件。
因此,特殊访问按钮。
我向表单添加了一个特殊的访问按钮,可以访问默认用户。
我能够让他们访问合同,但我无法让他们访问附加文档。
经过进一步调查,我发现与附加文档相关的表单仅限于与角色/读者,作者和网站管理员一起查看。
我应该做的解决方案是创建一个新角色(addreader)并创建一个具有addreader角色的组。
当通过特殊访问按钮添加用户时,应将用户添加到具有addreader角色的笔记组中。
我的问题在这里是如何添加组中的用户。
我是一名莲花笔记的初学者,我希望得到一些帮助。
在此先感谢。以编程方式将用户添加到莲花笔记组
代码从这里开始:
Sub Initialize
AGENT_NAME = "wqs-DocAccess"
ERROR_ON = True
If (ERROR_ON) Then On Error Goto Error_Handler
Call initObjects() ' Set global variables
Call ProcessAccess()
Exit Sub
Error_Handler: ' Error handling
Call ErrorHandler(Err(), Error$(), "Initialize sub", Erl())
End Sub
Sub ProcessAccess()
' This sub will inspect the given effective date range and enforce it for this web submit.
If (ERROR_ON) Then On Error Goto Error_Handler
Dim scanDoc As NotesDocument
Dim nItem As NotesItem
Dim vStart As Variant
Dim vEnd As Variant
Dim vEntries As Variant ' Array of strings
Dim strUser As String
Dim strCanonUser As String
Dim strDESUnid As String
Dim strDuration As String
Dim doRemove As Integer ' Boolean: Default = False
strUser = webDoc.GetItemValue("UserName")(0)
strCanonUser = Session.CreateName(strUser).Canonical
strDESUnid = webDoc.GetItemValue("DesDocID")(0)
If (webDoc.GetItemValue("RemoveAccess")(0) = "Yes") Then doRemove = True
' Determine date range
vStart = webDoc.GetItemValue("AccessBeginDate")(0)
strDuration = webDoc.GetItemValue("Duration")(0)
' Required fields on Access Doc have been filled out - continue inspection
vEnd = Evaluate(|@Adjust([| & Format$(vStart, "mm/dd/yyyy") & |]; 0; 0; | & Val(strDuration) - 1 & |; 0; 0; 0)|)
vEnd = vEnd(0)
' Store info in the event an error occurs trying to retrieve DES
strErrorInfo = "DES UNID = " & strDESUnid & "; User = " & strUser & "; AccessDoc UNID = " & webDoc.UniversalID
' Retrieve DES doc
Set desDoc = getDESDoc(strDESUnid)
If (desDoc Is Nothing) Then
Error 6020, "ERROR: Could not find related DES doc upon saving the Access doc" ' Should never happen.
End If
' Continue inspection of effective date range and be sure is enforced on DES
vEntries = desDoc.GetItemValue("AllowAccess")
If ((Today >= vStart And Today <= vEnd) And (Not doRemove)) Then
' In scope, be sure name and Access UNID are in DES
If Not (isStringInArray(strUser, vEntries)) Then
' User should have access, but is not listed -- stamp name on DES
Call desDoc.ReplaceItemValue("AllowAccess", AddStringToArray(strUser, vEntries))
Call desDoc.ReplaceItemValue("AllowAccessDocID", _
AddStringToArray(webDoc.UniversalID, desDoc.GetItemValue("AllowAccessDocID")))
' Add name to Readers field on DES
Call desDoc.ReplaceItemValue("WhoCanRead", _
AddStringToArray(strCanonUser, desDoc.GetItemValue("WhoCanRead")))
' BSM 09/08/2004: Also add name to Readers field on Scan doc (if one exists)
Set scanDoc = getScanDoc(desDoc)
If Not (scanDoc Is Nothing) Then
Call scanDoc.ReplaceItemValue("WhoCanRead", _
AddStringToArray(strCanonUser, scanDoc.GetItemValue("WhoCanRead")))
Call scanDoc.Save(True, True)
End If
Call StampAccessHistory(desDoc, Format$(Now, "mm/dd/yyyy") & " -- Name added: " & strUser)
Call desDoc.Save(True, True)
End If
Else
' Out of scope, be sure name and Access UNID are *not* in DES
If (isStringInArray(strUser, vEntries)) Then
' ERROR -- User has access, but should not! -- Remove user name stamp from DES.
Call RemoveAccessNameFromDES(strUser, strDESUnid, False)
End If
If (vEnd < Today) Then
Call webDoc.ReplaceItemValue("Expired", "Yes")
End If
' Note: If user clicked "Remove", then the daily agent will delete it the next day (cannot delete webDoc if the DocumentContext)
End If
' Copy editors field over from DES doc
Set nItem = desDoc.GetFirstItem("WhoCanEdit")
Call webDoc.CopyItem(nItem, "")
Exit Sub
Error_Handler: ' Error handling
Call ErrorHandler(Err(), Error$(), "ProcessAccess sub", Erl())
End Sub
Sub initObjects()
' This sub will set certain global variables
If (ERROR_ON) Then On Error Goto Error_Handler
Call InitSession() ' Invoke shared function
Set webDoc = Session.DocumentContext
Exit Sub
Error_Handler: ' Error handling
Call ErrorHandler(Err(), Error$(), "initObjects sub", Erl())
End Sub
我不确定将用户添加到组是否是解决问题的正确方案。您需要在此澄清一些您的语言,以便我们清楚地了解您的真实情况。当你说“附件”时,这可能仅仅意味着一个直接附加到包含合同的Notes文档的文件。我不认为你是这个意思,但重要的是要确定。此应用程序是否有两种形式 - 一种用于合同文件,另一种用于包含附件的文件? –
第二理查兹评论 –
对不起,我无法清楚地讨论我的问题。你是对的。文档附有文档和文件。我有两种形式。一种形式来查看合同和另一种形式,用户可以查看或下载附件。用户可以下载附件的表单仅限于角色阅读,作者和siteadmin用户查看。数据库已经由开发者设计。 –