You are here

referral_trigger.module in User Referral 6

File

referral_trigger/referral_trigger.module
View source
<?php

/*
* Implementation of hook_hook_info()
*/
function referral_trigger_hook_info() {
  return array(
    'referral' => array(
      'referral' => array(
        'new' => array(
          'runs when' => t('After a user\'s referral has resulted in a new account creation'),
        ),
      ),
    ),
  );
}

/*
* Implemenation of hook_referral()
*/
function referral_trigger_referral($new_uid, $referrer_uid) {
  $aids = _trigger_get_hook_aids('referral', 'new');
  $context = array(
    'hook' => 'referral',
    'op' => '',
    'new_uid' => $new_uid,
    'referrer_uid' => $referrer_uid,
  );

  // act on referrer user object.
  $object = user_load($referrer_uid);
  actions_do(array_keys($aids), $object, $context);
}

/*
 * Implementation of hook_action_info_alter
 */
function referral_trigger_action_info_alter(&$actions) {
  $actions['system_send_email_action']['hooks']['referral'] = array(
    'any' => TRUE,
  );
}

/*
 * Implementation of hook_form_alter
 */
function referral_trigger_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'system_actions_configure' && $form['recipient']) {
    $form['recipient']['#description'] = $form['recipient']['#description'] . ' ' . t('If sending an email via the User Referral trigger, using %author will send the email to the referring user\'s email.');
  }
  if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) {
    $form['workflow']['upload_' . $form['type']['#value']] = array(
      '#type' => 'radios',
      '#title' => t('Attachments'),
      '#default_value' => variable_get('upload_' . $form['type']['#value'], 1),
      '#options' => array(
        t('Disabled'),
        t('Enabled'),
      ),
    );
  }
}