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

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Token Replacement IssuesToken Replacement Issues
Previous
 
Next
New Post
10/16/2007 1:17 AM
 

Hello (this is probably best aimed at Stefan ;)

I've been reading the blog post about Tokens, and I have refactored the Events email templates to use it.It is great stuff, and I can remove some of the custom code I wrote to do this, and give my users a more standard interface, but I am hitting a couple of issues:

Basically, it appears as though it can only handle one user at a time. Many of my emails need two UserInfo objects - for exampe, when someone RSVPs to an event, a mail is sent from UserA to UserB, the event creator.

I used to use tokens like [TOUSERID] and [FROMUSERID], but I can at least remove the "TO" user values as I can use the core "[User:.." tokens for this. The first problem is that the To person is not always the logged on user, so I need to set it to the UserInfo of someone else, so I tried :

tokenReplace.User = toUserInfo;

where toUserInfo is NOT the logged on user (event created by person in my example). The result was odd - "*******". In debug mode tokenReplace.User was definitely pointing at the correct user, but only the "*******" came out for "[User:DisplayName]". The same token worked when I used the logged on user though. Any ideas?

The second issue is how to handle the additional UserInfo object. You can just change the User as the first time you ran it through all [User] tokens would be replaced with the To User. So it needs a new Token I think... what would you suggest - something like "[User2:DisplayName]" (it would problably be better to have User and User2 as opposed to To and From user. It does exactly the same as the User token, but must only replace those with User2 - any tips on where to start please?

My other question is:

I need to get this setting : PortalModuleBase.PortalSettings.PortalAlias.HTTPAlias

Can you use nested tokens (ie. it is proprty of PortalSettings ("Portal") but I actually need "PortalAlias.HTTPAlias".

I currently use

text = text.Replace("[PORTALURL]", pmb.PortalSettings.PortalAlias.HTTPAlias);

will I have to make a new class inheriting from Base Tokens for PortalAlias?

Much appreciated!

 

 


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
10/16/2007 3:14 AM
 

Hi Rodney,

since Stefan is travelling this week and I worked with him on TokenReplace, you might accept an answer from me as well.

If you get "********", this is usually caused by a security restriction, that limits property access to authorized users only, In order to take the burden of calculating permissions from the module developer, we developed a security feature set, that is determined by the queried objects according to AccessSecurityLevel and accessingUser, which allows most granular restrictions. Access to user profile properties can be configured by each individual user in his property (if activated by the admin) and will be taken into account. Other objects define a general line, differencing between administrators, registered users and unauthenticated guests. The user data currently does not differenciate per property, in defaultAccessLevel, each user can query his own properties only, to get information from other users, you need to use Scope.SystemMessages and set AccessingUser accordingly. from my curent review, IMO we should differenciate between the properties, I will try to get this included with DNN 4.7.0.

To access Portal alias, user [Portal:URL] (no access restriction). There is currently no complete list of properties, the most recent is included in the UDT 3.4.0 User Manual, otherwise you currently need to dive into the source code, starting with DotNetNuke.Services.Tokens in Library/components/TokenReplace.vb and retrieving the various DotNetNuke entities implementing Properties. We are currently working to enhance TokenReplace adding property collections and a selector control, that can be placed on forms and maybe included in the toolbar of RichTextEditors as well - but this will not be ready for DNN 4.7.0, I apologize.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
10/16/2007 4:09 AM
 

I should have known you’d have your hand in that too Sebastian ;)

Ok, the simple stuff first – [Portal:URL] does not work, and in the UDT manual it says [Portal:PortalAlias], which returns this error “RESX:TokenReplaceUnknownProperty.Text”. This is not a value in the Portals DB table, so I assume it is retrieved dynamically from somewhere. I checked the PortalAlias class in the source and it uses “HTTPAlias” – but I am afraid none of these work.

I have been trawling through the code for some time now and it’s still not entirely clear where it checks the property name – from what I can see it loads each object type into a hashtable? The fact that I am not too hot on VB.NET does not help ;)

Ok, for the SecurityLevel – I am not sure what Scope.SystemMessages does, but I set the User and the AccessingUser to the logged on user (in my business requirement, DisplayName is always visible, but yes, some other properties might not be) and now it works – thanks).

