View source
<?php
function tweet_feed_schema() {
$schema['tweet_feed'] = array(
'description' => 'A cache for twitter feeds.',
'fields' => array(
'tweet_id' => array(
'description' => 'The twitter tweet id for this tweet.',
'type' => 'int',
'size' => 'big',
'not null' => FALSE,
),
'tweet' => array(
'description' => 'The text of the tweet.',
'type' => 'text',
'size' => 'normal',
'not null' => TRUE,
),
'created_at' => array(
'description' => 'The date the tweet was posted (timestamp).',
'type' => 'int',
'length' => 11,
'not null' => TRUE,
),
'user_id' => array(
'description' => 'The user ID of the poster.',
'type' => 'varchar',
'length' => 24,
'not null' => TRUE,
),
'profile_image_url' => array(
'description' => 'The URL of the image for the poster of this tweet.',
'type' => 'text',
'size' => 'normal',
'not null' => FALSE,
),
'profile_image_https_url' => array(
'description' => 'The secure URL of the image for the poster of this tweet.',
'type' => 'text',
'size' => 'normal',
'not null' => FALSE,
),
'screen_name' => array(
'description' => 'The screen name of the person tweeting.',
'type' => 'varchar',
'length' => 24,
'not null' => TRUE,
),
'name' => array(
'description' => 'The name of the person tweeting',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'hashtags' => array(
'description' => 'A comma separated list of hashtags without the hash.',
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'is_reply' => array(
'description' => 'Is this tweet a reply to another?',
'type' => 'int',
'length' => 1,
'not null' => TRUE,
'default' => 0,
),
'media_url' => array(
'description' => 'The URL of the image for the poster of this tweet.',
'type' => 'text',
'size' => 'normal',
'not null' => FALSE,
),
'media_url_https' => array(
'description' => 'The secure URL of the image for the poster of this tweet.',
'type' => 'text',
'size' => 'normal',
'not null' => FALSE,
),
),
);
return $schema;
}
function tweet_feed_install() {
db_add_primary_key('tweet_feed', array(
'tweet_id',
));
}
function tweet_feed_uninstall() {
variable_del('tweet_feed_consumer_key');
variable_del('tweet_feed_consumer_key');
variable_del('tweet_feed_consumer_secret');
variable_del('tweet_feed_oauth_token');
variable_del('tweet_feed_oauth_token_secret');
variable_del('tweet_feed_query_type');
variable_del('tweet_feed_search_query');
variable_del('tweet_feed_user_id');
variable_del('tweet_feed_pull_count');
variable_del('tweet_feed_new_window');
variable_del('tweet_feed_truncate');
}
function tweet_feed_update_7104() {
db_change_field('tweet_feed', 'user_id', 'user_id', array(
'description' => 'The user ID of the poster',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
));
}
function tweet_feed_update_7105() {
variable_set('tweet_feed_consumer_key', variable_get('twitter_consumer_key', NULL));
variable_set('tweet_feed_consumer_secret', variable_get('twitter_consumer_secret', NULL));
variable_set('tweet_feed_oauth_token', variable_get('twitter_oauth_token', NULL));
variable_set('tweet_feed_oauth_token_secret', variable_get('twitter_oauth_token_secret', NULL));
variable_set('tweet_feed_search_query', variable_get('twitter_search_query', NULL));
variable_set('tweet_feed_pull_count', variable_get('twitter_pull_count', 50));
variable_set('tweet_feed_new_window', variable_get('twitter_new_window', 0));
variable_del('twitter_pull_count');
variable_del('twitter_search_query');
variable_del('twitter_oauth_token_secret');
variable_del('twitter_oauth_token');
variable_del('twitter_consumer_secret');
variable_del('twitter_consumer_key');
variable_del('twitter_new_window');
}
function tweet_feed_update_7108() {
$schema = tweet_feed_schema();
db_add_field('tweet_feed', 'hashtags', $schema['tweet_feed']['fields']['hashtags']);
}
function tweet_feed_update_7109() {
$schema = tweet_feed_schema();
if (db_field_exists('tweet_feed', 'tid')) {
db_add_index('tweet_feed', 'tid', array(
'tid',
));
db_drop_primary_key('tweet_feed');
db_drop_field('tweet_feed', 'tid');
}
if (!db_field_exists('tweet_feed', 'tweet_id')) {
$id = 1;
db_add_field('tweet_feed', 'tweet_id', $schema['tweet_feed']['fields']['tweet_id']);
$result = db_query('SELECT created_at, user_id FROM {tweet_feed}');
while ($data = $result
->fetchObject()) {
db_update('tweet_feed')
->fields(array(
'tweet_id' => $id++,
))
->condition('created_at', $data->created_at, '=')
->condition('user_id', $data->user_id, '=')
->execute();
}
db_add_primary_key('tweet_feed', array(
'tweet_id',
));
}
}
function tweet_feed_update_7111() {
$schema = tweet_feed_schema();
if (!db_field_exists('tweet_feed', 'profile_image_https_url')) {
db_add_field('tweet_feed', 'profile_image_https_url', $schema['tweet_feed']['fields']['profile_image_https_url']);
}
}
function tweet_feed_update_7113() {
$schema = tweet_feed_schema();
if (!db_field_exists('tweet_feed', 'is_reply')) {
db_add_field('tweet_feed', 'is_reply', $schema['tweet_feed']['fields']['is_reply']);
}
if (!db_field_exists('tweet_feed', 'media_url')) {
db_add_field('tweet_feed', 'media_url', $schema['tweet_feed']['fields']['media_url']);
}
if (!db_field_exists('tweet_feed', 'media_url_https')) {
db_add_field('tweet_feed', 'media_url_https', $schema['tweet_feed']['fields']['media_url_https']);
}
}
function tweet_feed_update_7115() {
$schema = tweet_feed_schema();
db_add_field('tweet_feed', 'name', $schema['tweet_feed']['fields']['name']);
}