You are here

fboauth.install in Facebook OAuth (FBOAuth) 7

Same filename and directory in other branches
  1. 6 fboauth.install
  2. 7.2 fboauth.install

Provides install and update functions for the Facebook OAuth module.

File

fboauth.install
View source
<?php

/**
 * @file
 * Provides install and update functions for the Facebook OAuth module.
 */

/**
 * Implements hook_install().
 */
function fboauth_install() {

  // Facebook proxy e-mail addresses may be longer than the Drupal-default 254
  // character limit. Extend to 320 characters.
  _fboauth_change_user_mail_field();
}

/**
 * Implements hook_uninstall().
 */
function fboauth_uninstall() {
  variable_del('fboauth_id');
  variable_del('fboauth_secret');
  variable_del('fboauth_anon_connect');
  variable_del('fboauth_user_email');
  variable_del('fboauth_user_username');
  variable_del('fboauth_user_picture');
  variable_del('fboauth_user_profile');
  variable_del('fboauth_user_properties');
  variable_del('fboauth_user_connections');
  variable_del('fboauth_user_fields');
}

/**
 * Implements hook_schema().
 */
function fboauth_schema() {
  $schema['fboauth_users'] = array(
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'fbid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'big',
      ),
    ),
    'primary key' => array(
      'fbid',
    ),
    'indexes' => array(
      'uid_fbid' => array(
        'uid',
        'fbid',
      ),
    ),
  );
  return $schema;
}

/**
 * Implements hook_schema_alter()
 */
function fboauth_schema_alter(&$schema) {
  $schema['users']['fields']['mail']['length'] = 320;
}

/**
 * Extend maximum email length to 320 chars
 *
 * @param $action
 *   Optional. May be specified as "install" to adjust the column length to the
 *   longer limit or "uninstall" to adjust the column to the default length.
 */
function _fboauth_change_user_mail_field($action = 'install') {
  $res = array();
  $schema = array(
    'users' => drupal_get_schema('users'),
  );
  if ($action == 'install') {
    fboauth_schema_alter($schema);
  }
  db_change_field('users', 'mail', 'mail', $schema['users']['fields']['mail']);
  return $res;
}

Functions

Namesort descending Description
fboauth_install Implements hook_install().
fboauth_schema Implements hook_schema().
fboauth_schema_alter Implements hook_schema_alter()
fboauth_uninstall Implements hook_uninstall().
_fboauth_change_user_mail_field Extend maximum email length to 320 chars