Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Blog_Comment table stores the username, doesn't update if username is changed View modes: 
User avatar
Member
Member
matt-awg - 8/6/2013 1:55:03 PM
   
Blog_Comment table stores the username, doesn't update if username is changed
Does anyone know why the Blog_Comment table stores the username in addition to the user ID but then does not udpate the username in the Blog_comment table when a user's username is changed? It seems many places are directly accessing this field instead of joining to the user table to get the latest username. I have customized things where I can, to add the join but some places I can't without sourcecode, for example, BlogCommentInfoProvider.GetPostComments function returns CommentUserName which is not displaying the new username if a user's username was changed after making the comment. Specifically, I am looking in this class: CMSModules_Blogs_Controls_BlogCommentView and this line of code:
// Get all post comments
rptComments.DataSource = BlogCommentInfoProvider.GetPostComments(PostNode.DocumentID, !isUserAuthorized, isUserAuthorized, DisplayTrackbacks);

I was going to try to update the SQL like I did in some other places but I can't here since I don't have the source code, I can't change it and I can't even see what this code is doing to replace it with my own datasource.

Is this a bug or am I just missing something simple here?

Thanks,
Matt

User avatar
Member
Member
matt-awg - 8/6/2013 3:14:17 PM
   
RE:Blog_Comment table stores the username, doesn't update if username is changed
One thing I realized.... this may have something to do with the ability for blog comments by anonymous users (not logged into kentico). In the site I am building, they are required to be logged in with a kentico user to comment. That does not solve my problem of course but I am seeing why it may be coded this way. It still seems incorrect to me either way. It could left join to the users table and use the blog comment username if the kentico username is null. Anyway, any insight would be appreciated.
Thanks,
Matt

User avatar
Kentico Support
Kentico Support
kentico_janh - 8/12/2013 1:30:21 AM
   
RE:Blog_Comment table stores the username, doesn't update if username is changed
Hello,

Yes, as you've mentioned, any public visitor can comment, so the Name is just a text field which gets prefilled, when a user is logged in with his/her UserName. However even then, you can change the name to any text you want, so there is no linkage with the CMS_User table.

Best regards,
Jan Hermann

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/14/2013 7:49:21 AM
   
RE:Blog_Comment table stores the username, doesn't update if username is changed
Matt since you are requiring the user to log in to post you could make a simple modification to the database table which would do this work for you without a problem. I've done this with custom tables and the cms_user table without issue. I'm 99.9% positive this isn't supported but if it helps and you run into issues with upgrades, its pretty simple to remove the fix and apply it later.

Open SSMS and navigate to your database and the Blog_Comments table. Right click the Blog_Comments table and click Design. Select Relationships. You'll see there is already a link to the CMS_User table but for ID only. We need to create one for the UserName field, but not yet.

If we continue down this road we will receive an error because the CMS_User.UserName field is a nvarchar(100) field and the Blog_Comment.CommentUserName field is a nvarchar(200). The datatypes need to match. So we start by changing the Blog_Comment.CommentUserName field to nvarchar(100) (safe to do so since you are requiring login). Then save it. You'll get notification that you are updating 3 tables, click OK.

Next go back to the Relationships for the Blog_Comments table. Click Add and next to the Tables and Columns Specification row, click the 3 periods. Select CMS_User as the Primary Key table with UserName as the field. Then select CommentsUserName for the Blog_Comments table. The important part is at the very bottom of this dialog box, INSERT and UPDATE specifications. Click the + to expand and in the Update rule, select Cascade. If you do this when the username changes in the CMS_User table, it will cascade and update in the Blog_Comments table.

Again, I'm 99.9% positive this isn't supported but its a change I'd make if it was a client's requirement because it involves no writing custom code and if documented correctly, can be reversed, the system updated, and re-implemented again in less than a few minutes.

User avatar
Member
Member
matt-awg - 8/27/2013 6:40:04 AM
   
RE:Blog_Comment table stores the username, doesn't update if username is changed
Thanks FroggEye but we have decided to abandon using Kentico for this project. The amount of customization and time spent on this so far was more than it would have took to build a custom solution from scratch. Thanks anyway for the idea.
-Matt

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/28/2013 7:55:45 AM
   
RE:Blog_Comment table stores the username, doesn't update if username is changed
That's unfortunate. I've been able to implement a typical blog solution into an already created Kentico site in less than 5 hours (styling and all). I understand some customization may need to be done, that's a given. I've worked with several asp.net CMS solutions and this one is by far the best and most like a typical asp.net website. Good luck on your project.