|
@@ -1,9 +1,15 @@
|
|
|
<?php
|
|
|
|
|
|
/**
|
|
|
- * @file Rules engine module
|
|
|
+ * @file
|
|
|
+ * Rules engine module.
|
|
|
*/
|
|
|
|
|
|
+// The class autoloader may fail for classes added in 7.x-2.4 (Issue 2090511).
|
|
|
+if (!drupal_autoload_class('RulesEventHandlerEntityBundle')) {
|
|
|
+ require_once dirname(__FILE__) . '/includes/rules.event.inc';
|
|
|
+}
|
|
|
+
|
|
|
// Include our hook implementations early, as they can be called even before
|
|
|
// hook_init().
|
|
|
require_once dirname(__FILE__) . '/modules/events.inc';
|
|
@@ -52,8 +58,9 @@ function rules_init() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns an instance of the rules UI controller, which eases re-using the Rules UI.
|
|
|
+ * Returns an instance of the rules UI controller.
|
|
|
*
|
|
|
+ * This function is for convenience, to ease re-using the Rules UI.
|
|
|
* See the rules_admin.module for example usage.
|
|
|
*
|
|
|
* @return RulesUIController
|
|
@@ -71,8 +78,9 @@ function rules_ui() {
|
|
|
*
|
|
|
* @param $name
|
|
|
* The action's name.
|
|
|
- * @param $settings
|
|
|
+ * @param array $settings
|
|
|
* The action's settings array.
|
|
|
+ *
|
|
|
* @return RulesAction
|
|
|
*/
|
|
|
function rules_action($name, $settings = array()) {
|
|
@@ -84,8 +92,9 @@ function rules_action($name, $settings = array()) {
|
|
|
*
|
|
|
* @param $name
|
|
|
* The condition's name.
|
|
|
- * @param $settings
|
|
|
+ * @param array $settings
|
|
|
* The condition's settings array.
|
|
|
+ *
|
|
|
* @return RulesCondition
|
|
|
*/
|
|
|
function rules_condition($name, $settings = array()) {
|
|
@@ -95,9 +104,9 @@ function rules_condition($name, $settings = array()) {
|
|
|
/**
|
|
|
* Creates a new rule.
|
|
|
*
|
|
|
- * @param $variables
|
|
|
+ * @param array $variables
|
|
|
* The array of variables to setup in the evaluation state, making them
|
|
|
- * available for the configuraion elements. Values for the variables need to
|
|
|
+ * available for the configuration elements. Values for the variables need to
|
|
|
* be passed as argument when the rule is executed. Only Rule instances with
|
|
|
* no variables can be embedded in other configurations, e.g. rule sets.
|
|
|
* The array has to be keyed by variable name and contain a sub-array for each
|
|
@@ -110,9 +119,10 @@ function rules_condition($name, $settings = array()) {
|
|
|
* initially, but the "Set data value" action may be used to do so. This is
|
|
|
* in particular useful for defining variables which can be provided to the
|
|
|
* caller (see $provides argument) but need not be passed in as parameter.
|
|
|
- * @param $provides
|
|
|
+ * @param array $provides
|
|
|
* The names of variables which should be provided to the caller. Only
|
|
|
* variables contained in $variables may be specified.
|
|
|
+ *
|
|
|
* @return Rule
|
|
|
*/
|
|
|
function rule($variables = NULL, $provides = array()) {
|
|
@@ -131,8 +141,9 @@ function rules_reaction_rule() {
|
|
|
/**
|
|
|
* Creates a logical OR condition container.
|
|
|
*
|
|
|
- * @param $variables
|
|
|
+ * @param array $variables
|
|
|
* An optional array as for rule().
|
|
|
+ *
|
|
|
* @return RulesOr
|
|
|
*/
|
|
|
function rules_or($variables = NULL) {
|
|
@@ -142,8 +153,9 @@ function rules_or($variables = NULL) {
|
|
|
/**
|
|
|
* Creates a logical AND condition container.
|
|
|
*
|
|
|
- * @param $variables
|
|
|
+ * @param array $variables
|
|
|
* An optional array as for rule().
|
|
|
+ *
|
|
|
* @return RulesAnd
|
|
|
*/
|
|
|
function rules_and($variables = NULL) {
|
|
@@ -153,13 +165,14 @@ function rules_and($variables = NULL) {
|
|
|
/**
|
|
|
* Creates a loop.
|
|
|
*
|
|
|
- * @param $settings
|
|
|
+ * @param array $settings
|
|
|
* The loop settings, containing
|
|
|
* 'list:select': The data selector for the list to loop over.
|
|
|
* 'item:var': Optionally a name for the list item variable.
|
|
|
- * 'item:label': Optionally a lebel for the list item variable.
|
|
|
- * @param $variables
|
|
|
+ * 'item:label': Optionally a label for the list item variable.
|
|
|
+ * @param array $variables
|
|
|
* An optional array as for rule().
|
|
|
+ *
|
|
|
* @return RulesLoop
|
|
|
*/
|
|
|
function rules_loop($settings = array(), $variables = NULL) {
|
|
@@ -169,10 +182,11 @@ function rules_loop($settings = array(), $variables = NULL) {
|
|
|
/**
|
|
|
* Creates a rule set.
|
|
|
*
|
|
|
- * @param $variables
|
|
|
+ * @param array $variables
|
|
|
* An array as for rule().
|
|
|
- * @param $provides
|
|
|
+ * @param array $provides
|
|
|
* The names of variables which should be provided to the caller. See rule().
|
|
|
+ *
|
|
|
* @return RulesRuleSet
|
|
|
*/
|
|
|
function rules_rule_set($variables = array(), $provides = array()) {
|
|
@@ -182,10 +196,11 @@ function rules_rule_set($variables = array(), $provides = array()) {
|
|
|
/**
|
|
|
* Creates an action set.
|
|
|
*
|
|
|
- * @param $variables
|
|
|
+ * @param array $variables
|
|
|
* An array as for rule().
|
|
|
- * @param $provides
|
|
|
+ * @param array $provides
|
|
|
* The names of variables which should be provided to the caller. See rule().
|
|
|
+ *
|
|
|
* @return RulesActionSet
|
|
|
*/
|
|
|
function rules_action_set($variables = array(), $provides = array()) {
|
|
@@ -197,15 +212,15 @@ function rules_action_set($variables = array(), $provides = array()) {
|
|
|
*
|
|
|
* @param $msg
|
|
|
* The message to log.
|
|
|
- * @param $args
|
|
|
+ * @param array $args
|
|
|
* An array of placeholder arguments as used by t().
|
|
|
* @param $priority
|
|
|
* A priority as defined by the RulesLog class.
|
|
|
* @param RulesPlugin $element
|
|
|
- * (optional) The RulesElement causing the log entry.
|
|
|
- * @param boolean $scope
|
|
|
- * (optional) This may be used to denote the beginning (TRUE) or the end
|
|
|
- * (FALSE) of a new execution scope.
|
|
|
+ * (optional) The RulesElement causing the log entry.
|
|
|
+ * @param bool $scope
|
|
|
+ * (optional) This may be used to denote the beginning (TRUE) or the end
|
|
|
+ * (FALSE) of a new execution scope.
|
|
|
*/
|
|
|
function rules_log($msg, $args = array(), $priority = RulesLog::INFO, RulesPlugin $element = NULL, $scope = NULL) {
|
|
|
static $logger, $settings;
|
|
@@ -242,7 +257,7 @@ function rules_log($msg, $args = array(), $priority = RulesLog::INFO, RulesPlugi
|
|
|
/**
|
|
|
* Fetches module definitions for the given hook name.
|
|
|
*
|
|
|
- * Used for collecting events, rules, actions and condtions from other modules.
|
|
|
+ * Used for collecting events, rules, actions and condition from other modules.
|
|
|
*
|
|
|
* @param $hook
|
|
|
* The hook of the definitions to get from invoking hook_rules_{$hook}.
|
|
@@ -270,7 +285,7 @@ function rules_fetch_data($hook) {
|
|
|
if (isset($discover[$hook])) {
|
|
|
$data[$hook] += rules_discover_plugins($discover[$hook]);
|
|
|
}
|
|
|
- drupal_alter('rules_'. $hook, $data[$hook]);
|
|
|
+ drupal_alter('rules_' . $hook, $data[$hook]);
|
|
|
}
|
|
|
return $data[$hook];
|
|
|
}
|
|
@@ -318,6 +333,13 @@ function rules_discover_plugins($class) {
|
|
|
|
|
|
/**
|
|
|
* Determines the module providing the given class.
|
|
|
+ *
|
|
|
+ * @param string $class
|
|
|
+ * The name of the class or interface plugins to discover.
|
|
|
+ *
|
|
|
+ * @return string|false
|
|
|
+ * The path of the class, relative to the Drupal installation root,
|
|
|
+ * or FALSE if not discovered.
|
|
|
*/
|
|
|
function _rules_discover_module($class) {
|
|
|
$paths = &drupal_static(__FUNCTION__);
|
|
@@ -335,7 +357,7 @@ function _rules_discover_module($class) {
|
|
|
$path = str_replace(realpath(DRUPAL_ROOT) . DIRECTORY_SEPARATOR, '', realpath(dirname($reflection->getFileName())));
|
|
|
$path = DIRECTORY_SEPARATOR != '/' ? str_replace(DIRECTORY_SEPARATOR, '/', $path) : $path;
|
|
|
|
|
|
- // Go up the path until we match a module up.
|
|
|
+ // Go up the path until we match a module.
|
|
|
$parts = explode('/', $path);
|
|
|
while (!isset($paths[$path]) && array_pop($parts)) {
|
|
|
$path = dirname($path);
|
|
@@ -366,9 +388,8 @@ function &rules_get_cache($cid = 'data') {
|
|
|
// Prevent stampeding by ensuring the cache is rebuilt just once at the
|
|
|
// same time.
|
|
|
while (!lock_acquire(__FUNCTION__ . $cid . $cid_suffix, 60)) {
|
|
|
- rules_log('Cache rebuild lock hit: !cid', array('!cid' => $cid), RulesLog::WARN);
|
|
|
// Now wait until the lock is released.
|
|
|
- lock_wait(__FUNCTION__ . $cid . $cid_suffix, 10);
|
|
|
+ lock_wait(__FUNCTION__ . $cid . $cid_suffix, 30);
|
|
|
// If the lock is released it's likely the cache was rebuild. Thus check
|
|
|
// again if we can fetch it from the persistent cache.
|
|
|
if ($get = cache_get($cid . $cid_suffix, 'cache_rules')) {
|
|
@@ -377,9 +398,10 @@ function &rules_get_cache($cid = 'data') {
|
|
|
}
|
|
|
}
|
|
|
if ($cid === 'data') {
|
|
|
- // There is no 'data' cache so we need to rebuild it. Make sure subsequent
|
|
|
- // cache gets of the main 'data' cache during rebuild get the interim
|
|
|
- // cache by passing in the reference of the static cache variable.
|
|
|
+ // There is no 'data' cache so we need to rebuild it. Make sure
|
|
|
+ // subsequent cache gets of the main 'data' cache during rebuild get
|
|
|
+ // the interim cache by passing in the reference of the static cache
|
|
|
+ // variable.
|
|
|
_rules_rebuild_cache($cache['data']);
|
|
|
}
|
|
|
elseif (strpos($cid, 'comp_') === 0) {
|
|
@@ -415,7 +437,7 @@ function &rules_get_cache($cid = 'data') {
|
|
|
* @see entity_defaults_rebuild()
|
|
|
*/
|
|
|
function _rules_rebuild_cache(&$cache) {
|
|
|
- foreach(array('data_info', 'plugin_info') as $hook) {
|
|
|
+ foreach (array('data_info', 'plugin_info') as $hook) {
|
|
|
$cache[$hook] = rules_fetch_data($hook);
|
|
|
}
|
|
|
foreach ($cache['plugin_info'] as $name => &$info) {
|
|
@@ -477,7 +499,7 @@ function rules_flush_caches() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Clears the rule set cache
|
|
|
+ * Clears the rule set cache.
|
|
|
*/
|
|
|
function rules_clear_cache() {
|
|
|
cache_clear_all('*', 'cache_rules', TRUE);
|
|
@@ -490,16 +512,17 @@ function rules_clear_cache() {
|
|
|
/**
|
|
|
* Imports the given export and returns the imported configuration.
|
|
|
*
|
|
|
- * @param $export
|
|
|
+ * @param string $export
|
|
|
* A serialized string in JSON format as produced by the RulesPlugin::export()
|
|
|
* method, or the PHP export as usual PHP array.
|
|
|
+ * @param string $error_msg
|
|
|
+ *
|
|
|
* @return RulesPlugin
|
|
|
*/
|
|
|
function rules_import($export, &$error_msg = '') {
|
|
|
return entity_get_controller('rules_config')->import($export, $error_msg);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Wraps the given data.
|
|
|
*
|
|
@@ -507,9 +530,10 @@ function rules_import($export, &$error_msg = '') {
|
|
|
* If available, the actual data, else NULL.
|
|
|
* @param $info
|
|
|
* An array of info about this data.
|
|
|
- * @param $force
|
|
|
+ * @param bool $force
|
|
|
* Usually data is only wrapped if really needed. If set to TRUE, wrapping the
|
|
|
* data is forced, so primitive data types are also wrapped.
|
|
|
+ *
|
|
|
* @return EntityMetadataWrapper
|
|
|
* An EntityMetadataWrapper or the unwrapped data.
|
|
|
*
|
|
@@ -550,11 +574,12 @@ function &rules_wrap_data($data = NULL, $info, $force = FALSE) {
|
|
|
/**
|
|
|
* Unwraps the given data, if it's wrapped.
|
|
|
*
|
|
|
- * @param $data
|
|
|
+ * @param array $data
|
|
|
* An array of wrapped data.
|
|
|
- * @param $info
|
|
|
+ * @param array $info
|
|
|
* Optionally an array of info about how to unwrap the data. Keyed as $data.
|
|
|
- * @return
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
* An array containing unwrapped or passed through data.
|
|
|
*/
|
|
|
function rules_unwrap_data(array $data, $info = array()) {
|
|
@@ -622,6 +647,9 @@ function rules_get_event_info($event_name) {
|
|
|
* For a configured event name like node_view--article the base event name
|
|
|
* node_view is returned.
|
|
|
*
|
|
|
+ * @param string $event_name
|
|
|
+ * A (configured) event name.
|
|
|
+ *
|
|
|
* @return string
|
|
|
* The event base name.
|
|
|
*/
|
|
@@ -668,7 +696,7 @@ function rules_plugin_factory($plugin_name, $arg1 = NULL, $arg2 = NULL) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Implementation of hook_rules_plugin_info().
|
|
|
+ * Implements hook_rules_plugin_info().
|
|
|
*
|
|
|
* Note that the cache is rebuilt in the order of the plugins. Therefore the
|
|
|
* condition and action plugins must be at the top, so that any components
|
|
@@ -680,11 +708,11 @@ function rules_rules_plugin_info() {
|
|
|
'condition' => array(
|
|
|
'class' => 'RulesCondition',
|
|
|
'embeddable' => 'RulesConditionContainer',
|
|
|
- 'extenders' => array (
|
|
|
+ 'extenders' => array(
|
|
|
'RulesPluginImplInterface' => array(
|
|
|
'class' => 'RulesAbstractPluginDefaults',
|
|
|
),
|
|
|
- 'RulesPluginFeaturesIntegrationInterace' => array(
|
|
|
+ 'RulesPluginFeaturesIntegrationInterface' => array(
|
|
|
'methods' => array(
|
|
|
'features_export' => 'rules_features_abstract_default_features_export',
|
|
|
),
|
|
@@ -697,11 +725,11 @@ function rules_rules_plugin_info() {
|
|
|
'action' => array(
|
|
|
'class' => 'RulesAction',
|
|
|
'embeddable' => 'RulesActionContainer',
|
|
|
- 'extenders' => array (
|
|
|
+ 'extenders' => array(
|
|
|
'RulesPluginImplInterface' => array(
|
|
|
'class' => 'RulesAbstractPluginDefaults',
|
|
|
),
|
|
|
- 'RulesPluginFeaturesIntegrationInterace' => array(
|
|
|
+ 'RulesPluginFeaturesIntegrationInterface' => array(
|
|
|
'methods' => array(
|
|
|
'features_export' => 'rules_features_abstract_default_features_export',
|
|
|
),
|
|
@@ -793,7 +821,7 @@ function rules_rules_plugin_info() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Implementation of hook_entity_info().
|
|
|
+ * Implements hook_entity_info().
|
|
|
*/
|
|
|
function rules_entity_info() {
|
|
|
return array(
|
|
@@ -822,10 +850,10 @@ function rules_entity_info() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Implementation of hook_hook_info().
|
|
|
+ * Implements hook_hook_info().
|
|
|
*/
|
|
|
function rules_hook_info() {
|
|
|
- foreach(array('plugin_info', 'rules_directory', 'data_info', 'condition_info', 'action_info', 'event_info', 'file_info', 'evaluator_info', 'data_processor_info') as $hook) {
|
|
|
+ foreach (array('plugin_info', 'rules_directory', 'data_info', 'condition_info', 'action_info', 'event_info', 'file_info', 'evaluator_info', 'data_processor_info') as $hook) {
|
|
|
$hooks['rules_' . $hook] = array(
|
|
|
'group' => 'rules',
|
|
|
);
|
|
@@ -852,12 +880,12 @@ function rules_hook_info() {
|
|
|
* @see hook_entity_info()
|
|
|
* @see RulesEntityController
|
|
|
*
|
|
|
- * @param $names
|
|
|
+ * @param array|false $names
|
|
|
* An array of rules configuration names or FALSE to load all.
|
|
|
- * @param $conditions
|
|
|
+ * @param array $conditions
|
|
|
* An array of conditions in the form 'field' => $value.
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return array
|
|
|
* An array of rule configurations indexed by their ids.
|
|
|
*/
|
|
|
function rules_config_load_multiple($names = array(), $conditions = array()) {
|
|
@@ -885,10 +913,10 @@ function rules_config_load($name) {
|
|
|
* Whether to return only the label or the whole component object.
|
|
|
* @param $type
|
|
|
* Optionally filter for 'action' or 'condition' components.
|
|
|
- * @param $conditions
|
|
|
+ * @param array $conditions
|
|
|
* An array of additional conditions as required by rules_config_load().
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return array
|
|
|
* An array keyed by component name containing either the label or the config.
|
|
|
*/
|
|
|
function rules_get_components($label = FALSE, $type = NULL, $conditions = array()) {
|
|
@@ -911,7 +939,7 @@ function rules_get_components($label = FALSE, $type = NULL, $conditions = array(
|
|
|
/**
|
|
|
* Delete rule configurations from database.
|
|
|
*
|
|
|
- * @param $ids
|
|
|
+ * @param array $ids
|
|
|
* An array of entity IDs.
|
|
|
*/
|
|
|
function rules_config_delete(array $ids) {
|
|
@@ -921,13 +949,13 @@ function rules_config_delete(array $ids) {
|
|
|
/**
|
|
|
* Ensures the configuration's 'dirty' flag is up to date by running an integrity check.
|
|
|
*
|
|
|
- * @param $update
|
|
|
+ * @param bool $update
|
|
|
* (optional) Whether the dirty flag is also updated in the database if
|
|
|
* necessary. Defaults to TRUE.
|
|
|
*/
|
|
|
function rules_config_update_dirty_flag($rules_config, $update = TRUE) {
|
|
|
// Keep a log of already check configurations to avoid repetitive checks on
|
|
|
- // oftent used components.
|
|
|
+ // often used components.
|
|
|
// @see rules_element_invoke_component_validate()
|
|
|
$checked = &drupal_static(__FUNCTION__, array());
|
|
|
if (!empty($checked[$rules_config->name])) {
|
|
@@ -974,7 +1002,7 @@ function rules_config_update_dirty_flag($rules_config, $update = TRUE) {
|
|
|
* @param ...
|
|
|
* Arguments to pass to the hook / event.
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return array
|
|
|
* An array of return values of the hook implementations. If modules return
|
|
|
* arrays from their implementations, those are merged into one array.
|
|
|
*/
|
|
@@ -1021,10 +1049,10 @@ function rules_invoke_event() {
|
|
|
$event_name = $args[0];
|
|
|
unset($args[0]);
|
|
|
// We maintain a whitelist of configured events to reduces the number of cache
|
|
|
- // reads. If the whitelist is empty we proceed and it is rebuilt.
|
|
|
+ // reads. If the whitelist is not in the cache we proceed and it is rebuilt.
|
|
|
if (rules_event_invocation_enabled()) {
|
|
|
$whitelist = rules_get_cache('rules_event_whitelist');
|
|
|
- if ((empty($whitelist) || isset($whitelist[$event_name])) && $event = rules_get_cache('event_' . $event_name)) {
|
|
|
+ if ((($whitelist === FALSE) || isset($whitelist[$event_name])) && $event = rules_get_cache('event_' . $event_name)) {
|
|
|
$event->executeByArgs($args);
|
|
|
}
|
|
|
}
|
|
@@ -1035,7 +1063,7 @@ function rules_invoke_event() {
|
|
|
*
|
|
|
* @param $event_name
|
|
|
* The event's name.
|
|
|
- * @param $args
|
|
|
+ * @param array $args
|
|
|
* An array of parameters for the variables provided by the event, as defined
|
|
|
* in hook_rules_event_info(). Either pass an array keyed by the variable
|
|
|
* names or a numerically indexed array, in which case the ordering of the
|
|
@@ -1066,7 +1094,7 @@ function rules_invoke_event_by_args($event_name, $args = array()) {
|
|
|
* @param $args
|
|
|
* Pass further parameters as required for the invoked component.
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return array
|
|
|
* An array of variables as provided by the component, or FALSE in case the
|
|
|
* component could not be executed.
|
|
|
*/
|
|
@@ -1080,10 +1108,12 @@ function rules_invoke_component() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Filters the given array of arrays by keeping only entries which have $key set
|
|
|
- * to the value of $value.
|
|
|
+ * Filters the given array of arrays.
|
|
|
*
|
|
|
- * @param $array
|
|
|
+ * This filter operates by keeping only entries which have $key set to the
|
|
|
+ * value of $value.
|
|
|
+ *
|
|
|
+ * @param array $array
|
|
|
* The array of arrays to filter.
|
|
|
* @param $key
|
|
|
* The key used for the comparison.
|
|
@@ -1105,10 +1135,11 @@ function rules_filter_array($array, $key, $value) {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Merges the $update array into $array making sure no values of $array not
|
|
|
- * appearing in $update are lost.
|
|
|
+ * Merges the $update array into $array.
|
|
|
+ *
|
|
|
+ * Makes sure no values of $array not appearing in $update are lost.
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return array
|
|
|
* The updated array.
|
|
|
*/
|
|
|
function rules_update_array(array $array, array $update) {
|
|
@@ -1126,12 +1157,13 @@ function rules_update_array(array $array, array $update) {
|
|
|
/**
|
|
|
* Extracts the property with the given name.
|
|
|
*
|
|
|
- * @param $arrays
|
|
|
+ * @param array $arrays
|
|
|
* An array of arrays from which a property is to be extracted.
|
|
|
* @param $key
|
|
|
* The name of the property to extract.
|
|
|
*
|
|
|
- * @return An array of extracted properties, keyed as in $arrays-
|
|
|
+ * @return array
|
|
|
+ * An array of extracted properties, keyed as in $arrays.
|
|
|
*/
|
|
|
function rules_extract_property($arrays, $key) {
|
|
|
$data = array();
|
|
@@ -1156,9 +1188,9 @@ function rules_array_key($array) {
|
|
|
*
|
|
|
* @param $replacements
|
|
|
* An array of token replacements that need to be "cleaned" for use in the URL.
|
|
|
- * @param $data
|
|
|
+ * @param array $data
|
|
|
* An array of objects used to generate the replacements.
|
|
|
- * @param $options
|
|
|
+ * @param array $options
|
|
|
* An array of options used to generate the replacements.
|
|
|
*
|
|
|
* @see rules_path_action_info()
|
|
@@ -1265,6 +1297,7 @@ function rules_permissions_by_component(array $components = array()) {
|
|
|
|
|
|
/**
|
|
|
* Menu callback for loading rules configuration elements.
|
|
|
+ *
|
|
|
* @see RulesUIController::config_menu()
|
|
|
*/
|
|
|
function rules_element_load($element_id, $config_name) {
|
|
@@ -1274,6 +1307,7 @@ function rules_element_load($element_id, $config_name) {
|
|
|
|
|
|
/**
|
|
|
* Menu callback for getting the title as configured.
|
|
|
+ *
|
|
|
* @see RulesUIController::config_menu()
|
|
|
*/
|
|
|
function rules_get_title($text, $element) {
|
|
@@ -1292,6 +1326,7 @@ function rules_get_title($text, $element) {
|
|
|
* Menu callback for getting the title for the add element page.
|
|
|
*
|
|
|
* Uses a work-a-round for accessing the plugin name.
|
|
|
+ *
|
|
|
* @see RulesUIController::config_menu()
|
|
|
*/
|
|
|
function rules_menu_add_element_title($array) {
|
|
@@ -1384,11 +1419,14 @@ function rules_drupal_goto_alter(&$path, &$options, &$http_response_code) {
|
|
|
* Returns whether the debug log should be shown.
|
|
|
*/
|
|
|
function rules_show_debug_output() {
|
|
|
- if (variable_get('rules_debug', FALSE) == RulesLog::INFO && user_access('access rules debug')) {
|
|
|
+ // For performance avoid unnecessary auto-loading of the RulesLog class.
|
|
|
+ if (!class_exists('RulesLog', FALSE)) {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ if (variable_get('rules_debug', 0) == RulesLog::INFO && user_access('access rules debug')) {
|
|
|
return TRUE;
|
|
|
}
|
|
|
- // For performance avoid unnecessary auto-loading of the RulesLog class.
|
|
|
- return variable_get('rules_debug', FALSE) == RulesLog::WARN && user_access('access rules debug') && class_exists('RulesLog', FALSE) && RulesLog::logger()->hasErrors();
|
|
|
+ return variable_get('rules_debug', 0) == RulesLog::WARN && user_access('access rules debug') && RulesLog::logger()->hasErrors();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1495,11 +1533,13 @@ function rules_modules_disabled($modules) {
|
|
|
->fields('r')
|
|
|
->condition('id', $ids, 'IN')
|
|
|
->condition('active', 1)
|
|
|
- ->execute()->rowCount();
|
|
|
+ ->countQuery()
|
|
|
+ ->execute()
|
|
|
+ ->fetchField();
|
|
|
if ($count > 0) {
|
|
|
$message = format_plural($count,
|
|
|
'1 Rules configuration requires some of the disabled modules to function and cannot be executed any more.',
|
|
|
- '@count Rules configuration require some of the disabled modules to function and cannot be executed any more.'
|
|
|
+ '@count Rules configurations require some of the disabled modules to function and cannot be executed any more.'
|
|
|
);
|
|
|
drupal_set_message($message, 'warning');
|
|
|
}
|
|
@@ -1580,25 +1620,25 @@ function rules_menu() {
|
|
|
/**
|
|
|
* Helper function to keep track of external documentation pages for Rules.
|
|
|
*
|
|
|
- * @param $topic
|
|
|
+ * @param string $topic
|
|
|
* The topic key for used for identifying help pages.
|
|
|
*
|
|
|
- * @return
|
|
|
+ * @return string|array|false
|
|
|
* Either a URL for the given page, or the full list of external help pages.
|
|
|
*/
|
|
|
function rules_external_help($topic = NULL) {
|
|
|
$help = array(
|
|
|
- 'rules' => 'http://drupal.org/node/298480',
|
|
|
- 'terminology' => 'http://drupal.org/node/1299990',
|
|
|
- 'condition-components' => 'http://drupal.org/node/1300034',
|
|
|
- 'data-selection' => 'http://drupal.org/node/1300042',
|
|
|
- 'chained-tokens' => 'http://drupal.org/node/1300042',
|
|
|
- 'loops' => 'http://drupal.org/node/1300058',
|
|
|
- 'components' => 'http://drupal.org/node/1300024',
|
|
|
- 'component-types' => 'http://drupal.org/node/1300024',
|
|
|
- 'variables' => 'http://drupal.org/node/1300024',
|
|
|
- 'scheduler' => 'http://drupal.org/node/1300068',
|
|
|
- 'coding' => 'http://drupal.org/node/878720',
|
|
|
+ 'rules' => 'https://www.drupal.org/node/298480',
|
|
|
+ 'terminology' => 'https://www.drupal.org/node/1299990',
|
|
|
+ 'condition-components' => 'https://www.drupal.org/node/1300034',
|
|
|
+ 'data-selection' => 'https://www.drupal.org/node/1300042',
|
|
|
+ 'chained-tokens' => 'https://www.drupal.org/node/1300042',
|
|
|
+ 'loops' => 'https://www.drupal.org/node/1300058',
|
|
|
+ 'components' => 'https://www.drupal.org/node/1300024',
|
|
|
+ 'component-types' => 'https://www.drupal.org/node/1300024',
|
|
|
+ 'variables' => 'https://www.drupal.org/node/1300024',
|
|
|
+ 'scheduler' => 'https://www.drupal.org/node/1300068',
|
|
|
+ 'coding' => 'https://www.drupal.org/node/878720',
|
|
|
);
|
|
|
|
|
|
if (isset($topic)) {
|
|
@@ -1700,7 +1740,7 @@ function rules_entity_metadata_wrapper_all_properties_callback(EntityMetadataWra
|
|
|
* when Drupal is not fully bootstrapped. It gets enabled in rules_init() and
|
|
|
* rules_enable().
|
|
|
*
|
|
|
- * @param bool|NULL $enable
|
|
|
+ * @param bool|null $enable
|
|
|
* NULL to leave the setting as is and TRUE / FALSE to change the behaviour.
|
|
|
*
|
|
|
* @return bool
|