You are here

function privatemsg_rules_rules_defaults in Privatemsg 6.2

Implements hook_rules_defaults().

File

privatemsg_rules/privatemsg_rules.rules.inc, line 154
Hooks and callback functions for rules.module integration.

Code

function privatemsg_rules_rules_defaults() {
  $config = array(
    'rules' => array(
      'privatemsg_welcome_message' => array(
        '#type' => 'rule',
        '#set' => 'event_user_insert',
        '#label' => 'Send welcome message with privatemsg when a new user is created',
        '#active' => 0,
        '#weight' => '0',
        '#status' => 'custom',
        '#conditions' => array(),
        '#actions' => array(
          1 => array(
            '#weight' => -10,
            '#info' => array(
              'label' => 'Load a user account',
              'new variables' => array(
                'admin_user' => array(
                  'label' => 'Admin User (uid 1)',
                  'label callback' => FALSE,
                  'type' => 'user',
                ),
              ),
              'module' => 'User',
            ),
            '#name' => 'rules_action_load_user',
            '#settings' => array(
              'username' => '',
              'userid' => '1',
              '#argument map' => array(
                'admin_user' => 'user_loaded',
              ),
            ),
            '#type' => 'action',
          ),
          0 => array(
            '#weight' => 0,
            '#type' => 'action',
            '#settings' => array(
              'subject' => 'Welcome!',
              'body' => 'Hey <?php $account->name; ?>, welcome on our site!',
              '#argument map' => array(
                'account' => 'recipient',
                'admin_user' => 'author',
              ),
              '#eval input' => array(
                'rules_input_evaluator_php' => array(
                  'body' => array(
                    0 => 'account',
                  ),
                ),
              ),
            ),
            '#name' => 'privatemsg_rules_new',
            '#info' => array(
              'label' => 'Send a message',
              'arguments' => array(
                'subject' => array(
                  'type' => 'string',
                  'label' => 'Subject',
                ),
                'body' => array(
                  'type' => 'string',
                  'label' => 'Body text',
                ),
                'recipient' => array(
                  'type' => 'user',
                  'label' => 'Recipient',
                ),
              ),
              'module' => 'Privatemsg',
            ),
          ),
        ),
      ),
      'privatemsg_rules_autorespond' => array(
        '#type' => 'rule',
        '#set' => 'event_privatemsg_insert',
        '#label' => 'Auto-Respond a message to UID 1',
        '#active' => 0,
        '#weight' => '0',
        '#status' => 'custom',
        '#conditions' => array(
          0 => array(
            '#type' => 'condition',
            '#settings' => array(
              'number1' => '$mid',
              'number2' => '$thread_id',
              'operation' => 'equal',
            ),
            '#name' => 'rules_condition_number_compare',
            '#info' => array(
              'label' => 'First message of thread',
              'label callback' => FALSE,
              'arguments' => array(
                'number1' => array(
                  'label' => 'Number 1',
                  'type' => 'number',
                ),
                'number2' => array(
                  'label' => 'Number 2',
                  'type' => 'number',
                ),
              ),
              'module' => 'Rules',
            ),
            '#weight' => 0,
          ),
          1 => array(
            '#info' => array(
              'label' => 'Recipient is uid 1',
              'label callback' => FALSE,
              'module' => 'PHP',
              'eval input' => array(
                0 => 'code',
              ),
            ),
            '#name' => 'rules_condition_custom_php',
            '#settings' => array(
              'code' => 'return $recipient->uid == 1;',
              'vars' => array(
                0 => 'recipient',
              ),
            ),
            '#type' => 'condition',
            '#weight' => 0,
          ),
        ),
        '#actions' => array(
          0 => array(
            '#type' => 'action',
            '#settings' => array(
              'body' => 'Hey <?php echo $author->name; ?>!

  Thanks for your message, I will reply soon!

  Greetings, <?php echo $recipient->name; ?>

  (this is an automatic message)',
              '#argument map' => array(
                'recipient' => 'author',
              ),
              '#eval input' => array(
                'rules_input_evaluator_php' => array(
                  'body' => array(
                    0 => 'author',
                    1 => 'recipient',
                  ),
                ),
              ),
            ),
            '#name' => 'privatemsg_rules_reply',
            '#info' => array(
              'label' => 'Reply a message',
              'arguments' => array(
                'thread_id' => array(
                  'type' => 'int',
                  'label' => 'Privatemsg thread id',
                ),
                'body' => array(
                  'type' => 'string',
                  'label' => 'Body text',
                  'long' => TRUE,
                ),
                'author' => array(
                  'type' => 'user',
                  'label' => 'Author',
                ),
              ),
              'module' => 'Privatemsg',
            ),
            '#weight' => 0,
          ),
        ),
      ),
    ),
  );
  return $config;
}