This is related to #353548, but focuses on the contrib module rules instead of the core triggers/actions.

Attached in the .tgz are two files:

  • patch for feedback.module, which invokes a rules event ("feedback_add_entry") when new feedback is added. For now, only the user providing the feedback is passed on, but I am working on passing the message, the location and all other relevant data as well.
  • file 'feedback.rules.inc', which defines the feedback event. This allows the rules module to use this event.

You can now easily send out emails whenever new feedback is added, or any other action provided by rules or contrib modules, using the entire $user variable.

Would there be a possibility to add this patch to the rules module? If so, I will elaborate on the implementation in feedback.rules.inc, providing more data for conditions and triggers.

Comments

pvhee’s picture

I forgot the [ ] around the issue I refered to, here it is: #353548: Add trigger/action for e-mail notification

pescetti’s picture

subscribing

sethcohn’s picture

+1

pvhee’s picture

Status: Active » Needs review
StatusFileSize
new851 bytes

Here is a new patch, passing the feedback message and location as arguments in the event (as rules strings). Now you can use those in your actions/conditions, eg to send out email with the actual message and the location it was submitted at.

Coding conventions of the patch have been checked as well, and I've successfully tested it already on multiple sites.

pvhee’s picture

Any feedback on this? Could this be included in the latest dev? Thanks!

ayalon’s picture

Cool patch. I implemented it in my own feedback module and it works quite well! Thanks! (PS: Maybe is posting text files more convinient for admins to check your patch)

sun’s picture

Status: Needs review » Needs work

Could you please provide a proper patch? See http://drupal.org/patch for further information.

pvhee’s picture

StatusFileSize
new1.76 KB

Attached is a proper patch.

I now pass the following variables to the rule: user, feedback message, feedback location, masked path location and the HTTP_USER_AGENT.

sun’s picture

+++ feedbackNew/feedback.module	2009-08-07 14:51:48.000000000 +0200
@@ -142,6 +142,12 @@ function feedback_form() {
+  
...
+    global $user;    
...
+  

Trailing white-space here.

+++ feedbackNew/feedback.rules.inc	2009-08-07 14:51:48.000000000 +0200
@@ -0,0 +1,24 @@
+ * @file rules integration for the feedback module

"@file" should be on an own line, "Rules integration..." right below it. Also note proper capitalization for "Rules" and "Feedback". And there should be a trailing period (full-stop).

+++ feedbackNew/feedback.rules.inc	2009-08-07 14:51:48.000000000 +0200
@@ -0,0 +1,24 @@
+      'label' => t('User gives feedback'),

I think we should label this event "Feedback is submitted" - or - any better suggestions welcome.

+++ feedbackNew/feedback.rules.inc	2009-08-07 14:51:48.000000000 +0200
@@ -0,0 +1,24 @@
+      'module' => 'Feedback',

Shouldn't this be lower-case? (sorry, I'm not very familiar with Rules)

+++ feedbackNew/feedback.rules.inc	2009-08-07 14:51:48.000000000 +0200
@@ -0,0 +1,24 @@
+        'feedback' => array('type' => 'string', 'label' => t('feedback message')),
+        'location' => array('type' => 'string', 'label' => t('feedback location')),
+        'location_masked' => array('type' => 'string', 'label' => t('feedback location masked')),
+        'useragent' => array('type' => 'string', 'label' => t('user agent')),

I think the key should be "message" instead of "feedback".

Also, all labels should be properly capitalized, i.e. "Feedback message".

"Feedback location masked" we should change to "Feedback location (masked)".

Beer-o-mania starts in 24 days! Don't drink and patch.

pvhee’s picture

StatusFileSize
new1.77 KB

Thanks for reviewing the patch. I've changed the patch to accommodate to your comments. I haven't changed the capitalization in all cases though, as I'm following the standards set by Rules. Example:

'feedback' => array('type' => 'string', 'label' => t('feedback message')),

Should be "feedback message" instead of "Feedback message". Same for "'module' => 'Feedback'".

kyle_mathews’s picture

I applied the patch -- and it almost works. I can create a rule but the tokens are all wrong except for acting user. The other token patterns only show generic global tokens. For example, there's no token to place the feedback message in the email.

I don't really know enough about rules to be much help beyond that.

socialnicheguru’s picture

Can I use Rules to copy the feedback message and other information to Case Tracker? has anyone tried this?

summit’s picture

Subscribing, greetings, Martijn

awolfey’s picture

With the last patch the message results are available as php variables, but not tokens.

ensnaregod’s picture

so how would someone go about utilizing the php variables in the triggered rule email?

joostvdl’s picture

+1

snorkers’s picture

I added the patch at #10 (thanks @pvhee) and works with 6.x-2.1. It's functional although I don't seem to have many of the tokens working yet - as also mentioned in this thread. The exposed PHP variables do the job, but the tokens issue is a bar to incorporating this into the module.

I think once the tokens become a little more usable, this functionality should be included into the module.

andrewcheetham’s picture

