Right now it's either yellow or check box activated "error message."

Green is beautiful for nice messages.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mitchell’s picture

Issue tags: +Newbie

I need to learn to code someday.

amitaibu’s picture

Status: Active » Closed (works as designed)

1) The color is determined by your theme. If you'll use Garland you will see it in green - Rule is using drupal_set_message() here.
2) Grab the Pro Drupal book - that's how I learned programing :)

mitchell’s picture

Title: Add green option to "Show a configurable message on the site" » Clarify options for "Show a configurable message on the site" action
Status: Closed (works as designed) » Active

@Amitaibu: Two ideas: what about helping the user set a configurable color with color module, or providing a clearer way to choose between showing as a "status message" / "messages error" / ""custom message""?

Right now, we have a poor way to help the user select a message type (it unpredictably defaults to green or yellow; or a single choice to set as a red "error message." These options are very limited, imo.

mitchell’s picture

Title: Clarify options for "Show a configurable message on the site" action » Improve options for "Show a configurable message on the site" action
amitaibu’s picture

http://api.drupal.org/api/function/drupal_set_message/6

Dealing with color is just not correct - this is done via CSS. Rules simply sending a through a core function a message to the user. So I don't think Rules should change it's behavior.

mitchell’s picture

Considering the API says

The type of the message. One of the following values are possible:

* 'status'
* 'warning'
* 'error'

Wouldn't this be a better way to set up the UI?

amitaibu’s picture

Ok you convinced me, go a head - code it :)

fago’s picture

+1, however you need to make sure existing settings stay working - so best don't change the format of $settings.

bveb’s picture

It is possible to add option for clearing messages on session object.

mitchell’s picture

Component: Rules Engine » User interface
Priority: Normal » Minor
shushu’s picture

FileSize
1.06 KB

I needed such a feature, and even more - the need to be able to clean existing messages and show "mine".

I think these features should get into the module, but meanwhile I created a new module called "Better Rules Message", which has the following features:

Comments are welcome,
Regards,
Shushu

shushu’s picture

Priority: Minor » Normal
Status: Active » Needs review
shushu’s picture

FileSize
1.07 KB

Another version - with use of filter_xss() over the message, and proper textarea instead of the textfield.

YK85’s picture

hey shushu!

would you be able to provide the new feature also in a patch form to be reviewed?
when a final version of your new feature is tested, then it can easily be set to RTBC and possibly added to the Rules module

thanks for the great work!

fago’s picture

Status: Needs review » Needs work

Please only set status to needs review when you rolled a real patch, see this.

Also for new features like this it's best to make sure they are in 7.x-2.x first. There we could easily convert the boolean to a string argument supporting all possible options as we don't have to directly support existing configurations - those just need to have a valid upgrade path later on.

If someone wants to give this a shot for 7.x-2.x, I'm here to provide guidance/reviews.

shushu’s picture

Thanks for the feedback.
Sorry, but I don't have the time right now to create a proper patch, nor to make it "7 ready".

shushu’s picture

Status: Needs work » Needs review
FileSize
4.49 KB

Attached starting patch ontop of DRUPAL-6--1.
Comments are welcome.
What about the upgrading ?
I guess this is something to be thought about.

Status: Needs review » Needs work

The last submitted patch, rules-409090.patch, failed testing.

shushu’s picture

Status: Needs work » Needs review
FileSize
4.59 KB

Another try, hopefully now with the right -p flags...

fago’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Active

I don't think a 'rules_action_drupal_clean_message' action is often needed, so it doesn't make much sense to me to add it to Rules (feel free to add it to another module though). Also the patch violates the coding style.

Improving the message action is fine to me, but let's do it for 7.x first as this is where new features currently go. Afterwards we can look at backporting it to 6.x.

shushu’s picture

Hi fago,

The cleanning action is useful since this is the only way to "manipulate" messages given by other modules.
I had several scenarios in which I just wanted to avoid from showing the user messages created by other modules.

Those modules weren't flexible and forced their messages (not configurable), but on the other hand they were needed.
"Hacking" those modules just to avoid the messages seems unreasonable.

Anyway, if you still don't like it, I will create a different module for it.
Sorry for the coding standards. I will use Coder to wipe them out.

Regarding to implementing on 7.x - I guess it is time for me to jump on this wagon...

shushu’s picture

Hi again,

Got Drupal 7 Rules installed, and went directly to implement the enhanced drupal_set_message action.

After a while I understood it is a bit more complicated than it was in Drupal 6.

Is there an updated documentation for Rules in Drupal 7 ?
For example, I was trying to figure out how to create a select field for an action, using "list".

Please direct me to the right documentation, or just code examples.

Shushu

fago’s picture

You need to define a 'options list' callback that returns a suiting $options array. E.g. see how the user_add_role action does it. Then Rules automatically generates the right form - usually one does not need to write the settings form in Rules 2.x - even there is only a actionbase_form_alter(). Just put the callback in system.rules.inc.

@docs:
As of now there is only the doxygen shipping with the module: rules.api.php.

shushu’s picture

Thanks.

I was able to immitate the need for the callback, I was just surprised the callback need to be executed both in the configuration of the rule and in the execution of it, but after following the rules_action_user_add_role() example it clarifies the issue.

Hope to quickly make this patch working.

shushu’s picture

FileSize
4.12 KB

First patch for 7.
I am not certain it is 100% according to the new API, but I tried to do my best.
Passed Coder module.

Comments are welcome.

shushu’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, rules-409090.patch, failed testing.