I need some advice on my class design please – I am battling to understand how best to achieve this (Stefan’s blog entry confused me a little with the different Object sources and when you would use the BaseTokenReplace:

An example is probably the easiest to start with: Basically when a user (UserA) RSVPs to an event, UserB (Event Creator) receives an email. I currently have the following info in my template:

  • EventName (from EventInfo object)
  • EventCreatedBy DisplayName (UserB)
  • EventUser DisplayName (UserA)
  • List value (the RSVP option Y/N/Maybe), based on EventUserRSVPID in the EventUser object
  • and a couple of others….

So… there are at least 3 different bits of data here – the Event object, EventUser object and the custom bit where it passes the EventUserRSVPID into the core List functionality to get a listEntryInfo.Text property. Currently this is implemented (n a very inefficient String.Replace method –

        private string ReplaceParams(SmartThinker_EventInfo smartThinker_EventInfo, SmartThinker_EventUserInfo smartThinker_EventUserInfo, string rsvpText, string text)

        {

            text = text.Replace("[Event.EventName]", smartThinker_EventInfo.EventName);

            text = text.Replace("[Event.Location.City]", smartThinker_EventInfo.City.ToString());

            text = text.Replace("[Event.Location.Country]", smartThinker_EventInfo.Country.ToString());

            text = text.Replace("[EventUser.Comment]", smartThinker_EventUserInfo.Comment);

            text = text.Replace("[EventUser.EventRSVPText]", rsvpText);

            return text;

        }

Now, from Stefan’s blog – it appears as though I have 2 options – I could either make a basic class that inherited from BaseTokenReplace and essentially does a switch statement to return the correct value based on the property name, and I would pass in the EventInfo, SmartThinker and any other data I need, or I could use the PropertyAccess method.

From what I can see, I could implement IPropertyAccess in my Event and EventUser Info classes – the bit that is confusing me is how it all fits together. I checked the core PortalInfo object and it does not seem to implement this interface, which I thought it would have to? Where does it actually retrieve the value from? Does it load it into a hash-table somewhere? I assume I am going to need 2 new TokenReplace types here – one for Event and one for EventUser, with their respective PropertyAccessors.

Another question is that the text = tokenReplace.ReplaceEnvironmentTokens(text) seems to process all the different types of objects. Will I need to inherit from and extend that class to add my new object type to it so I only have to call NewTokenReplace.ReplaceEnvironmentTokens(text) to have it process all the token objects?

The other problem is the fact that I am using 2 UserInfo objects – how would you suggets I get around this? I need to make a class exactly the same as the current “User” one, but it muct only replace “User2” objects.

Sorry Sebastian, I know this is quite a complex post and I really appreciate your time - I am battling to reverse engineer it and some pointers on class design would help a lot!

ps - please excuse the colours/formatting - I wrote it in Outlook and pasted it and spent more time trying to make it uniform than writing it!


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
New Post
10/16/2007 4:31 AM
 

Rodney,

Tokens do not need to match object hierarchy, this allows us to provide a simplier model to admins than needed for developers. Tokens are derived from system objects, declared in tokenReplace.vb, which pass over the property to the object itself, using the new "IPropertyAccess" interface, which implements GetProperty. PortalSettings implements GetProperty using a Select statement, first case is "Url", that is mapped to Me.PortalAlias.HTTPAlias(). This architecture allows each core team developer to modify property access for tokenReplace together with object modifications in the same file (or, at leaset same folder). Regarding your other questions, I will answer tonight, I am atm running out of time, sorry.


Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
10/25/2007 7:49 PM
 

Thanks for the help so far Sebastian - I have a couple more questions now ;)

Firstly, a bug, I think -
URL: This is not working. I debugged the core code and it's passing in ""portalurl" instead of "url" (value of variable "lowerPropertyName") for this token -  [Portal:URL] - not sure why... the Case statement is looking for "url" in PortalSettings.vb

Secondly, a question about the core code: In the GetProperty method on PortalSettings.vb, there are the following lines:

            Dim OutputFormat As String = String.Empty
            If strFormat = String.Empty Then OutputFormat = "g"

and

                Case "expirydate"
                    PublicProperty = False : PropertyNotFound = False : result = (Me.ExpiryDate.ToString(OutputFormat, formatProvider))

but OutputFormat is only ever going to be Empty, or "g" (if strFormat is Empty). That means that if you try to format Expirt daye with "dddd", Output format will be Empty and it wlll not format. Is this a bug, or have I missed something (I did away with OutputFormat completely and use StrFormat (which defaults to "g" if Empty).

I'm going to ask my main question in a separate post...


Entrepreneur

PokerDIY Tournament Manager - PokerDIY Tournament Manager<
PokerDIY Game Finder - Mobile Apps powered by DNN
PokerDIY - Connecting Poker Players

 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...Token Replacement IssuesToken Replacement Issues


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