+1

socialnicheguru’s picture

I can't seem to find the entry in rules for feedback.

1. Is feedback.rules.inc supposed to be in it's own directory called "feedback"? After I apply the patch, the path is feedback > feedback > feedback.rules.inc

2. I do not see feedback anywhere in rules section. I created a rule and looked under "condition to add" and "action to add" and I do not see a reference to feedback rules.

any help would be greatly appreciated.

jody lynn’s picture

Version: 6.x-2.0 » 7.x-2.x-dev
Status: Needs work » Postponed

Rules integration will be simple to add once the entity integration is added: #351698: Use entities for Feedback messages

chien_fu’s picture

Version: 7.x-2.x-dev » 6.x-2.1

Is this still being addressed for D6? This seems like a critical feature.
Thanks, subscribing.

jody lynn’s picture

Version: 6.x-2.1 » 7.x-2.x-dev

New features go in the 7 branch, and once there we can consider a backport.

jody lynn’s picture

Status: Postponed » Active

#351698: Use entities for Feedback messages has landed, so time to add this

rkarajgi’s picture

I am using - feedback-6.x-2.2 - it is great. It makes it a very good user experience for the site.

Right now, when a user submits feedback - one can see the msg in admin/reports. I am trying to use the Rules such that it sends out a email. I did not find any feedback related event in rules.

The patch in #10 seems to be for feedback-6.x-2.1. Has anyone tried it on 6.x.2.2?

Thanks

jeremdow’s picture

Status: Active » Needs review
StatusFileSize
new4.49 KB

New patch against 7.x-2.x HEAD - also adds token support for send mail actions.

Please review - working fine for me.

dagomar’s picture

Hi __rajeev

the patch works.

jeremdow’s picture

Anyone have a chance to review my patch for 7?

sun’s picture

Status: Needs review » Needs work
+++ b/feedback.info
@@ -4,4 +4,6 @@ package = Development
+files[] = feedback.rules.inc
+files[] = feedback.tokens.inc

Doesn't seem to be needed, as they don't seem to contain classes.

+++ b/feedback.rules.inc
@@ -0,0 +1,41 @@
+    'group' => t('feedback'),

Shouldn't this be properly capitalized?

+++ b/feedback.rules.inc
@@ -0,0 +1,41 @@
+      'variables' => array(
+        'feedback' => array('type' => 'feedback', 'label' => t('created feedback')),
+      ),

1) Shouldn't the label be "Feedback message" ?

2) Isn't this variable the same for all possible events?

+++ b/feedback.rules.inc
@@ -0,0 +1,41 @@
+ * Comment integration access callback.

Comment?

+++ b/feedback.tokens.inc
@@ -0,0 +1,88 @@
+  $type = array(
+    'name' => t('Feedback'),
+    'description' => t('Tokens for feedback posted on the site.'),
+    'needs-data' => 'feedback',
+  );
...
+  return array(
+    'types' => array('feedback' => $type),
+    'tokens' => array(
+      'feedback' => $feedback,
+    ),
+  );

That's a very weird way to define an array. I'd suggest to build a $types array and a separate $tokens array and return those two arrays in 'types' and 'tokens'.

+++ b/feedback.tokens.inc
@@ -0,0 +1,88 @@
+  ¶
...
+  } ¶
+  ¶

Trailing white-space.

+++ b/feedback.tokens.inc
@@ -0,0 +1,88 @@
+  $sanitize = !empty($options['sanitize']);

This needs to be used for the token replacements.

+++ b/feedback.tokens.inc
@@ -0,0 +1,88 @@
+        case 'uid':
+          $replacements[$original] = $feedback->uid;
+          break;

This should actually be resolved into feedback:author:*

+++ b/feedback.tokens.inc
@@ -0,0 +1,88 @@
+        case 'location_masked':
+          $replacements[$original] = $feedback->location_masked;
+          break;

I don't think that this token is useful in anyway.

adamgerthel’s picture

We've used the patch from #25 for a couple of weeks now with no hickups. Seems to be working as intended

SebCorbin’s picture

Status: Needs work » Needs review
StatusFileSize
new21 KB

Patch as per #28

SebCorbin’s picture

StatusFileSize
new2.64 KB

Bad PHPStorm, bad!

SebCorbin’s picture

StatusFileSize
new4.62 KB

Bad developer... (forgive me for spamming, need to get sleep)

Joseph_Fowler’s picture

We are using the patch from #25. Does the job well. Would be great if this could be added to the module.

jody lynn’s picture

Status: Needs review » Needs work

Confirmed the patch in #32 addressed the notes in #28.

Now that feedback entries can be edited. This should be expanded to have a trigger on updating as well as inserting. Possibly on deleting as well.

parasolx’s picture

Status: Needs work » Reviewed & tested by the community

Confirmed patch #33 worked without any problem.

jody lynn’s picture

Status: Reviewed & tested by the community » Needs work

Needs work for issues in #34

javier.drupal.2012’s picture

