Rules integration: rules event when submitting feedback

pvhee - June 15, 2009 - 11:55
Project:Feedback 2.0
Version:6.x-2.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs work
Description

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.

AttachmentSize
feedback_rules_patch.tgz787 bytes

#1

pvhee - June 15, 2009 - 11:57

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

#2

pescetti - June 15, 2009 - 13:24

subscribing

#3

sethcohn - June 16, 2009 - 04:05

+1

#4

pvhee - June 16, 2009 - 09:47
Status:active» needs review

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.

AttachmentSize
feedback_rules_patch_2.tgz 851 bytes

#5

pvhee - June 23, 2009 - 11:44

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

#6

ayalon - August 6, 2009 - 17:50

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)

#7

sun - August 7, 2009 - 04:44
Status:needs review» needs work

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

#8

pvhee - August 7, 2009 - 12:54

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.

AttachmentSize
feedback-492094.patch 1.76 KB

#9

sun - August 7, 2009 - 17:17

+++ 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.

#10

pvhee - August 8, 2009 - 17:41

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'".

AttachmentSize
feedback-492094.patch 1.77 KB

#11

kyle_mathews - September 2, 2009 - 18:06

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.

#12

SocialNicheGuru - October 3, 2009 - 12:59

subscribing

#13

Summit - November 7, 2009 - 10:54

Subscribing, greetings, Martijn

 
 

Drupal is a registered trademark of Dries Buytaert.