You are here

function user_activity_node_defaults in Heartbeat 6.2

Function to work with rules on node events

1 call to user_activity_node_defaults()
user_activity_rules_defaults in user_activity/user_activity.rules_defaults.inc
Implementation of hook_rules_defaults

File

user_activity/user_activity.rules_defaults.inc, line 29
Rules' pre-configured rules for default drupal core behaviour.

Code

function user_activity_node_defaults() {
  $config = array(
    # node_update_activity_rule
    'node_update_activity_rule' => array(
      '#type' => 'rule',
      '#fixed' => TRUE,
      '#name' => 'node_update_activity_rule',
      '#label' => 'Heartbeat: User activity - log user on update content',
      '#set' => 'event_node_update',
      '#categories' => array(
        'heartbeat',
      ),
      '#active' => 1,
      '#weight' => '0',
      '#status' => 'default',
      // 'custom' will make it deletable
      '#conditions' => array(
        0 => rules_use_condition('rules_condition_content_is_published', array(
          '#settings' => array(
            '#argument map' => array(
              'node' => 'node',
            ),
          ),
          '#weight' => 0,
        )),
      ),
      '#actions' => rules_use_action('user_activity_rules_default_action', array(
        '#settings' => array(
          'event_param' => 'event_node_update',
          'uid_param' => '[author:uid]',
          'uid_target_param' => '0',
          'nid_target_param' => '[node:nid]',
          'message_param' => t(heartbeat_event_messages('event_node_update', 'message')),
          'message_concat_param' => t(heartbeat_event_messages('event_node_update', 'message_concat')),
          'variables_param' => heartbeat_event_messages('event_node_update', 'variables'),
          '#eval input' => array(
            'token_rules_input_evaluator' => array(
              'uid_param' => array(
                0 => 'author',
              ),
              'nid_target_param' => array(
                0 => 'node',
              ),
              'message_param' => array(
                0 => 'node',
                1 => 'author',
              ),
              'variables_param' => array(
                0 => 'node',
                1 => 'author',
              ),
            ),
          ),
        ),
      )),
    ),
    // end node_update_activity_rule
    // node_add_activity_rule
    'node_add_activity_rule' => array(
      '#type' => 'rule',
      '#name' => 'node_add_activity_rule',
      '#categories' => array(
        'heartbeat',
      ),
      '#set' => 'event_node_insert',
      '#label' => 'Heartbeat: User activity - log user added new content',
      '#active' => 1,
      '#weight' => '0',
      '#status' => 'default',
      '#conditions' => array(
        0 => rules_use_condition('rules_condition_content_is_published', array(
          '#settings' => array(
            '#argument map' => array(
              'node' => 'node',
            ),
          ),
          '#weight' => 0,
        )),
      ),
      '#actions' => rules_use_action('user_activity_rules_default_action', array(
        '#settings' => array(
          'event_param' => 'event_node_insert',
          'uid_param' => '[author:uid]',
          'uid_target_param' => '0',
          'nid_target_param' => '[node:nid]',
          'message_param' => t(heartbeat_event_messages('event_node_insert', 'message')),
          'message_concat_param' => t(heartbeat_event_messages('event_node_update', 'message_concat')),
          'variables_param' => heartbeat_event_messages('event_node_insert', 'variables'),
          '#eval input' => array(
            'token_rules_input_evaluator' => array(
              'uid_param' => array(
                0 => 'author',
              ),
              'nid_target_param' => array(
                0 => 'node',
              ),
              'message_param' => array(
                0 => 'node',
                1 => 'author',
              ),
              'variables_param' => array(
                0 => 'node',
                1 => 'author',
              ),
            ),
          ),
        ),
      )),
    ),
  );
  return $config;
}