Created
January 31, 2013 17:44
-
-
Save Lokutus/4684720 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%REM | |
Class UserSubstitutionManager | |
Handle substitution settings in user profiles | |
@author Jiri Krakora | |
@date 31.1.2013 | |
@uses UserProfileLazyLoader, Collection | |
@revision 31.1.2013 1.0 Relesase | |
%END REM | |
Public Class UserSubstitutionManager | |
Private oLazy As UserProfileLoader | |
Private oProfiles As Collection | |
Public Sub New | |
Set Me.oLazy = New UserProfileLoader | |
Set Me.oProfiles = New Collection | |
End Sub | |
%REM | |
Initialize object | |
@return true/false if success | |
%END REM | |
Public Function Init As Boolean | |
Let Init = Me.oLazy.Init | |
End Function | |
%REM | |
Return flag whether is Substitution enabled in given user profile or not | |
@param User name value in abbreviated or canonical format | |
@return true/false | |
%END REM | |
Public Function IsSubstitutionEnabled(userNameValue As String) As Boolean | |
Dim userName As New NotesName(userNameValue) | |
Dim profile As UserProfile | |
Set profile = Me.GetProfile(userName) | |
Let IsSubstitutionEnabled = profile.IsSubstitutionEnabled | |
End Function | |
%REM | |
Return name of the substitute | |
@param User name value in abbreviated or canonical format | |
@return User name of the given substitute in canonical format | |
%END REM | |
Public Function GetSubstituteName(userNameValue As String) As String | |
Dim userName As New NotesName(userNameValue) | |
Dim profile As UserProfile | |
Dim substitute As User | |
Set profile = Me.GetProfile(userName) | |
Set substitute = profile.Substitute | |
Let GetSubstituteName = substitute.ToCanonical() | |
End Function | |
%REM | |
Try to get user profile from collection or lazy load it from database | |
@param User name object | |
@return UserProfile object | |
%END REM | |
Private Function GetProfile(userName As NotesName) As UserProfile | |
Dim s As UserProfile | |
Set s = Me.oProfiles.Get(LCase(userName.Abbreviated)) | |
If s Is Nothing Then | |
Set s = Me.oLazy.Load(userName) | |
End If | |
Set GetProfile = s | |
End Function | |
End Class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment