It would be nice if there would be a ability to use different arguments for sending alerts. Currently there are '#options' => array('all' => t('All users'), 'user' => t('The user who performed the action'), 1 => t('User 1')), defined in code :
<?php
//=============
//INTEGRATIONS.
//=============
/**
* Implementation of hook_rules_action_info().
*/
function appbar_rules_action_info() {
return array(
'appbar_action_set_message' => array(
'label' => t('Set an alert in the Application Toolbar'),
'module' => 'Application Toolbar',
'eval input' => array('message'),
),
);
}
/**
* Sets an alert from Rules.
*/
function appbar_action_set_message($settings) {
if ($settings['account'] == 'user') {
$settings['account'] = $GLOBALS['user']->uid;
}
appbar_set_message($settings['message'], 'misc', $settings['account']);
}
/**
* Configuration form for the Rules action to set an alert.
*/
function appbar_action_set_message_form($settings, &$form) {
$settings += array('message' => '', 'account' => 'user');
$form['settings']['message'] = array(
'#type' => 'textarea',
'#title' => t('Message'),
'#required' => TRUE,
'#rows' => 5,
'#default_value' => $settings['message'],
);
$form['settings']['account'] = array(
'#type' => 'select',
'#title' => t('Show message to'),
'#description' => t('The alert will be registered for the person or people specified above.'),
'#required' => TRUE,
'#default_value' => $settings['account'],
'#options' => array('all' => t('All users'), 'user' => t('The user who performed the action'), 1 => t('User 1')),
);
}
?>
So is there any way that it could be better integrated into rules, so you can use argument e.g. Loaded User, Loaded Comment ID, etc.
Comments
Comment #1
vertazzar commentedDifferent * title misstype
Comment #2
icecreamyou commentedCommitted to CVS
Comment #3
vertazzar commentedThank you for update, but I tested it and it sends the alert only to the one who did the action :
example
http://pokit.etf.ba/upload/?pokit4e668929edb3bf915e1a3a9d96c3c97e.png
http://pokit.etf.ba/upload/?pokitaa677d660eefd1fe0d323c1dc9bfa869.png
It only sends the alert if the targeted comments author is the one who did the action. So flagging other comment results no alert.
Maybe I'm doing something wrong hmm.
Comment #4
vertazzar commentedI can once again confirm that this doesn't work :/
I did all testing needed and all variations with rules.
Rules set
if comment is flagged under “XXX”
DO:
send alertAll of it works, but not send alert, it only works if the flagged comment author is a user who flagged it (the user who did that action (triggered rule)
Same goes for any other rule defined.
So its like if its set 'user' => t('The user who performed the action') in the select form that was before.
Comment #5
icecreamyou commentedNope, works for me. Make sure you're using the very latest development version and that you've upgraded correctly, including refreshing your caches (run update.php). You may need to reconstruct your rule from scratch as well.
Also, it sounds to me like you're getting the behavior you configured. Your rule is set up to set an Appbar alert for the author of the comment, so it makes complete sense that users would only see the alert that results from that rule if they flagged their own comment. If you want to set an alert for the person flagging the comment, you should either load the current user's object or type "user" in the box. (FWIW, the old 'user' setting [which works the same as typing "user" in the box now] does not behave like you described -- it would always set an alert for the person flagging the comment regardless of who authored that comment.)
Comment #6
vertazzar commentedDAMN you're right.
Rules cache :( and that's why it had no effect. Sorry for this. I didn't knew that rules have cache system. Now it works perfectly!
Thanks for this great module and your support !
Comment #7
vertazzar commentedBy the way, I wanted to send alert to owner of the comment - to notify the person that someone flagged its comment. For notifying the current user, I use standard drupal $messages.
The above comment that i wrote is because it worked first time, like i described in paragraph above, and i was happy cause of it because at last i found what i was looking for, but after some tests.. i was wrong with early happiness. Later in reading you'll see what i've encountered with.
I was testing this module for full 2 days and i discovered that it cannot give me what i want. That someone else gets alert if his content/comment was changed/flagged by someone else by some strange reason that I cannot understand. First time when you (user ID 1) flag someone else comment (user id 2's comment), user id 2 gets alert. But if user 3 ID flags a comment of User ID 2 the user 2 doesnt gets the alert...
How to fix it ?
DELETE FROM `cache_rules` WHERE (`cid`='set_event_flag_flagged_nameofyourFLAG')and after you deleted cache_rules record go with USER 3 ID and flag USER 2 ID comment and user 2 ID will get the alert and vice versa. So I think rules cache works really strange when using the [token] value in that textfield - im not php/drupal expert to know how all the code works altogether. If you use "user" in field, it works fine -- the current user gets alert in all variations. (user ID1, user ID3).
Like i said, I was testing this module yesterday and today from 14:00 to 22:00 and I got this conclusions. Also (not tested much but at first i suspected that was the problem) when you change the settings of appbar at admin/settings/appbar it breaks the rules-token integration completely leaving me incapable of solving the problem than uninstalling the module. But later, i uninstalled appbar and installed it again without touching the settings and I got same results of all the testing.
Maybe it works for you just fine because you didn't used it in environment where many modules are involved - maybe cause of that I have conflicts on my site, but nevertheless this module is lightweight and it doesn't contain code that would confuse others (as I noticed reading the logic of the module code).
Tomorrow ill test it on fresh drupal site using rules, token, flags, comments and appbar. If it gives me the same results as before i give up from this module.
Thanks again for responses and support.
Comment #8
icecreamyou commentedThat sounds like more of a Rules issue than an Appbar issue. If you continue having this problem I would open an issue in the Rules queue.
The only reason changing the Appbar settings would affect anything at all is that changing the Appbar style flushes Drupal's caches, but if anything that should have helped your problem.
Comment #9
vertazzar commentedDid testing with fresh drupal installation with flags, comments, userpoints, rules and appbar and still same.
You can also test it, just make
3 users
1 flag named rules_appbar_test
userpoints module
rules module
flag module
appbar module
devel (to switch between the users easily)
and insert this rule
When you do all the above, add few comments with different users
comment 1 = user 1
comment 2 = user 2
comment 3 = user 3
comment 1 flag with user 2
comment 2 flag with user 3
commnet 3 flag with user 2
And see for yourself what happens.
Personally, I don't think its problem with Rules because there are other similar modules that integrate with them and there are no issues of this nature.
For example you can see this one that is kinda similar with appbar, the "private message rules integration" at http://drupal.org/node/327938#comment-2190494
Comment #10
icecreamyou commentedI think it is a Rules issue because it doesn't happen with other kinds of rules. Appbar just provides an action, whereas Rules listens for events and processes the tokens. For example, if you repeat the experiment but use the Facebook-style Statuses module to set Appbar alerts for recipients of messages, there is no problem. Similarly, I suspect that if you set a rule to react to receipt of a private message, setting an alert for the recipient of the privatemsg would work as well. Appbar does absolutely nothing with the tokens, it just receives the pre-processed value that Rules passes to it. It's just with this flag/comment/rules/appbar combination that any problem shows up (although I haven't repeated your experiment yet to test it).
Comment #11
vertazzar commentedDon't understand than how it sends message when private message rules are configured. But never mind, It seems that I won't be in able to find where is the problem inside all that.
Comment #12
vertazzar commentedBTW - I also tested other types of rules, when there's node update, node delete, comment add and such.. It doesn't work.
So, the rules integration doesn't work at all :|, for me at least.
Comment #13
icecreamyou commentedWell, I can't reproduce that behavior, but I'm going to come back and improve all the Rules integration in a few weeks or so when I get some time. There's probably a simple explanation for your problem, but I don't have the slightest idea what it is.
Comment #14
vertazzar commentedI made the rules integration (custom module) without using the forms - I thought it will work than, but no.. still the same problem. The fact is that $sendmessage variable gives back results as it should, but the $user does not - always returns NULL which results that global $user is used.
Comment #15
icecreamyou commentedOnce again, this is not an appbar issue, it is a rules issue.