You are here

function mo_auth_install in Google Authenticator / 2 Factor Authentication - 2FA 7

Implements hook_install().

File

./mo_auth.install, line 12

Code

function mo_auth_install() {
  $field_bases = array();
  $field_bases['mo_auth_password_checked'] = array(
    'field_name' => 'mo_auth_password_checked',
    'settings' => array(
      'max_length' => 255,
    ),
    'type' => 'text',
  );
  $field_bases['miniorange_registered_email'] = array(
    'field_name' => 'miniorange_registered_email',
    'settings' => array(
      'max_length' => 255,
    ),
    'type' => 'text',
  );
  $field_bases['configured_auth_methods'] = array(
    'field_name' => 'configured_auth_methods',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
    'settings' => array(
      'allowed_values' => array(
        'OUT OF BAND EMAIL' => 'OUT OF BAND EMAIL',
        'MOBILE AUTHENTICATION' => 'MOBILE AUTHENTICATION',
        'GOOGLE AUTHENTICATOR' => 'GOOGLE AUTHENTICATOR',
        'SOFT TOKEN' => 'SOFT TOKEN',
        'PUSH NOTIFICATIONS' => 'PUSH NOTIFICATIONS',
        'SMS' => 'SMS',
        'SMS AND EMAIL' => 'SMS AND EMAIL',
      ),
    ),
    'type' => 'list_text',
  );
  foreach ($field_bases as $field) {
    field_create_field($field);
  }
  $field_instances['user-user-miniorange_registered_email'] = array(
    'bundle' => 'user',
    'entity_type' => 'user',
    'field_name' => 'miniorange_registered_email',
    'label' => 'Registered Email for Second Factor',
  );
  $field_instances['user-user-mo_auth_password_checked'] = array(
    'bundle' => 'user',
    'entity_type' => 'user',
    'field_name' => 'mo_auth_password_checked',
    'label' => 'mo_auth_password_checked',
  );
  $field_instances['user-user-configured_auth_methods'] = array(
    'bundle' => 'user',
    'display' => array(
      'default' => array(
        'label' => 'above',
        'module' => 'list',
        'settings' => array(),
        'type' => 'list_default',
        'weight' => 1,
      ),
    ),
    'entity_type' => 'user',
    'field_name' => 'configured_auth_methods',
    'label' => 'Configured Methods for Second Factor',
  );
  $field_instances['user-user-configured_auth_methods'] = array(
    'bundle' => 'user',
    'display' => array(
      'default' => array(
        'label' => 'above',
        'module' => 'list',
        'settings' => array(),
        'type' => 'list_default',
        'weight' => 1,
      ),
    ),
    'entity_type' => 'user',
    'field_name' => 'configured_auth_methods',
    'label' => 'Configured Methods for Second Factor',
  );
  foreach ($field_instances as $instance) {
    field_create_instance($instance);
  }
  if (!db_table_exists('mo_auth_user_track')) {
    drupal_install_schema('mo_auth');
  }
}