Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

I need advice on creating plugin update date message.

steamsteam www.planamigo.org - #1 foro planes amigo
edited September 2016 in Vanilla 2.0 - 2.8

Hi,

In my vanilla community I have members messages with personal promotions that constantly repeated in the discuciones. Users try to put your message as last one by copying your previous message.

To prevent post the same messages that users always try to put as the last I plan to create a plugin that allows users to update your comment by update the publication date. Then I would order the comments in the discussion by the date of update.
I thought that user could update each message from their profile where all comments are listed. By clicking the "button update" on each message.

Here comes the first problem, I can not get CommentID for each comment in ProfileController_BeforeItemContent_Handler event. UserID have obtained from the Sender but CommentID I can not find.

Then I think update message date (DateUpdated) according CommentID and UserID by ajax call.
And next step would be sort messages in discussion by the date of update (DateUpdated).

Someone can tell me how to get in ProfileController_BeforeItemContent_Handler event CommentID ?

I have also tried to overwrite profilecomments.php which makes messages list

public function ProfileController_AfterUserInfo_Handler ($ Sender, $ args) {
$ Sender-> View = PATH_PLUGINS '/ UpdateMessage / views / profilecomments.php.';

        $ Sender-> render ();
}

It does replace default listing by my class but user information that shown before messages is disappeared.

