diff --git a/modules/comment.rules.inc b/modules/comment.rules.inc index f9846fd..ab01118 100644 --- a/modules/comment.rules.inc +++ b/modules/comment.rules.inc @@ -54,6 +54,58 @@ function rules_comment_event_info() { } /** + * Condition: Check if the comment is published + */ +function rules_condition_comment_is_published($node) { + return $node->status == 1; +} + +/** + * Implements hook_rules_condition_info() on behalf of the comment module. + */ +function rules_comment_condition_info() { + $defaults = array( + 'parameter' => array( + 'node' => array('type' => 'comment', 'label' => t('Comment')), + ), + 'group' => t('Comment'), + 'access callback' => 'rules_comment_integration_access', + ); + $items['comment_is_published'] = $defaults + array( + 'label' => t('Comment is published'), + 'base' => 'rules_condition_comment_is_published', + ); + return $items; +} + +/** + * Implements hook_rules_action_info() on behalf of the comment module. + */ +function rules_comment_action_info() { + $defaults = array( + 'parameter' => array( + 'node' => array('type' => 'comment', 'label' => t('Comment'), 'save' => TRUE), + ), + 'group' => t('Comment'), + 'access callback' => 'rules_comment_admin_access', + ); + // Add support for hand-picked core actions. + $core_actions = comment_action_info(); + $actions = array( + 'comment_publish_action', + 'comment_unpublish_action', + ); + foreach ($actions as $base) { + $action_name = str_replace('_action', '', $base); + $items[$action_name] = $defaults + array( + 'label' => $core_actions[$base]['label'], + 'base' => $base, + ); + } + return $items; +} + +/** * Comment integration access callback. */ function rules_comment_integration_access($type, $name) { @@ -63,5 +115,12 @@ function rules_comment_integration_access($type, $name) { } /** + * Comment integration admin access callback. + */ +function rules_comment_admin_access() { + return user_access('administer comments'); +} + +/** * @} */