You are here

function twitter_update_6300 in Twitter 6.4

Same name and namespace in other branches
  1. 6.5 twitter.install \twitter_update_6300()
  2. 6.3 twitter.install \twitter_update_6300()

Update from 2.x to 3.x

File

./twitter.install, line 552
Install, update and uninstall functions for the twitter module.

Code

function twitter_update_6300() {
  $ret = array();

  // add additional fields to {twitter_account}
  db_add_field($ret, 'twitter_account', 'uid', array(
    'description' => t("The {users}.uid of the owner of this account"),
    'type' => 'int',
    'unsigned' => TRUE,
    'size' => 'big',
    'not null' => TRUE,
  ));
  db_add_field($ret, 'twitter_account', 'host', array(
    'description' => t('The host for this account can be a laconi.ca instance'),
    'type' => 'varchar',
    'length' => 255,
  ));
  db_add_field($ret, 'twitter_account', 'password', array(
    'description' => t("The password for the Twitter account."),
    'type' => 'varchar',
    'length' => 64,
  ));
  db_add_field($ret, 'twitter_account', 'oauth_token', array(
    'description' => t('The token_key for oauth-based access.'),
    'type' => 'varchar',
    'length' => 64,
  ));
  db_add_field($ret, 'twitter_account', 'oauth_token_secret', array(
    'description' => t('The token_secret for oauth-based access.'),
    'type' => 'varchar',
    'length' => 64,
  ));
  db_add_field($ret, 'twitter_account', 'friends_count', array(
    'description' => t("The number of users this {twitter_account} is following."),
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_field($ret, 'twitter_account', 'statuses_count', array(
    'description' => t("The total number of status updates performed by a user, excluding direct messages sent."),
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_field($ret, 'twitter_account', 'favourites_count', array(
    'description' => t("The  number of statuses a user has marked as favorite."),
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_field($ret, 'twitter_account', 'profile_background_color', array(
    'description' => t("hex RGB value for a user's background color"),
    'type' => 'varchar',
    'length' => 6,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, 'twitter_account', 'profile_text_color', array(
    'description' => t("hex RGB value for a user's text color"),
    'type' => 'varchar',
    'length' => 6,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, 'twitter_account', 'profile_link_color', array(
    'description' => t("hex RGB value for a user's link color"),
    'type' => 'varchar',
    'length' => 6,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, 'twitter_account', 'profile_sidebar_fill_color', array(
    'description' => t("hex RGB value for a user's sidebar color"),
    'type' => 'varchar',
    'length' => 6,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, 'twitter_account', 'profile_sidebar_border_color', array(
    'description' => t("hex RGB value for a user's border color"),
    'type' => 'varchar',
    'length' => 6,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, 'twitter_account', 'profile_background_image_url', array(
    'description' => t("The url of the {twitter_account}'s profile image."),
    'type' => 'varchar',
    'length' => 255,
  ));
  db_add_field($ret, 'twitter_account', 'profile_background_tile', array(
    'description' => t("Boolean indicating if a user's background is tiled."),
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 1,
  ));
  db_add_field($ret, 'twitter_account', 'verified', array(
    'description' => t("Indicates if a user is verified."),
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 1,
  ));
  db_add_field($ret, 'twitter_account', 'created_at', array(
    'description' => t("Date and time the {twitter_account} was created."),
    'type' => 'varchar',
    'length' => 64,
    'not null' => TRUE,
    'default' => '',
  ));
  db_add_field($ret, 'twitter_account', 'created_time', array(
    'description' => t("A duplicate of {twitter_account}.created_at in UNIX timestamp format."),
    'type' => 'int',
    'not null' => TRUE,
  ));
  db_add_field($ret, 'twitter_account', 'utc_offset', array(
    'description' => t("A duplicate of {twitter_account}.created_at in UNIX timestamp format."),
    'type' => 'int',
    'not null' => TRUE,
  ));
  db_add_field($ret, 'twitter_account', 'import', array(
    'description' => t("Boolean flag indicating whether the {twitter_user}'s posts should be pulled in by the site."),
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 1,
  ));
  db_add_field($ret, 'twitter_account', 'is_global', array(
    'description' => t("Boolean flag indicating if this account is available for global use"),
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  if (db_table_exists('twitter_user')) {
    $result = db_query("SELECT * FROM {twitter_user} ORDER BY uid DESC");
    while ($row = db_fetch_array($result)) {
      db_query("UPDATE {twitter_account} SET uid=%d, password='%s', import=%d WHERE screen_name='%s'", $row['uid'], $row['password'], $row['import'], $row['screen_name']);
    }
    db_drop_table($ret, 'twitter_user');
  }
  drupal_install_modules(array(
    'twitter_post',
  ));
  return $ret;
}