Any suggestions would be welcome,
Thanks

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    Do you want to create something like that for comments? https://vanillaforums.org/addon/bump-plugin

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited September 2016

    @R_J dijo:
    Do you want to create something like that for comments? https://vanillaforums.org/addon/bump-plugin

    Hi @R_J

    I have installed this plugin for test but do not understand what it does?

  • steamsteam www.planamigo.org - #1 foro planes amigo

    Does someone knows how to ordering comments in discusions by its DESC CommentIDs and DESC DateUpdated ?

    Thanks in advance

  • R_JR_J Ex-Fanboy Munich Admin

    @steam said:

    @R_J dijo:
    Do you want to create something like that for comments? https://vanillaforums.org/addon/bump-plugin

    Hi @R_J

    I have installed this plugin for test but do not understand what it does?

    It adds an option to discussions to "bump" them: that will make appear a discussion at the top of the recent discussion list again, without adding a comment to it.

    I did not understand what you are really looking for and so I thought that might be a comparison: that plugin shows a discussion at the top of the recent discussions list and I understood your question as if you want to let users change the order of comments in a discussion (which I think is a horrible idea).

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited September 2016

    I did not understand what you are really looking for and so I thought that might be a comparison: that plugin shows a discussion at the top of the recent discussions list and I understood your question as if you want to let users change the order of comments in a discussion (which I think is a horrible idea).

    Now I understand about "bump" plugin, but it's not what I'm looking for.

    I thought allow user to move his comment on the last position in the discussion. Avoid duplication of comments that users themselves.
    They are offering their discounts and copy the same text after some time or others comments.

  • R_JR_J Ex-Fanboy Munich Admin

    @steam said:
    I thought allow user to move his comment on the last position in the discussion. Avoid duplication of comments that users themselves.
    They are offering their discounts and copy the same text after some time or others comments.

    I would consider that a bad habit and I personally would prefer having a plugin that doesn't allow posting of duplicate comments in a discussion, or even better: report a duplicate post to the moderator so he could warn the user who did so.

    They should change their offer and post another info. But simply repeating themselves has no benefit for your users.

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited September 2016

    I would consider that a bad habit and I personally would prefer having a plugin that doesn't allow posting of duplicate comments in a discussion, or even better: report a duplicate post to the moderator so he could warn the user who did so.

    I agree with you that it is a bad habit of users to copy their messages and is bad for seo. So I'm thinking for a solution. I tired to warn users.
    I also thought about a plugin that does not allow posting of duplicate comments in a discussion.
    But to control it is very complicated and is not effective because the user can change two words and it is difficult to identify.
    So I thought allow a user to update the date of his message and put the same message as last in discussion.

    They should change their offer and post another info. But simply repeating themselves has no benefit for your users.

    What they want is to leave your promoting message in last place in the discussion.

    I dont know the best solution...

  • R_JR_J Ex-Fanboy Munich Admin

    I think there will be unpredictable problems when you change the order of comments (where would the "latest" link point to?), but maybe I am wrong.

    If some of your users comments are more ads than comments, maybe treating them like that would be helpful?

    What if they can check "This comment is an advertisment" when writing a comment and every advert (but only one at a time) would be shown either in a module in the panel or repeated at the end of the comments. Which comment is shown could be iterated so that every advert-comment is shown equally often.

    You would have to add two columns to the Discussion table (one for the info which advert-comment was shown last and one to hold an array of all advert-comments in the discussion) and one column to the Comment table (for the information if a comment is an advert)

    On comment save you have to check if you need to update the Discussion.AdvertCommentIDs field.

    On CommentModel AfterGet you have to add the current advert-comment and change the field in the Discussion table of the last shown advert.

    As an improvement I would only make the change to the db every X minutes and would only use one column for all CommentIDs and would always show the first one.

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited September 2016

    @R_J dijo:
    I think there will be unpredictable problems when you change the order of comments (where would the "latest" link point to?), but maybe I am wrong.

    If some of your users comments are more ads than comments, maybe treating them like that would be helpful?

    What if they can check "This comment is an advertisment" when writing a comment and every advert (but only one at a time) would be shown either in a module in the panel or repeated at the end of the comments. Which comment is shown could be iterated so that every advert-comment is shown equally often.

    You would have to add two columns to the Discussion table (one for the info which advert-comment was shown last and one to hold an array of all advert-comments in the discussion) and one column to the Comment table (for the information if a comment is an advert)

    On comment save you have to check if you need to update the Discussion.AdvertCommentIDs field.

    On CommentModel AfterGet you have to add the current advert-comment and change the field in the Discussion table of the last shown advert.

    As an improvement I would only make the change to the db every X minutes and would only use one column for all CommentIDs and would always show the first one.

    I have also concluded that it must be a special comment by user in the discussion to handle it. With the possibility for user to change the text at any time.

    But I would like to make a few changes in the data model.

    I have reviewed the DiscussionModel class and I think I could sort comments by the DateLastComment column.
    On the table Discussion update DateLastComment and LastCommentUserID
    Table Comment new column indicating that this message is advert and make update of DateInserted
    Discussion.DateLastComment = Comment.DateInserted

    Would be able to sort comments in the discussion by DateLastComment and it will work?
    What do you think about this?

    And have a check "This comment is an advertisement" when writing a comment is an excellent idea !

  • R_JR_J Ex-Fanboy Munich Admin

    @steam said:
    I have also concluded that it must be a special comment by user in the discussion to handle it. With the possibility for user to change the text at any time.

    Everything "special" is a) extra work for you and b) might need extra explanation for the user. That's why I would avoid it.
    You can make each comment editable, but I wouldn't do so at all. If there will be a new text needed, it is a new advert and seeing the last one makes it comparable.
    If the adverts are shown exclusively, there is no need to "cheat" by editing older comments.

    I do not know how adverts work on your forum and where they are placed and what the intention of your users are, but I guess it could make sense to accept only one advert per discussion per user.

    @steam said:
    But I would like to make a few changes in the data model.

    I have reviewed the DiscussionModel class and I think I could sort comments by the DateLastComment column.
    On the table Discussion update DateLastComment and LastCommentUserID
    Table Comment new column indicating that this message is advert and make update of DateInserted
    Discussion.DateLastComment = Comment.DateInserted

    Would be able to sort comments in the discussion by DateLastComment and it will work?
    What do you think about this?

    You wouldn't have to look at DiscussionModel but at CommentModels method get().
    As you will see, there is no way to take influence on the sort order. You get $limit comments starting from $offset.
    You would be able to take influence on what you get from that query by utilizing the AfterGet event.

    That's why your plan might be okay for discussions with one page of comments, but when a discussion has more than $limit comments, you will not be able to ge your plan working.
    The only solution to that would be to let get() do its query and afterwards make simulate exactly the same query but with your order criteria. But that would make 2 queries instead of one per page view. Not very clever.

    And only because some of your users are not disciplined... I would say that your problem is not the sort order of the comments, but your users behavior. Simply delete their duplicate posts and/or ban them.

  • steamsteam www.planamigo.org - #1 foro planes amigo
    edited September 2016

    ...

    That's why your plan might be okay for discussions with one page of comments, but when a discussion has more than $limit comments, you will not be able to ge your plan working.
    The only solution to that would be to let get() do its query and afterwards make simulate exactly the same query but with your order criteria. But that would make 2 queries instead of one per page view. Not very clever.

    And only because some of your users are not disciplined... I would say that your problem is not the sort order of the comments, but your users behavior. Simply delete their duplicate posts and/or ban them.

    @R_J many thanks for the information and given help I will think about all this.

    Before doing method update comment I thought of a very simple solution.

    Instead of advert comment update is to do delete it and then insert it with the same text as a new by the plugin.

    But this will greatly increase comments ids.

  • R_JR_J Ex-Fanboy Munich Admin

    Don't care for IDs, they are just numbers. The maximum number you can use is 2,147,483,647 (if not 4,294,967,295, I'm not sure), so I don't think that will ever be a problem for you ;-)

    I must say that deleting and re-inserting the comment is the most cleanest solution.

    Do you have a link to a discussion with multiple comments? I'm still deeply convinced that you are trying to solve the wrong problem.

  • RiverRiver MVP
    edited September 2016

    You need to change the behavior of the users and enforce it. Anything else is pretty silly.

    Every wonder why the plugin never got updated, because it is a bad idea to change the sort order.
    https://vanillaforums.org/discussion/19950/would-like-to-know-if-anyone-got-this-working

    if you play the deletion -insertion game any links to the deleted comment will be "not found" and just an overall bad idea.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    Do you have a link to a discussion with multiple comments? I'm still deeply convinced that you are trying to solve the wrong problem.

    First I want to say it is a Spanish forum discounts and promotions to invite others. There are companies with which you have a hired service (car insurance, adsl, telephone, bank ...) the company give you discount code to invite your friends.

    for example, this thread offers cars insurance Verti company - http://www.planamigo.org/discussion/17/codigos-nuevos-plan-amigo-verti-seguros#latest

    When someone does post a message I get email notice and I try to see and clean duplication. But I think this is not a solution. I have also warned some users for its bad practice to duplicate messages.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    @River dijo:
    You need to change the behavior of the users and enforce it. Anything else is pretty silly.

    Yes, I agree with you. I'm looking for the best solution.

  • R_JR_J Ex-Fanboy Munich Admin

    Maybe a restriction to be able to only write one comment per discussion could solve that problem. Is there a real need for them to post more than one time in each discussion?


    Since your forum doesn't seem to be a place for discussions, but more for offers, you can make quite heavy changes: you could change simple textarea comments into an offer form:
    Field1: Short description (this would be the normal comment body, but with a rigid length restriction
    Field2: Code (new column) (short string)
    Field3: Value (new column) (very! short string)
    If appropriate:
    Field4: Link

    Then you would have to tweak the comment view a little bit, set an insanely high limit for Vanilla.Comments.PerPage and it could be more like a list. e.g.

    =)Someone Code: 1a2b3c4d Value: up to 150 EUR Link to homepage more...
    B)Another Code: HH-GG-KK-JJJJ-HH Value: € 50 Link to homepage more...

    Clicking on "more..." would unhide the rest of the information normally shown in a comment.

    You also should prevent users from posting twice per discussion.


    In order to better track when your users are "spamming" by posting the same offer more than one time, you could write a plugin that a) would notify you if a user posts more than one time in a discussion or b) make the second comment of a user in a discussion require admin approval before it is published. That way you do not have to track all comments, but only the suspicious comments.

  • steamsteam www.planamigo.org - #1 foro planes amigo

    Interesting point of view...

    Whether to limit the discussion for comments then have to make a special discussion to keep the native possibility of further discussions.

    I also I thought that each user could only make your offers on your profile page... But this will be difficult to control.

  • R_JR_J Ex-Fanboy Munich Admin
    edited September 2016

    @steam said:
    Interesting point of view...

    Whether to limit the discussion for comments then have to make a special discussion to keep the native possibility of further discussions.

    If you are able to write a plugin that restricts multiple comments from a user in a discussion, restricting that to only special categories/excluding special categories would be the easiest part ;)

    @steam said:
    I also I thought that each user could only make your offers on your profile page... But this will be difficult to control.

    You haven't succeeded stopping the spamming in discussions and now you dream of asking them to post not even one comment offer? :lol:

Sign In or Register to comment.