I made the chenge and it is working like a charm. Thanks for your work

Would be awesome to commit the patch in the last version

Thanks heaps

javiersalado’s picture

Category: feature » support

Hello there,

I applied the patch successfully but when Adding a new rule I can't se the Feedback event as defined in the feedback.rules.inc so basically is not working for me.

Am I missing something? I have flushed caches and reset and restarted anything that came to my mind...

Thanks,
J.

jody lynn’s picture

Category: support » feature

Please do not change the status of an issue in progress.

We can't provide support to development patches.

jaydee1818’s picture

This works for me to a point.

If I create a rule that sends an email, it works if I put random text in the mail body.

However, if I want the actual feedback to be sent and I enter:

echo $feedback;

in the mail body, I am returned the following error message:

An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /system/ajax
StatusText: Service unavailable (with message)
ResponseText: Recoverable fatal error: Object of class stdClass could not be converted to string in eval() (line 1 of ../sites/all/modules/rules/modules/php.eval.inc(125) : eval()'d code).

jaydee1818’s picture

Actually, figured it out:

print $feedback->message;

BrockBoland’s picture

Issue summary: View changes
StatusFileSize
new4.86 KB

Added an update event to the Rules config.

This still needs some tweaking to make it more useful, though. If feedback implements hook_entity_property_info(), it can provide additional information via Entity API that can then be used…I think.

For example, I want to define a Rule that will act only when an existing Feedback entity is updated and the status is set to Processed. Right now, the status property is not available through the data selector in the Rules interface, because Rules doesn't know about it.

I'm going to take a stab at this.

BrockBoland’s picture

StatusFileSize
new4.56 KB

This is only a slight change from 42. Rather than sticking the rules_invoke_event() call into the form submit handlers (booo), I implemented hook_feedback_insert() and hook_feedback_update(), since both of these are invoked from feedback_save(). This way, the rule will fire regardless of where the Feedback is changed or created from (for example, if a custom module programmatically creates or modifies feedback).

BrockBoland’s picture

Status: Needs work » Needs review
StatusFileSize
new5.98 KB
new2.98 KB

This patch adds two things from the last one:

  1. Properties for status, author, message, and timestamp, which can now be used in the data selector.
  2. Added a feedback_unchanged variable that can also be used in the data selector, to check for changes (eg: check if the status is 1 now, but was not before).

I also included an interdiff from the last patch on comment 32, to show all of my changes and updates together.

bendev’s picture

Thanks for your useful patch.

I tested the author and timestamp sucessfully

kmajzlik’s picture

#44 works well but fid (feedback id) token should be also added.

paulap’s picture

Category: Feature request » Bug report

Hi! Works well. thx

But instead of the author i get "Array" (i use [feedback:author]).

kmajzlik’s picture

I think it is ok, try to use [feedback:author:mail]

paulap’s picture

hi karlos007!

thx for your response #48.

But this doesn't work too. I tried [feedback:author:mail] and [feedback:author:name]. But it shows always "Array" as the placeholder/token value.

kmajzlik’s picture

paulap: sorry, ma fault. I took it only from my head and wrong. So i took a look in existing rule:
So final solution:
1) add action: Fetch entity by property, type = user, value = user id, data selector = feedback:author:uid, entity name = author
2) address is available in next action as [author:0:mail] (note: author means a name of variable from step 1)

so as i look you can also first try token [feedback:author:0:mail]

paulap’s picture

Thx karlos007!

It works perfect...

jody lynn’s picture

StatusFileSize
new3.47 KB

I added fid as one of the properties. (I use that to construct a link to the feedback view page)

aron novak’s picture

Status: Needs review » Reviewed & tested by the community

It seems the patch is stable, I tested with a real rule, the fields are available in Rules, it seems it's ready to go.

  • Jody Lynn committed 36b256f on 7.x-2.x
    Issue #492094 by pvhee, BrockBoland, SebCorbin, Jody Lynn, jeremdow:...
jody lynn’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mfb’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new2.68 KB

Part of this patch got lost along the way! The tokens part, which is pretty important :)

wylbur’s picture

The patch in #57 does bring back the tokens, but a number of them do not work.

I was able to fix the feedback url with this:
- $replacements[$original] = url($feedback->url, $url_options);
+ $replacements[$original] = url(drupal_get_path_alias($feedback->location), $url_options);

I was not able to get feedback:author to work, it just returns Array. Even using feedback:author:name does not work.

mparker17’s picture

Status: Needs review » Closed (outdated)

When I use the 3.x version of the Feedback module with Rules 4.0.1, I can create reaction rules on the event "After saving a new feedback message entity". Further, the 3.x version has good integration with the the ECA module as well (ECA is a popular alternative to the Rules module in 2026).

The Drupal 7 version of Feedback is no longer available, and no longer maintained. (If you'd like to maintain the Drupal 7 version, please post an issue in the queue)

So I'm going to close this issue as outdated.

Thanks in advance for your patience and understanding as I try to clean up this project's issue queue!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.