Hello,
Congratulations for this very good module. I would like to suggest a very easy addition on the template engine, enabling to display or not text depending on the fact the user has or not a given role. For ex, [HASROLE_xxx] would be the tag defining the text to display when the user is in role xxx, and [HASNOTROLE_xxx] when the user has not the role xxx.
The way I use it is to display phone numbers (implemented as a custom field) only when users are connected. Otherwise, the message "Please connect to display this information" is displayed. Sample config :
[HASROLE_Registered Users]
<span class="Normal">[event:customfield2]</span>
[/HASROLE_Registered Users]
[HASNOTROLE_Registered Users]
<span class="Normal">Connectez vous pour accéder à cette info</span>
[/HASNOTROLE_Registered Users]
Implementing such functionnality requires just a few lines in method EventController.TokenParameters, (for ex at its beginning) :
Public Function TokenParameters(ByVal sourceText As String, ByVal EventInfo As EventInfo, ByVal Settings As EventModuleSettings) As String
If sourceText.Contains("[HASROLE_") Or sourceText.Contains("[HASNOTROLE_") Then
Dim role As RoleInfo
Dim roleController As RoleController = New RoleController
Dim userRoles As String() = New String() {}
If Not UserController.GetCurrentUserInfo() Is Nothing Then
userRoles = roleController.GetRolesByUser(UserController.GetCurrentUserInfo().UserID, _portalId)
End If
For Each role In roleController.GetPortalRoles(_portalId)
sourceText = TokenOneParameter(sourceText, "HASROLE_" + role.RoleName, userRoles.Contains(role.RoleName))
sourceText = TokenOneParameter(sourceText, "HASNOTROLE_" + role.RoleName, Not userRoles.Contains(role.RoleName))
Next
End If
'... the rest of the code
End Function
Hoping that it helps, regards,
Michael