Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsEventsEventsSuggestion + code : templates based on roleSuggestion + code : templates based on role
Previous
 
Next
New Post
6/3/2012 5:11 PM
 

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

 
New Post
6/3/2012 5:52 PM
 

I like this idea and have added to CodePlex for the next major release here - http://dnnevents.codeplex.com/workite...

Cheers
Roger


DNN MVP
Events - Get the latest version - Upgrade now!!
Feedback 6.4.2 - Now available - Give it a go!
Find us on Codeplex - DNN Events, DNN Feedback
Requirements/Bugs - Please submit them on Codeplex
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsEventsEventsSuggestion + code : templates based on roleSuggestion + code : templates based on role


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out