From fce5d18231b44ce3a4329cd9cc00900d0b825bdc Mon Sep 17 00:00:00 2001 From: argiepiano Date: Sat, 28 May 2022 12:49:34 -0600 Subject: [PATCH 1/2] Issue #159. Deal with drupal-only actions Fixes #159. WIP --- modules/system.eval.inc | 22 ++++++++++++++++++++++ modules/system.rules.inc | 14 +++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/system.eval.inc b/modules/system.eval.inc index a905f49..3630295 100644 --- a/modules/system.eval.inc +++ b/modules/system.eval.inc @@ -15,6 +15,17 @@ function rules_action_backdrop_message($message, $status, $repeat) { backdrop_set_message(filter_xss_admin($message), $status, $repeat); } +/** + * Action: Show a backdrop message (drupal namespace). + * + * @deprecated + */ +function rules_action_drupal_message($message, $status, $repeat) { + watchdog('rules', 'The action drupal_message is deprecated. This action is now named backdrop_message.', array(), WATCHDOG_DEPRECATED); + rules_log('The action drupal_message is deprecated. This action is now named backdrop_message.', array(), RulesLog::WARN); + rules_action_backdrop_message($message, $status, $repeat); +} + /** * Action: Write a watchdog db log message. */ @@ -29,6 +40,17 @@ function rules_action_backdrop_watchdog($type, $message, $severity, $link_text, watchdog($type, $message, array(), $severity, $link); } +/** + * Action: Write a watchdog db log message (drupal namespace). + * + * @deprecated + */ +function rules_action_drupal_watchdog($type, $message, $severity, $link_text, $link_path) { + watchdog('rules', 'The action drupal_watchdog is deprecated. This action is now named backdrop_watchdog.', array(), WATCHDOG_DEPRECATED); + rules_log('The action drupal_watchdog is deprecated. This action is now named backdrop_watchdog.', array(), RulesLog::WARN); + rules_action_backdrop_watchdog($type, $message, $severity, $link_text, $link_path); +} + /** * Action: Page redirect. * diff --git a/modules/system.rules.inc b/modules/system.rules.inc index 95e0cc1..8e5da76 100644 --- a/modules/system.rules.inc +++ b/modules/system.rules.inc @@ -97,7 +97,7 @@ function _rules_system_watchdog_log_entry_info() { * Implements hook_rules_action_info() on behalf of the system module. */ function rules_system_action_info() { - return array( + $return = array( 'backdrop_message' => array( 'label' => t('Show a message on the site'), 'group' => t('System'), @@ -304,6 +304,18 @@ function rules_system_action_info() { 'access callback' => 'rules_system_integration_access', ), ); + + $return['drupal_message'] = $return['backdrop_message']; + $return['drupal_message']['label'] = t('Show a message on the site. DEPRECATED.'); + $return['drupal_message']['base'] = 'rules_action_drupal_message'; + $return['drupal_message']['hidden'] = TRUE; // @todo To be implemented + + $return['drupal_watchdog'] = $return['backdrop_watchdog']; + $return['drupal_watchdog']['label'] = t('Logs a message to the system dblog. DEPRECATED.'); + $return['drupal_watchdog']['base'] = 'rules_action_drupal_watchdog'; + $return['drupal_watchdog']['hidden'] = TRUE; // @todo To be implemented + + return $return; } /** From 3dd33fc34c06b6fe6a0a267bb54dc1587322595d Mon Sep 17 00:00:00 2001 From: argiepiano Date: Sat, 28 May 2022 13:07:51 -0600 Subject: [PATCH 2/2] Added a way to hide the action if marked hidden --- ui/ui.core.inc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/ui.core.inc b/ui/ui.core.inc index bd474a5..e0127a9 100644 --- a/ui/ui.core.inc +++ b/ui/ui.core.inc @@ -1318,10 +1318,14 @@ class RulesUICategory { continue; } if ($group = RulesUICategory::getItemGroup($info)) { - $sorted_data[backdrop_ucfirst($group)][$name] = backdrop_ucfirst($info['label']); + if (empty($info['hidden'])) { + $sorted_data[backdrop_ucfirst($group)][$name] = backdrop_ucfirst($info['label']); + } } else { - $ungrouped[$name] = backdrop_ucfirst($info['label']); + if (empty($info['hidden'])) { + $ungrouped[$name] = backdrop_ucfirst($info['label']); + } } } asort($ungrouped);