You are here

function redhen_contact_redhen_settings in RedHen CRM 7

Implements hook_redhen_settings().

File

modules/redhen_contact/redhen_contact.module, line 825
Module file for RedHen contacts.

Code

function redhen_contact_redhen_settings() {
  $contact_type_options = redhen_contact_type_options_list();
  return array(
    'redhen_contact_email' => array(
      '#type' => 'fieldset',
      '#title' => t('Email settings'),
      '#weight' => 0,
      'settings' => array(
        REDHEN_CONTACT_REQUIRE_EMAIL => array(
          '#type' => 'checkbox',
          '#title' => t('Require contacts to have a valid email address'),
          '#description' => t('Controls the contact form validation. Must be true to enable Drupal user connections keyed on email and contact email mirroring.'),
          '#default_value' => variable_get(REDHEN_CONTACT_REQUIRE_EMAIL, TRUE),
        ),
        REDHEN_CONTACT_CONNECT_USERS => array(
          '#type' => 'checkbox',
          '#title' => t('Connect users to Redhen contacts'),
          '#description' => t('If checked, Redhen will attempt to connect Drupal users to Redhen contacts by matching email addresses when a contact is updated.'),
          '#default_value' => variable_get(REDHEN_CONTACT_CONNECT_USERS, FALSE),
          '#states' => array(
            'enabled' => array(
              ':input[name="' . REDHEN_CONTACT_REQUIRE_EMAIL . '"]' => array(
                'checked' => TRUE,
              ),
            ),
          ),
        ),
        REDHEN_CONTACT_MIRROR_EMAIL => array(
          '#type' => 'checkbox',
          '#title' => t('Mirror RedHen Contact email to Drupal user'),
          '#description' => t('If checked, RedHen will mirror the primary email of a RedHen Contact with the email of the linked user account. The email field on the Drupal user form will also be disabled.'),
          '#default_value' => variable_get(REDHEN_CONTACT_MIRROR_EMAIL, FALSE),
          '#states' => array(
            'enabled' => array(
              ':input[name="' . REDHEN_CONTACT_CONNECT_USERS . '"]' => array(
                'checked' => TRUE,
              ),
            ),
          ),
        ),
        REDHEN_CONTACT_EMBED_ON_USER_FORM => array(
          '#type' => 'checkbox',
          '#title' => t('Embed Redhen Contact Fields on the User edit form'),
          '#description' => t('If checked, the RedHen Contact tab on users will be removed, and the Contact edit fields will instead be attached to the bottom of the User Edit form.'),
          '#default_value' => variable_get(REDHEN_CONTACT_EMBED_ON_USER_FORM, FALSE),
          '#states' => array(
            'enabled' => array(
              ':input[name="' . REDHEN_CONTACT_CONNECT_USERS . '"]' => array(
                'checked' => TRUE,
              ),
            ),
          ),
        ),
        REDHEN_CONTACT_DELETE_USER_WITH_CONTACT => array(
          '#type' => 'checkbox',
          '#title' => t('Delete Users when their connected Redhen Contacts are deleted (WARNING: automated User deletion!)'),
          '#description' => t('If checked, deleted Redhen Contacts will be checked for connected users, and those users will be automatically deleted as well.'),
          '#default_value' => variable_get(REDHEN_CONTACT_DELETE_USER_WITH_CONTACT, FALSE),
          '#states' => array(
            'enabled' => array(
              ':input[name="' . REDHEN_CONTACT_CONNECT_USERS . '"]' => array(
                'checked' => TRUE,
              ),
            ),
          ),
        ),
        REDHEN_CONTACT_USER_EMAIL_TYPE => array(
          '#type' => 'checkboxes',
          '#multiple' => TRUE,
          '#options' => $contact_type_options,
          '#title' => t('User email contact types'),
          '#description' => t('Restrict which contact types will connect to Drupal user accounts by email address. Leave blank to allow ANY contact type (default).'),
          '#default_value' => variable_get(REDHEN_CONTACT_USER_EMAIL_TYPE, array()),
          '#states' => array(
            'enabled' => array(
              ':input[name="' . REDHEN_CONTACT_CONNECT_USERS . '"]' => array(
                'checked' => TRUE,
              ),
            ),
          ),
          '#access' => count($contact_type_options) > 1,
        ),
      ),
    ),
    REDHEN_CONTACT_ALTER_USERNAME => array(
      '#type' => 'checkbox',
      '#title' => t('Display username as contact label'),
      '#description' => t("If checked, RedHen will alter the display of the Drupal username to match a linked contact's label."),
      '#default_value' => variable_get(REDHEN_CONTACT_ALTER_USERNAME, FALSE),
    ),
    REDHEN_CONTACT_ALTER_COMMENT_AUTHOR => array(
      '#type' => 'checkbox',
      '#title' => t('Use contact as comment author'),
      '#description' => t("If checked, RedHen will alter the display of Comments to display related contact names and link to redhen contacts for users with related RedHen Contacts."),
      '#default_value' => variable_get(REDHEN_CONTACT_ALTER_COMMENT_AUTHOR, FALSE),
    ),
    'redhen_user_registration_form' => array(
      '#type' => 'fieldset',
      '#title' => t('User registration'),
      'settings' => array(
        REDHEN_CONTACT_REG => array(
          '#type' => 'checkbox',
          '#options' => array(
            1,
            1,
          ),
          '#title' => t('Create a contact during user registration'),
          '#default_value' => variable_get(REDHEN_CONTACT_REG, FALSE),
        ),
        REDHEN_CONTACT_REG_TYPE => array(
          '#type' => 'select',
          '#options' => $contact_type_options,
          '#title' => t('Default contact type'),
          '#description' => t('Select the default contact type to create during registration. This can be overriden by appending the contact type machine name in the registration url.'),
          '#default_value' => variable_get(REDHEN_CONTACT_REG_TYPE, FALSE),
          '#states' => array(
            'invisible' => array(
              ':input[name="redhen_contact_reg"]' => array(
                'checked' => FALSE,
              ),
            ),
          ),
        ),
        REDHEN_CONTACT_REG_UPDATE => array(
          '#type' => 'checkbox',
          '#options' => array(
            1,
            1,
          ),
          '#title' => t('Update and link existing contacts'),
          '#description' => t('If a contact is found with the same email as the new Drupal user, it will be updated and linked to the new account.'),
          '#default_value' => variable_get(REDHEN_CONTACT_REG_UPDATE, FALSE),
        ),
        REDHEN_CONTACT_REG_UPDATE_FIELDS => array(
          '#type' => 'checkbox',
          '#options' => array(
            1,
            1,
          ),
          '#title' => t('Update contact fields'),
          '#description' => t('Should the contact fields be updated?'),
          '#default_value' => variable_get(REDHEN_CONTACT_REG_UPDATE_FIELDS, FALSE),
          '#states' => array(
            'invisible' => array(
              ':input[name="redhen_contact_reg_update"]' => array(
                'checked' => FALSE,
              ),
            ),
          ),
        ),
      ),
    ),
    REDHEN_CONTACT_REQUIRE_FIRST_NAME => array(
      '#type' => 'checkbox',
      '#options' => array(
        1,
        1,
      ),
      '#title' => t('Require contacts to have non-empty first name'),
      '#description' => t('Uncheck this if contact first name field should be optional.'),
      '#default_value' => variable_get(REDHEN_CONTACT_REQUIRE_FIRST_NAME, TRUE),
    ),
  );
}