Rules Bonus Pack
This module is a greenhouse for Rules functionality – triggers, actions and conditions that could be included in the Rules module, but probably should be tested out and voted on first. Feel free to add your own ideas, opinions, examples and feature requests!
Note 1: I do not plan to make a stable release of this project. It is a greenhouse for building and trying out new functionality for Rules, and should always be open for new and untested ideas.
Note 2: The Views integration in this kind of broken. It will be rewritten, but that has not started yet. If you want to use Views to load entities into Rules, I recommend Views Bulk Operations. See the VBO chapter at http://dev.nodeone.se/node/984 for a tutorial on how to do this.
Installation
The usual. Download, enable. You will need the Rules module. (Surprise!)
README for D7 version
RULES BONUS: MISCELLANEOUS
==========================
Conditions
* Check number of results from a view: This condition loads a view and checks
the number of results – condition is passed if it is at least as many results
as you set. You can pass on arguments to the view.
Actions
* Load a node list with Views: This action executes a node view, along with any
defined arguments, and loads the result as Rules list. This allows executing
Rules loops on the results of a view. Yeah.
* Load a user list with Views: This works the same way as the previous action,
but acts on user views and returns a list of users.
* Load a comment list with Views: This works the same way as the previous
action, but acts on comment views and returns a list of comments.
* Set page title: This action sets the page title. The page title will be used
as $title in page.tpl.php. The action uses drupal_set_title to set the current
page title
* Set the active menu item: This action is A FIRST ATTEMPT at setting the active
menu item using Rules. It sets the active menu item in the sense that the menu
recognises it and show all children links. Currently it sets active-trail
class on the item chosen. Requires the Menu position module.
* Clone a node: This action clones a node and resets a few properties (such as
nid) before saving it. Useful if you want to clone a node, but make some
changes in the copy.
* Load the first node in a Views list: This action fetches the first node in a
node view (assuming there is at least one row of results). It is similar to
loading a node list with Views (see above), but is quicker if you are only
interested in getting the first hit. This is useful if you want to perform
more complex queries than "fetch entity by property" allows.
Events
* Allow Page manager variants to act as Rule even triggers: This introduces a
new setting on your Page manager variants – "Create a Rules event for this
variant" (found in the new tab "Reactions"). This makes your variant appear in
the list of Rules events, allowing you to execute Rules conditions and
conditions when variants are loaded. Not least: You also get the context
objects in the variant to work with.
Other
* All Rules condition components are exposed as CTools access plugins, for
example making them accessible in Page manager and Panels.
RULES BONUS: THEME
==================
Actions
* Set head title: This action sets the head title. This is the <title> element
in the HTML document. The action implements hook_preprocess_html to set the
head title
* Set body class: This adds classes to the <body> element. It can use available
substitutions. The outputted class is sanitized. The action implements
hook_preprocess_html to set additional body classes.
RULES BONUS: BLOCK
==================
Actions
* Place a block: This action lets you place a block in a region, and decide its
weight. Works on both blocks enabled by default (thereby moving them) and on
disabled blocks (thereby enabling them). All regions in all enabled themes are
available for selection.
* Disable a block: This action hides a block from view.
RULES BONUS: VIEWS
==================
Data types
* View display: This data type contains a number of properties.
- Read-only properties are machine name, human name, display (machine) name,
base table and total number of rows (assuming the view has been built).
- Writable properties are: argument values (list of text strings), current
page number, items per page and offset.
- View handlers are also available, but currently only supports reading of
alias names and the action 'unset a view handler' described below. Available
handlers are fields, contextual filters, sort criteria, filters,
relationships, headers, footers and no-result behaviours.
Events
* Before a view is being built: This event allows Rules to, for example, change
the arguments being sent to the view. You cannot, however, read the number of
results (since the view has not yet been executed).
* After a view has been built: This allows Rules to act whenever a view is going
to be rendered. Allows, for example, to check the number of results from a
view.
* After a view has been rendered: This is very similar to the previous event,
but also contains the actual output of the view.
Actions
* Unset a view handler: This allows removing a handler, such as a filter or
a field, based on its alias.
Other
* Rules components can be used as argument (contextual filter value) validators
in Views. To do this, create a Rules component that accepts a text string as
input ('parameter') – this is the filter value from Views. The component must
also output ('provide') one text string – the possibly altered filter value –
and one boolean – the TRUE/FALSE evaluation of the validation.
RULES BONUS: THINK TWICE
==================
This module contains experimental code for Rules. The module depends on bad
judgement. If you need to enable/disable a module through Rules you probably
have other problems to deal with.
Actions
* Enable a module
* Disable a module
README for D6 version
RULES BONUS: CCK
================
Conditions
* Field value is one of several: This condition checks if a field contains one
of several provided values. This could theoretically be done with Rules core,
but would require terrible nesting of and/or statements.
* Field has content: This condition utilizes the CCK field callbacks for
determining if the field is empty or not. Useful for checking if a complex
CCK field has content or not.
Actions
* Set a CCK field without validation: This gives you a plain old textfield to
enter data into CCK fields. That means that you won't be limited to
validations or form elements that the CCK widget provides. Please have a look
at http://drupal.org/node/1144404 if you'd like this functionality in Rules
core.
* Insert a value in a multiple-value field: This action adds a new value to a
multiple-value field, if it wasn't already present.
* Remove a value from a multiple-value field: This action kind of does the
opposite to the previously described action.
* Get a field value, bypassing Token: This action gets a field value, even if a
node hasn't been saved to the database yet. This is basically only for the
cases when you're working on the node presave event, which causes Token to
provide outdated content.
* Copy multiple field content between nodes: This action copies the content of
selected fields from one node to another (assuming the fields exist on the
target node). There are options for skipping empty fields when copying, and to
also copy node title.
* Copy entire field content between nodes: This takes the field content and
copies it into another field. Unlike other actions to set field content, this
works well with multiple-value fields as well (and it has no restrictions on
which field types to work with).
* Send e-mail to all users in a user reference field: This action mimics the
'send e-mail to a user' action, but does it for all users listed in a user
reference field. Note that bloated user reference fields causes bloated e-mail
sendouts – with potential negative side effects of servers dying and also
becoming blacklisted.
* Insert multiple values to a CCK field: Insert a whole bunch of values into a
multiple-value CCK field. Optionally clear the field before setting new
values. (Duplicate values are ignored.)
* Force a text field to an allowed value: This checks a (single-value) text
field against the allowed values for the field. If it doesn't match, the value
is removed. Optionally does white space-insensitive and case-insensitive
comparison. Can be useful when importing content.
RULES BONUS: COMMENT
====================
Actions
* Change the comment owner: This action updates the comment owner to a selected
user.
RULES BONUS: MISCELLANEOUS
==========================
Conditions
* Verify path argument: Provides the option to check an eqality condition on one
part of the path.
* Check number of results from a view: This condition loads a view and checks
the number of results – condition is passed if it is at least as many results
as you set. You can pass on arguments to the view.
Actions
* Load path argument: Loads a selected part of the argument into a string.
* Get a string with current time: Creates a string object with the current time,
in a custom format and with the acting user's time zone settings.
* Use Views to load a node: This action executes a view of your choice,
including arguments you send to it, and loads the first node returned by the
view as a new Rules object. (Note that you might first want to check that the
view actually has any result using the condition above.)
* Get URL alias for an internal path: Gives you the URL alias for any internal
path. Could be useful for adding additional URL aliases for node related
paths.
* Set the active menu item: This action is A FIRST ATTEMPT at setting the active
menu item using Rules. It sets the active menu item in the sense that the menu
recognises it and show all children links, but it does not yet set the
'active' class to the item in question. Requires the Menu position module.
* Get import nid for content: This action may be useful if you're using the
Feeds module, and use import nodes for importing content. Given an imported
node, this action will give you the node ID for the node used to import it.
Requires the Feeds module, obviosly.
* Set node creation time: This sets the post time for a node to the current
time, or optionally any given time expression.
RULES BONUS: NUMBERS
====================
Actions
* Generate a random number: This gives a random integer in a set interval. Some
validation checks on the interval is still missing.
* Sum up numbers: This provides a sum of a list of numbers you write. Tokens are
allowed.
* Multiply numbers: Much like the action above, but multiplies instead of adds.
* Build a sum from Views: Get a sum of all the values in selected
fields/columns, in a selected view. Use to build dynamically updated sums, and
store/display them any way you want.
RULES BONUS: USER
=================
Conditions
* Node author is an authenticated user: This condition checks that a node has a
real user account as owner – i.e. is not written by an anonymous user.
* A string is valid user name: This checks whether a given string is an ok user
name, optionally also checking if the name is still available.
Actions
* Load the acting user: Guess what this action does. :-)
* Load session ID for active user: Provides the session ID as a number object,
as defined by the Session API module. (Session API module is required.)
* Generate a valid user name: This action takes a string and processes it until
it is a valid and unique Drupal user name. NOTE: It currently replaces invalid
suggested strings with 'dummy name' instead of removing disallowed characters.