View source
<?php
require_once 'includes/Account.inc';
require_once 'includes/Template.inc';
function gathercontent_install() {
db_add_field('node', 'gathercontent_mapping_id', array(
'definition' => 'The ID of GatherContent mapping.',
'type' => 'int',
'unsigned' => TRUE,
));
db_add_field('node', 'gathercontent_id', array(
'definition' => 'The ID of content in GatherContent.',
'type' => 'int',
'unsigned' => TRUE,
));
db_add_field('node', 'gathercontent_import_status', array(
'definition' => 'The ID of content in GatherContent.',
'type' => 'text',
));
db_add_field('file_managed', 'gathercontent_id', array(
'definition' => 'The ID of file in GatherContent.',
'type' => 'int',
'unsigned' => TRUE,
));
_gathercontent_create_text_formats();
}
function _gathercontent_create_text_formats() {
$filtered_html_format = array(
'format' => 'filtered_gathercontent_html',
'name' => 'Filtered GatherContent HTML',
'weight' => 0,
'filters' => array(
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
'filter_html' => array(
'weight' => 1,
'status' => 1,
),
'filter_autop' => array(
'weight' => 2,
'status' => 1,
),
'filter_htmlcorrector' => array(
'weight' => 10,
'status' => 1,
),
),
);
$filtered_html_format = (object) $filtered_html_format;
filter_format_save($filtered_html_format);
}
function gathercontent_uninstall() {
variable_del('gathercontent_username');
variable_del('gathercontent_api_key');
variable_del('gathercontent_account');
variable_del('gathercontent_node_update_method');
db_drop_field('node', 'gathercontent_mapping_id');
db_drop_field('node', 'gathercontent_id');
db_drop_field('node', 'gathercontent_import_status');
db_drop_field('file_managed', 'gathercontent_id');
}
function gathercontent_schema() {
$schema = array();
$schema['gathercontent_mapping'] = array(
'description' => 'The base table for the Mapping entity',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'gathercontent_project_id' => array(
'type' => 'int',
'length' => 11,
'not null' => TRUE,
),
'gathercontent_project' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'gathercontent_template_id' => array(
'type' => 'int',
'length' => 11,
'not null' => TRUE,
),
'gathercontent_template' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'content_type' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
),
'data' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
'created' => array(
'type' => 'int',
'not null' => TRUE,
),
'updated_drupal' => array(
'type' => 'int',
'not null' => FALSE,
),
'template' => array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
),
'primary key' => array(
'id',
),
);
$schema['gathercontent_operation'] = array(
'description' => 'The base table for the GC Operation entity',
'fields' => array(
'uuid' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'type' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'uuid',
),
);
$schema['gathercontent_operation_item'] = array(
'description' => 'The base table for the GC Operation Item entity',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'operation_uuid' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'created' => array(
'description' => 'The Unix timestamp when the GatherContent operation item was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'changed' => array(
'description' => 'The Unix timestamp when the GatherContent operation item was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'item_status' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'item_status_color' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'item_name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'template_name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'status' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'gathercontent_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
),
),
'primary key' => array(
'id',
),
'indexes' => array(
'gc_id_created' => array(
'gathercontent_id',
'created',
),
),
);
return $schema;
}
function gathercontent_schema_alter(&$schema) {
$schema['node']['fields']['gathercontent_mapping_id'] = array(
'definition' => 'The ID of GatherContent mapping.',
'type' => 'int',
'unsigned' => TRUE,
);
$schema['node']['fields']['gathercontent_id'] = array(
'definition' => 'The ID of content in GatherContent.',
'type' => 'int',
'unsigned' => TRUE,
);
$schema['node']['fields']['gathercontent_import_status'] = array(
'definition' => 'The ID of content in GatherContent.',
'type' => 'text',
);
$schema['file_managed']['fields']['gathercontent_id'] = array(
'definition' => 'The ID of file in GatherContent.',
'type' => 'int',
'unsigned' => TRUE,
);
if (isset($schema['gathercontent_mapping']['fields']['updated_gathercontent'])) {
unset($schema['gathercontent_mapping']['fields']['updated_gathercontent']);
}
}
function gathercontent_update_7301() {
db_change_field('gathercontent_mapping', 'content_type', 'content_type', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'default' => '',
));
db_change_field('gathercontent_mapping', 'data', 'data', array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
));
}
function gathercontent_update_7302() {
db_add_field('node', 'gathercontent_import_status', array(
'definition' => 'The ID of content in GatherContent.',
'type' => 'text',
));
}
function gathercontent_update_7303() {
$acc_obj = new GatherContent\Account();
$accounts = $acc_obj
->getAccounts();
$local_account = variable_get('gathercontent_account');
reset($local_account);
$local_account_id = key($local_account);
foreach ($accounts as $account) {
if ($local_account_id === $account->id) {
variable_set('gathercontent_urlkey', $account->slug);
break;
}
}
}
function gathercontent_update_7304() {
db_drop_field('gathercontent_mapping', 'updated_gathercontent');
}
function gathercontent_update_7305() {
db_add_field('gathercontent_mapping', 'template', array(
'type' => 'blob',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
));
}
function gathercontent_update_7306() {
$mappings = entity_load('gathercontent_mapping');
$tmp = new GatherContent\Template();
foreach ($mappings as $mapping) {
if (empty($mapping->template)) {
$template = $tmp
->getTemplate($mapping->gathercontent_template_id);
$mapping->template = serialize($template);
$mapping
->save();
}
}
}
function gathercontent_update_7307() {
db_create_table('gathercontent_operation', drupal_get_schema_unprocessed('gathercontent', 'gathercontent_operation'));
db_create_table('gathercontent_operation_item', drupal_get_schema_unprocessed('gathercontent', 'gathercontent_operation_item'));
}
function gathercontent_update_7308() {
_gathercontent_create_text_formats();
$views = views_get_all_views();
foreach ($views as $view) {
if ($view->disabled) {
continue;
}
if ($view->type == t('Overridden')) {
$view
->delete();
ctools_include('object-cache');
ctools_object_cache_clear('view', $view->name);
}
}
}
function gathercontent_update_7309() {
ctools_include('object-cache');
ctools_object_cache_clear('view', 'mapping');
}
function gathercontent_update_7310() {
$created = array(
'description' => 'The Unix timestamp when the GatherContent operation item was created.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
$changed = array(
'description' => 'The Unix timestamp when the GatherContent operation item was most recently saved.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
);
db_add_field('gathercontent_operation_item', 'created', $created);
db_add_field('gathercontent_operation_item', 'changed', $changed);
db_add_index('gathercontent_operation_item', 'gc_id_created', array(
'gathercontent_id',
'created',
));
}
function gathercontent_update_7311() {
ctools_include('object-cache');
ctools_object_cache_clear('view', 'mapping');
}
function gathercontent_requirements($phase) {
if ($phase !== 'runtime') {
return array();
}
$t = get_t();
$requirements = array(
'gathercontent_tablesorter' => array(
'title' => $t('GatherContent: Tablesorter plugin'),
'value' => $t('Unavailable.'),
'description' => $t('Install <a href="@libraries-page">Libraries</a> module.', array(
'@libraries-page' => 'https://www.drupal.org/project/libraries',
)),
'severity' => REQUIREMENT_INFO,
),
);
if (module_exists('libraries')) {
$tablesorter_lib_info = libraries_detect('tablesorter-mottie');
if ($tablesorter_lib_info['installed'] && $tablesorter_lib_info['version']) {
$requirements['gathercontent_tablesorter']['value'] = $tablesorter_lib_info['version'];
$requirements['gathercontent_tablesorter']['severity'] = REQUIREMENT_OK;
unset($requirements['gathercontent_tablesorter']['description']);
}
else {
$requirements['gathercontent_tablesorter']['description'] = $t('Download <a href="@tablesorter-github">Mottie\'s tablesorter plugin</a> to <code>sites/all/libraries</code> toget sortable table headers at GatherContent admin UI. Rename it\'s folder to <code>tablesorter-mottie</code>.', array(
'@tablesorter-github' => 'https://github.com/Mottie/tablesorter/archive/v2.25.8.zip',
));
}
}
return $requirements;
}