Bonjour,
Il s'agit bien de vues stockées sur le serveur , "Partagé, devenant privé à la 1re ouverture".
Public Sub ViewPrivateDelete(wNameView As String, wDB As NotesDatabase,wType As String,nbDeleteAll As Boolean)
Dim DBDesktop As NotesDatabase
Dim DBServer As NotesDatabase
Dim vwDelete As NotesView
Dim vwBase As NotesView
Dim nbCacheServer As Boolean
Dim nbCacheDesktop As Boolean
Dim vrValue As Variant
On Error Goto ErreurHandle
If Trim(wNameView)="" Then
If nbDeleteAll = False Then
Exit Sub
End If
End If
%REM
View : $FLAG
Shared : PY
Shared Server Private : pPY (pPYV pour la copie privé)
Shared Desktop Private : poPY
Private : PYV
Folder : $FLAG
Shared : 3PFY
Shared Server Private : 3pPFY (3pPFYV pour la copie privé)
Shared Desktop Private : 3poPFY
Private : 3PFYV
%END REM
Select Case Ucase(Trim(wType))
Case "S","SERVER","SERVEUR" 'Efface les vues privées sur le serveur
nbCacheServer = True
nbCacheDesktop = False
Case "B","BOTH","2","SD","DS"
nbCacheServer = True ' efface les vues privées sur le server et le desktop
nbCacheDesktop = True
Case "D","DESKTOP" 'efface les vues privées sur le desktop
nbCacheServer = False
nbCacheDesktop = True
End Select
If Session Is Nothing Then
Set Session = New NotesSession
End If
If wDB Is Nothing Then
Set DBServer = Session.CurrentDatabase
Else
Set DBServer = wDB
End If
'traitement pour les vues stocker sur le server
If nbCacheServer = True Then
'efface toutes les vues privées
If nbDeleteAll = True Then
vrValue = DBServer.Views
If TestVariant(vrValue) = True Then
Forall ValueS In vrValue
Set vwDelete = ValueS
If Not vwDelete Is Nothing Then
If ViewIsPrivate(vwDelete) = True Then
Call vwDelete.Remove
End If
Set vwDelete = Nothing
End If
End Forall
End If
vrValue = Null
Else
'efface la vue privée passé en parametre
Set vwDelete = ViewInit(DBServer, wNameView,Nothing)
If Not vwDelete Is Nothing Then
If ViewIsPrivate(vwDelete) = True Then
Call vwDelete.Remove
If nbCacheDesktop = False Then
Set vwDelete = Nothing
Set DBServer = Nothing
Exit Sub
End If
End If
Set vwDelete = Nothing
End If
End If
End If
'traitement pour les vues privées stocké sur le desktop
If nbCacheDesktop = True Then
Set DBDesktop = DBOpenDesktop()
If Not DBDesktop Is Nothing Then
'traite toutes les vues privées
If nbDeleteAll = True Then
vrValue = DBServer.Views
If TestVariant(vrValue) = True Then
Forall ValueD In vrValue
Set vwBase = ValueD
If Not vwBase Is Nothing Then
'passe en revue toutes les vue de la base pour trouver les privés
'puis va dans le desktop les supprimer
Set vwDelete = ViewInit(DBDesktop,vwBase.Name, vwBase.Aliases)
Set vwBase = Nothing
If Not vwDelete Is Nothing Then
If ViewIsPrivate(vwDelete) = True Then
Call vwDelete.Remove
End If
Set vwDelete = Nothing
End If
End If
End Forall
End If
vrValue = Null
Else
'traite la vue privé passé en paramettre
Set vwDelete = ViewInit(DBDesktop, wNameView, Null)
If Not vwDelete Is Nothing Then
If ViewIsPrivate(vwDelete) = True Then
Call vwDelete.Remove
End If
Set vwDelete = Nothing
End If
End If
End If
Set DBDesktop = Nothing
End If
Set DBServer = Nothing
Exit Sub
ErreurHandle:
Msgbox "("+Structure_Log+" : "+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
Exit Sub
End SubPublic Function ViewIsPrivate(vwView As NotesView) As Boolean
On Error Goto ErreurHandle
ViewIsPrivate = False
If vwView Is Nothing Then
Exit Function
End If
ViewIsPrivate = vwView.IsPrivate
Exit Function
ErreurHandle:
ViewIsPrivate = False
Resume Next
Exit Function
End FunctionPublic Function ViewInit(wDB As NotesDatabase, wNameView As String, wvrAlias As Variant) As NotesView
'permet d'nstancier une vue si elle est introuvable
Dim DBCible As NotesDatabase
Dim vrListViews As Variant
Dim vrListAlias As Variant
Dim vwSearch As NotesView
Dim nbAlias As Boolean
On Error Goto ErreurHandle
Set ViewInit = Nothing
If Trim(wNameView) = "" Then
Error 9999,"wNameView is empty"
Exit Function
End If
If Session Is Nothing Then
Set Session = New NotesSession
End If
If wDB Is Nothing Then
Set DBCible = Session.CurrentDatabase
Else
Set DBCible = wDB
End If
'tentative de connexion standard
Set ViewInit = DBCible.GetView(Trim(wNameView))
If Not ViewInit Is Nothing Then
Set DBCible = Nothing
Exit Function
End If
'sinon boucle sur l'ensemble des vues pour comparer les names et pseudos
Set ViewInit = Nothing
'recuepre la liste des vues
vrListViews = DBCible.Views
If TestVariant(vrListViews) = False Then
Set DBCible = Nothing
vrListViews = Null
Exit Function
End If
nbAlias = False
If TestVariant(wvrAlias) = True Then
nbAlias = True
End If
'parcours les vues
Forall ValueView In vrListViews
Set vwSearch = ValueView
If Not vwSearch Is Nothing Then
'reagrde si le nom est identique
If Trim(wNameView) = Trim(vwSearch.Name) Then
Set ViewInit = vwSearch
Exit Forall
Else
'sinon boucle sur chaque alias/pseudo
vrListAlias = vwSearch.Aliases
If TestVariant(vrListAlias) = True Then
Forall ValueAlias In vrListAlias
If Trim(Cstr(ValueAlias)) <> "" Then
If Trim(Cstr(ValueAlias)) = Trim(wNameView) Then
Set ViewInit = vwSearch
Exit Forall
End If
If nbAlias = True Then
Forall ValueAlias2 In wvrAlias
If Trim(Cstr(ValueAlias2)) <> "" Then
If Trim(Cstr(ValueAlias)) = Trim(Cstr(ValueAlias2)) Then
Set ViewInit = vwSearch
Exit Forall
End If
End If
End Forall
End If
End If
End Forall
End If
vrListAlias = Null
End If
Set vwSearch = Nothing
End If
If Not ViewInit Is Nothing Then
Exit Forall
End If
End Forall
vrListAlias = Null
vrListViews = Null
Set DBCible = Nothing
Exit Function
ErreurHandle:
Msgbox "("+Structure_Log+" : "+Cstr(Getthreadinfo (1))+" Call by "+Cstr(Getthreadinfo(10))+")"+Chr(10)+"Erreur " + Str(Err) + " : "+Chr(10) + Cstr(Error)+". "+Chr(10)+"Ligne N° "+Cstr(Erl),16," ERREUR !"
Set ViewInit = Nothing
Exit Function
End Function