The best way to remove all of a user's private views on a db
The best way to remove all of a user's private views on a db
Drop into a button for the admin to periodically click. Or include in the DatabaseOpen script.
In R5 use isPrivate property of view instead of isPrivateView(NotesView)
$Flags containing a "V" may not be reliable in future versions of Notes
Sub Postopen(Source As Notesuidatabase)
%REM ==================================================== This code removes out-of-date private views stored on the server. Each time the database is opened, it searches for private views. For each private view, it compares the Created date to the LastModified date of the corresponding shared view. If the shared view design was updated after the private view was created, then we know that the private view's design is out of date. The private view is then removed and the user is issued a message box advising that they close and reopen the database. Usage: This code can be used ad-hoc by the database manager to remove all private views. It is more efficient that way, but requires manual execution. For R5.0 and later, use the isPrivate property of NotesView rather than isPrivateView(v) 22 March 1999 Jamie Magee Martin Scott Consulting LLC McLean, Virginia www.MartinScott.com Jamie.Magee@MartinScott.com (c) copyright 1999 Martin Scott Consulting LLC %END REM ================================================= Function isPrivateView(v As NotesView) As Integer isPrivateView = False Set vdoc = v.parent.GetDocumentByUnid( v.UniversalID ) If Not (vdoc Is Nothing) Then If vdoc.HasItem("$Flags") Then If Instr(vdoc.GetItemValue("$Flags")(0), "V") Then isPrivateView = True Exit Function End If End If End If End Function Function getMasterView(pView As NotesView) As NotesView Set db = pView.parent viewList = db.views Dim view As NotesView Forall v In viewList If v.Name = pView.Name Then Set view = v If Not(isPrivateView(view)) Then Set getmasterView = v '...get the shared view on which this personal view is based Exit Function End If End If End Forall Set getMasterView = Nothing Print "Shared copy of view '" & pView.name & "' can not be found." End Function Set db = Source.database '...works in Database PostOpen event, modify for other contexts count=0 privateviewtext="" Dim masterView As NotesView tot = Ubound(db.views) + 1 Forall v In db.views count=count+1 Print "Checking view " & count & " out of " & tot & "..." If isPrivateView(v) Then Set masterView = getMasterView(v) '...get the shared view on which this personal view is based If Not(masterView Is Nothing) Then If v.Created < masterView.LastModified Then '...if the shared view design was updated after the private view was created... '...then remove the private view privateviewtext=privateviewtext & Chr(10) & v.name v.remove End If End If End If End Forall If privateviewtext="" Then Print "No out-of-date private views were found." Else Print "" Messagebox "The following out-of-date private views were removed:" & privateviewtext & Chr(10) & "Please reopen this database for these views to be updated." End If End Sub |