You are here

fboauth.install in Facebook OAuth (FBOAuth) 7.2

Same filename and directory in other branches
  1. 6 fboauth.install
  2. 7 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_apiversion');
  variable_del('fboauth_secret');
  variable_del('fboauth_debug');
  variable_del('fboauth_popup');
  variable_del('fboauth_always_load_js');
  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;
}

/**
 * FBAPI v2.0: Remove deprecated user_checkins permission.
 */
function fboauth_update_7201() {
  if ($connections = variable_get('fboauth_user_connections')) {
    $deprecated = array(
      'checkins',
    );
    foreach ($deprecated as $permission) {
      $permission_key = array_search($permission, $connections);
      if (is_numeric($permission_key)) {
        unset($connections[$permission_key]);
      }
    }
    variable_set('fboauth_user_connections', $connections);
  }
}

/**
 * FBAPI v2.3: Remove deprecated user_interests and user_activities permissions.
 */
function fboauth_update_7202() {
  if ($connections = variable_get('fboauth_user_connections')) {
    $deprecated = array(
      'activities',
      'interests',
    );
    foreach ($deprecated as $permission) {
      $permission_key = array_search($permission, $connections);
      if (is_numeric($permission_key)) {
        unset($connections[$permission_key]);
      }
    }
    variable_set('fboauth_user_connections', $connections);
  }
}

/**
 * FBAPI v2.0: Username deprecated. Use Real name for user name import.
 */
function fboauth_update_7203() {
  if (variable_get('fboauth_user_username', 'name') == 'username') {
    variable_set('fboauth_user_username', 'name');
  }
}

/**
 * FBAPI v2.0: Remove access to notes.
 */
function fboauth_update_7204() {
  if ($connections = variable_get('fboauth_user_connections')) {
    $deprecated = array(
      'notes',
    );
    foreach ($deprecated as $permission) {
      $permission_key = array_search($permission, $connections);
      if (is_numeric($permission_key)) {
        unset($connections[$permission_key]);
      }
    }
    variable_set('fboauth_user_connections', $connections);
  }
}

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_update_7201 FBAPI v2.0: Remove deprecated user_checkins permission.
fboauth_update_7202 FBAPI v2.3: Remove deprecated user_interests and user_activities permissions.
fboauth_update_7203 FBAPI v2.0: Username deprecated. Use Real name for user name import.
fboauth_update_7204 FBAPI v2.0: Remove access to notes.
_fboauth_change_user_mail_field Extend maximum email length to 320 chars