rocky.ongkowidjojo

Check TOU before posting a comment

Discussion created by rocky.ongkowidjojo on Jan 20, 2011

Case #109965

Details


Status: Closed
Case Type: /
Severity: Level 2
Product: /
Component: Core: Attachments - Binary Content - Images
Environment: /
Internal Discussion Link: /

Description


Hello,

 

I'm trying to do customization to enable TOU check before user post a comment. I'm aware that TOU check is fired up by default when user's trying to submit ideas, not posting comment.

The problem I'm having now is: I can't see where the commenting code is written for Ideation plugin. Looks to me that it's using the same CreateCommentAction.java in core SBS code.

 

Is there any way to turn this feature on without modifying core code?

Please advise

 

 

Thanks,

Rocky


Comments


Hi Rocky,

 

Would you like me to provide you the source code of the Ideation plugin?  I am not sure if this will be possible, but it sounds like it will be very helpful in troubleshooting this.

 

Thanks,

Cory



Hi Cory,

 

I already have the source code and got confused somehow with how the commenting is implemented. I couldn't find where it is implemented, and so far it looks to me that it's still using the core SBS code. Not very sure either. Any documentation on how TOU is implemented will be very helpful though, especially on how the database is.

 

Thanks,

 

Rocky



Hi Rocky,

 

The Terms of Use are not commentable.  They are set via the Admin Console, and appear as a message that must be approved before you create an Idea.

screenshot16.png

 

Ideas implement a custom content type using the Content Type Framework.  Ideas are commentable because the IdeaObjectType implements CommentableType.  This mostly consists of providing a CommentableTypeInfoProvider, which is done with the class IdeaCommentableTypeInfoProvider.  With this in place, the idea.ftl simply includes the following line to show comments:

<@comments contentObject=idea isPrintPreview=fromPrintPreview />

 

Thanks,
Cory



Hi Cory,

 

Yes, I understand that. What we need to implement is not to comment TOU, but to enable TOU checking before user posting comments on ideas. The idea here is, user have to sign TOU before they create an idea AND before they post comment to existing ideas. Do you think this is possible to implement?

 

Thanks,

Rocky



One more issue that I'm having here is: when I call this function

 

ideaManager.getIdeaTOU(getUser().getID())

 

It returns NULL exception pointer, which is weird because I have an entry in the Dbase. Not sure if there is an initialization first.

Please advise,

 

Thanks,

Rocky



Hi Rocky,

 

After looking over the CommentableTypeInfoProvider interface, I do not believe this will be possible.

 

One thing you could do is prevent users from commenting and seeing comments until they confirm the TOU:

  1. In the FTL, before including the comments macro I posted earlier, check to see if the user has confirmed the TOU.
  2. If they have not confirmed the TOU, add a link that says "You must first confirm the terms of use before viewing/adding comments."  You would need a custom action for showing the Terms of Use in this scenario.
  3. If they have confirmed the TOU, show the comments macro.

 

If you want to make it so they can view comments but not add them, I think you may need to actually re-write the comments framework and remove CommentableType from IdeaObjectType.

 

Thanks,

Cory



Hi Cory,

 

Thanks for pointing out. I believe in order to do that I would need to do DB query to check whether user has signed the TOU previously or not. But strangely, as I mentioned on my previous post, it returns NULL when I query from my action class. Do I need to register my custom action class first somewhere to enable DB query?

 

Thanks,

Rocky



Hi Rocky,

 

You can see this method used in HandleIdeaTOUAction.updateUserTOUStatus().  Typically, if the user has not already accepted the TOU, it will return null.

if(null==ideaManager.getIdeaTOU(user.getID())) {
     ideaManager.addIdeaTOU(ideaTOUBean);
     return true;
} else {
    ideaManager.updateIdeaTOU(ideaTOUBean);
    return true;
}

 

Thanks,

Cory



Hi Cory,

 

Well, I tried that method as well, doesn't work. I tried to put the existing userID number to the method directly to see if it will fetch the data, unfortunately it didn't. I use this method:

 

 

ideaManager.getIdeaTOU(1);

 

userID 1 is supposed to be administrator, and I checked DB entry already, there is an entry with userID = 1. It returns NULLpointer exception. Is there anything to do with sessions parameter to do this? or during ideaManager instantiation perhaps?

 

 

Thanks,

Rocky.



Hi Cory,

 

Another interesting finding is: I'm able to query the community database, user database, and other database entry that comes with the default SBS package. BUT, not with Ideation database entry, e.g.: ideas, userTOU. Is there any method to initiate the connection first? or it should work right away?

 

Thanks,

Rocky


Outcomes