fago’s picture

+++ rules/modules/system.eval.inc	15 Jul 2010 14:02:41 -0000
@@ -12,8 +12,27 @@
+function rules_action_drupal_message($message, $type, $other, $clean) {
+  rules_action_clean_messages($clean, $type, $other);
+  if ($type == 'other') {
+    $type = $other;
+  }
+  drupal_set_message(filter_xss($message), $type);

drupal_set_message() has no support for $other, thus we shouldn't add that. No hacks in Rules please ;)

Calling filter_css() seems to make sense here.

+++ rules/modules/system.eval.inc	15 Jul 2010 14:02:41 -0000
@@ -12,8 +12,27 @@
+function rules_action_clean_messages($clean, $type, $other) {

Cleaning messages is also rather hacky and not often needed anyway. So I don't want to have that action in Rules, but feel free to provide in a contributed module.

+++ rules/modules/system.rules.inc	15 Jul 2010 14:02:41 -0000
@@ -104,19 +104,53 @@ function rules_system_action_info() {
+          'type' => 'text', ¶
+          'label' => t('Message type'), ¶

Trailing whitespaces.

+++ rules/modules/system.rules.inc	15 Jul 2010 14:02:41 -0000
@@ -104,19 +104,53 @@ function rules_system_action_info() {
+          'description' => t('The message type.'),

Provide a better description or leave it empty.

+++ rules/modules/system.rules.inc	15 Jul 2010 14:02:41 -0000
@@ -104,19 +104,53 @@ function rules_system_action_info() {
+        'clean' => array(
+          'type' => 'integer',
+          'label' => t('Clean messages'), ¶
+          'options list' => 'drupal_set_message_clean_options',
+          'description' => t('Should we clean messages ?'),

This should go. But d7 has a new 'repeat' parameter for dsm - adding that would make much sense.

+++ rules/modules/system.rules.inc	15 Jul 2010 14:02:41 -0000
@@ -166,6 +200,25 @@ function rules_system_evaluator_info() {
+function drupal_set_message_message_types() {
+  return array(
+               'status' => t('Status'),
+               'warning' => t('Warning'),
+               'error' => t('Error'),
+               'other' => t('Other'),
+  );
+}

The function name isn't prefixed right. Also the indentation of the array is wrong - it should be 2 spaces. And other is no valid type, thus needs to be removed.

Powered by Dreditor.

shushu’s picture

First time to get into the testing of Drupal 7.
It looks amazing !
And - made me write better code...

shushu’s picture

filter_xss breaks several tests that uses drupal_message action.

What should be the right way to solve this ? Wrap the arguments of the assertions with filter_xss as well ?

fago’s picture

I think in this case we can use filter_xss_admin(). If there are still problems with that, yes just add it to the assertion too.

shushu’s picture

I added it to the assertion, and still got failues.
Printing out the values from the action and from the origin (after the filter_xss) still shows differences such as or italic in one and not in the other.

I guess somewhere in the process it is being manipulated even more.
Hope to find more time to debug it properly.

fago’s picture

Status: Needs work » Fixed

I implemented that with filter_xss_admin().

Status: Fixed » Closed (fixed)

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

YK85’s picture

Will this improvement be added to 6.x or already added as per comment in #20?

Thanks

shushu’s picture

For 6.x I recommend on using the separated module I created http://drupal.org/project/rules_better_message.

Comments are welcome,
Shushu

mitchell’s picture

Version: 7.x-2.x-dev » 6.x-1.x-dev
Component: User interface » Rules Core
Status: Closed (fixed) » Patch (to be ported)

filter_xss and message types weren't backported, but a separate module for this action is unnecessary and confusing. Therefore, we need to revisit this issue.

#19 & Rules Better Message are what needs review/work. The only other difference I found with Rules Better Message was an 'other' message type, but I think it would be best to address that in a separate issue.

TheDanScott’s picture

Hi all,

I'm a little confused. I've been using the (very useful) Rules Better Messaging on a customer site - because I wanted the option to suppress some of the built-in messages that come out of drupal, replacing them with my own confirmation message.

The maintainer of that module ("shushu") has - on request from the rules team - flagged his own module as obsolete.

I've updated to the latest Rules for drupal 6 (6.x-1.5) and I cannot find equivalent functionality to his module in Rules.

It seems most of the discussion here has centered around the option of an "other" message type. I personally have no use for an "other" message type, and am quite happy with being able to choose from error, warning or status.

However, the function that is missing in Rules - and in my opinion is critical - is the option to "Clean messages:". In Rules Better Messaging the available options for this setting are:

  • Do not clean
  • Clean all
  • Clean selected type

These make a lot of sense to me - and I think it would be great to see those options in the inbuilt "Show a configurable message on the site" action.

Rules Better Messaging also provides a simple standalone "Clean Messages" action (again with the option to limit the purge to messages of a particular type) - which I think is also quite useful.

mitchell’s picture

TheSchmuck, you've made such a clear point.

I thought by trying to move attention to this issue, we would soon have the more perfect solution of this being built-into Rules.

I think 'obsolete' may have been a limited description, especially as the functionality currently resides there and works well.

I only wish Rules was more actively developed, such that functionality like this was quickly available on the 6.x and 7.x branches.

TR’s picture

Issue summary: View changes
Status: Patch (to be ported) » Closed (won't fix)

This was fixed in Rules 7.x-2.x and marked for backport to Drupal 6. But Drupal 6 is no longer supported, so this will not be backported at this point.