instagram_social_feed.install in Instagram Social Feed 7
Same filename and directory in other branches
Defines table schema and update hooks.
File
instagram_social_feed.installView source
<?php
/**
* @file
* Defines table schema and update hooks.
*/
/**
* Implements hook_uninstall().
*/
function instagram_social_feed_uninstall() {
// API data.
variable_del('instagram_social_feed_api_key');
variable_del('instagram_social_feed_user_id');
variable_del('instagram_social_feed_username');
// Client setup data.
variable_del('instagram_social_feed_client_secret');
variable_del('instagram_social_feed_redirect_uri');
variable_del('instagram_social_feed_client_id');
variable_del('instagram_social_feed_last_run');
// Publishing information.
variable_del('instagram_social_feed_passive_timeout');
// Block data.
variable_del('instagram_social_feed_block_count');
variable_del('instagram_social_feed_feed_selection');
variable_del('instagram_social_feed_more_uri');
variable_del('instagram_social_feed_more_text');
}
/**
* Implements hook_schema().
*/
function instagram_social_feed_schema() {
$schema['instagram_social_feed_photos'] = array(
'description' => 'Stores instagram photo data',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique ID.',
'no export' => TRUE,
),
'feed_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'description' => 'Corresponding feed ID.',
),
'user_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'User ID',
),
'tags' => array(
'type' => 'text',
'length' => 255,
'not null' => TRUE,
'description' => 'Tags',
),
'created_time' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Created time.',
),
'low_resolution' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Low resolution photo.',
),
'low_resolution_width' => array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Width of low resolution photo.',
),
'low_resolution_height' => array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Height of low resolution photo.',
),
'thumbnail' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Photo thumbnail.',
),
'thumbnail_width' => array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Width of thumbnail photo.',
),
'thumbnail_height' => array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Height of thumbnail photo.',
),
'standard_resolution' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Standard photo resolution',
),
'standard_resolution_width' => array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Width of standard resolution photo.',
),
'standard_resolution_height' => array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Height of standard resolution photo.',
),
'caption' => array(
'type' => 'blob',
'size' => 'normal',
'not null' => FALSE,
'description' => 'Caption',
),
'instagram_id' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Instagram ID',
),
'instagram_link' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Instagram Link',
),
'instagram_user' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Instagram Username',
),
'approve' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Approval status',
),
),
'primary key' => array(
'id',
),
);
$schema['instagram_social_feeds'] = array(
'description' => 'Stores Instagram feed settings',
'export' => array(
'key' => 'name',
'key name' => 'Name',
'primary key' => 'id',
'identifier' => 'preset',
// Exports will be defined as $preset
'default hook' => 'default_nitf_xml_preset',
// Function hook name.
'api' => array(
'owner' => 'instagram_social_feed',
'api' => 'default_instagram_social_feed_presets',
// Base name for api include files.
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Primary Key: Unique ID.',
'no export' => TRUE,
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
'description' => 'Client title',
),
'feed_type' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Integer indicating the feed type - refer to .module file for constants',
),
'search_term' => array(
'type' => 'varchar',
'length' => 255,
'default' => '',
'description' => 'Hashtag to search',
),
'user_id' => array(
'type' => 'varchar',
'length' => 255,
'default' => '',
'description' => 'User ID',
),
'auto_publish' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Boolean indicating whether to auto publish photos',
),
'enabled' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Boolean indicating whether to enable this feed',
),
),
'primary key' => array(
'id',
),
);
return $schema;
}
/**
* Make user_id column unsigned.
*/
function instagram_social_feed_update_7101() {
$new_field = array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'User ID',
);
db_change_field('instagram_social_feed_photos', 'user_id', 'user_id', $new_field);
}
/**
* Change Instagram caption field to blob to accommodate utf8mb4 characters.
*
* @todo This schema update is a workaround and should be reverted as soon as
* Drupal's MySQL implementation properly supports the utf8mb4 character set.
*
* @see https://www.drupal.org/node/1910376
*/
function instagram_social_feed_update_7102() {
if (db_field_exists('instagram_social_feed_photos', 'caption')) {
$spec = array(
// Using a blob instead of a text type make it possible for MySQL to
// handle extended UTF8 characters, like emoji.
// @see https://www.drupal.org/node/1910376
'type' => 'blob',
// Balance size vs performance. The Instagram caption allows for captions
// that are 2200 characters in length, so in theory MySQL's default
// blob length of 16KB should be enough.
'size' => 'normal',
'not null' => FALSE,
);
db_change_field('instagram_social_feed_photos', 'caption', 'caption', $spec);
}
}
/**
* Change Instagram caption field to blob to accommodate utf8mb4 characters.
*
* @todo This schema update is a workaround and should be reverted as soon as
* Drupal's MySQL implementation properly supports the utf8mb4 character set.
*
* @see https://www.drupal.org/node/1910376
*/
function instagram_social_feed_update_7103() {
if (db_field_exists('instagram_social_feed_photos', 'caption')) {
$spec = array(
// Using a blob instead of a text type make it possible for MySQL to
// handle extended UTF8 characters, like emoji.
// @see https://www.drupal.org/node/1910376
'type' => 'blob',
// Balance size vs performance. The Instagram caption allows for captions
// that are 2200 characters in length, so in theory MySQL's default
// blob length of 16KB should be enough.
'size' => 'normal',
'not null' => FALSE,
);
db_change_field('instagram_social_feed_photos', 'caption', 'caption', $spec);
}
}
/**
* Add field to store user id.
*/
function instagram_social_feed_update_7104() {
if (!db_field_exists('instagram_social_feeds', 'user_id')) {
db_add_field('instagram_social_feeds', 'user_id', array(
'type' => 'varchar',
'length' => 255,
'default' => '',
'description' => 'User ID',
));
}
}
/**
* Add width, height columns for photos to instagram_social_feed_photos table.
*/
function instagram_social_feed_update_7105() {
$spec = array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Width of low resolution photo.',
);
db_add_field('instagram_social_feed_photos', 'low_resolution_width', $spec);
$spec = array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Height of low resolution photo.',
);
db_add_field('instagram_social_feed_photos', 'low_resolution_height', $spec);
$spec = array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Width of thumbnail photo.',
);
db_add_field('instagram_social_feed_photos', 'thumbnail_width', $spec);
$spec = array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Height of thumbnail photo.',
);
db_add_field('instagram_social_feed_photos', 'thumbnail_height', $spec);
$spec = array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Width of standard resolution photo.',
);
db_add_field('instagram_social_feed_photos', 'standard_resolution_width', $spec);
$spec = array(
'type' => 'varchar',
'length' => 25,
'not null' => TRUE,
'default' => '',
'description' => 'Height of standard resolution photo.',
);
db_add_field('instagram_social_feed_photos', 'standard_resolution_height', $spec);
}
Functions
Name![]() |
Description |
---|---|
instagram_social_feed_schema | Implements hook_schema(). |
instagram_social_feed_uninstall | Implements hook_uninstall(). |
instagram_social_feed_update_7101 | Make user_id column unsigned. |
instagram_social_feed_update_7102 | Change Instagram caption field to blob to accommodate utf8mb4 characters. |
instagram_social_feed_update_7103 | Change Instagram caption field to blob to accommodate utf8mb4 characters. |
instagram_social_feed_update_7104 | Add field to store user id. |
instagram_social_feed_update_7105 | Add width, height columns for photos to instagram_social_feed_photos table. |