i want to realize the next algorithm using rules

if node have only one comment
if no comments added to this node since 1 month ago.
set this unique comment as bestreply.

but i can't found any reference to bestreply in rules.

any help?

Comments

taslett’s picture

Status: Active » Postponed

Hi kervi,
I don't know enough about rules and am not prepared to implement the rules api at the moment.
If you write the api integration I will add it to the module.

taslett’s picture

Status: Postponed » Closed (won't fix)
taslett’s picture

Issue summary: View changes

1

gladiatorhl2’s picture

It is a very good module and it deserves more attention than it actually has. I wanted to implement rules integration but it is quite hard to fully understand the code for me, because I am not a PHP programmer and I can program only something simple.

It would be great to get at least a rule integration ''best reply selected'' and ''best reply unselected'' like for Best Answer module (Answers) but it has 2 content types (Question and Answer) and it is its big weakness in my opinion, as certain rules cannot be put for two content types at the same time!

taslett’s picture

Ok I have added basic Rules integration, it should show up as a dev release with todays date shortly.
Test it out and let me know how it goes.

gladiatorhl2’s picture

I am so glad that it could be released! I am certain that other people will be happy, too. I tested it out and it goes quite well at the moment. If I find some bugs, I will post comments. Is it possible to donate, if you do not mind?

taslett’s picture

Hi gladiatorhl2,
Glad you find it useful.
You can donate via paypal to: tony [AT] appcreator.com

gladiatorhl2’s picture

Issue summary: View changes

Hello,
I have noticed a problem. If somebody clicks ''Best reply'' several times, rules are also executed several times. For example, one rule was done that after clicking ''Best reply'', a private message is sent. If ''Best reply'' is clicked several times, several messages are sent.

taslett’s picture

Hi gladiatorhl2,
Is there a way to restrict that via the rule?

Not really sure how to do this in code but can look into it.
Do you only want it sent the first time Best Reply is clicked?

gladiatorhl2’s picture

Hi taslett,

I was searching this functionality in rules and it seems that there is no any rule which could restrict a repeated execution of rules (at least that they will continue to function after that action).

I will try to describe a problem in detail. ''Best Reply'' button is changed into ''Clear Best Reply'' after clicking it and it is good. Of course, it takes time to see this change. During this action if somebody rapidly clicks this button several times, rules are also executed several times. I suppose that it means that there must be a restriction which prevents the second and following clicks while rules are executed.

I confirm that I would like a message to be sent only the first time. I guess that the problem could be similar to this one https://drupal.org/node/69048

gladiatorhl2’s picture

Hello taslett,

I was searching some information about it. I don't know how to fix it. I understand that after clicking ''Best Reply'', a page must be reloaded manually to avoid a repeated execution of rules. Is there a way to reload it automatically?

gladiatorhl2’s picture

Maybe it is impossible to refresh a page that an author would view it immediately through his browser. At this moment I might understand that the second click of ''Best Reply'' must be prevented somehow and only for this node, not for others.

taslett’s picture

Hi gladiatorhl2,
I have been pretty busy and haven't had much of a chance to look into this.

Currently it uses ajax to apply the changes such as best reply.
If JavaScript is disabled it will reload the page. So if you want to test out the issue and see if reloading helps then disable JavaScript in your browser.
If that works I can add a new setting to reload the page or disable JavaScript.

gladiatorhl2’s picture

Hi taslett,
After trying this option, the problem persists to be there. If ''Best Reply'' is clicked three times, three messages are still received. In addition, there is no moved ''Best Reply'' to top. In order to see it, JavaScript must be enabled. Maybe all that happens because there is also an error (I removed a part of the path to the file):

Notice: Trying to get property of non-object in function _bestreply_remove_upoints() (string 487 in file ...\sites\all\modules\bestreply\bestreply.module).

Could you propose any directions? Thank you in advance.

taslett’s picture

Hi gladiatorhl2,
I'll look at where the rule is invoked and see if I can restrict it to once.

taslett’s picture

Hi gladiatorhl2,
The latest dev branch should fix the issue.
A user shouldn't be able to keep clicking to trigger the rule now.
Test it out and let me know how it goes.

gladiatorhl2’s picture

Hi taslett,
I have just read your response and tested the module. If JavaScript is on, it works fine, I think. Thank you very much.

I have noticed only two minor errors.

1) If a rule ''Show a message on the site'' is triggered by clicking ''Best Reply'', it does not appear and Best Reply comment doesn't move to top automatically. I suppose that they are related to the same minor problem. The entire page must be reloaded entirely. I wanted to show a message on the site ''Refresh the page in your browser'' but it doesn't appear, so a user can't see the moved Best Reply to top and he does not know exactly what he is supposed to do (especially a new visitor).

If we see the refreshed page with moved Best Reply comment to top and this time if ''Clear Best Reply'' is clicked, Best Reply comment disappears automatically. It works fine. If it worked like that after clicking ''Best Reply'', it would be perfect.

2) After clicking ''Best Reply'', a line ''Clear Best Reply'' appears. I think that ''Best Reply'' rests there and only ''Clear'' is forced to appear before ''Best Reply'' to complete the whole phrase ''Clear Best Reply'', so for some languages it is almost impossible to choose proper words so that they would be coherent to each other. The page must be refreshed to see the whole translated phrase ''Clear Best Reply'', not ''Clear'' + ''Best Reply''.

I am sorry that I have written such a long text. English is not my mother tongue :)
Thank you in advance for any suggestions.

gladiatorhl2’s picture

Hi taslett,
I think that I have fixed this issue :) I was searching quite a lot through the Internet and it was eventually quite easy to refresh the whole page. I do not know exactly, if it is needed to be included in the developed version of the module, because it is not so critical.

Thank you for this module. Probably I will contribute again in some time when I will launch my website :). It is a very long way for me.

Powergird’s picture

I have meet the same erro "Notice: Trying to get property of non-object in function _bestreply_remove_upoints() (string 487 in file ...\sites\all\modules\bestreply\bestreply.module)."

by using latest dev branch。
any help ,thanks much.

gladiatorhl2’s picture

I suppose that you can comment these lines. I did it and the module functions well so far.