You are here

google_calendar_block.install in Google Calendar Block 7

Same filename and directory in other branches
  1. 7.2 google_calendar_block.install

Install, update and uninstall functions for the google_calendar_block module.

File

google_calendar_block.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the google_calendar_block module.
 */

/**
 * Implements hook_requirements().
 */
function google_calendar_block_requirements($phase) {
  $requirements = array();
  $t = get_t();
  if ($phase == 'runtime') {

    // Check if the ZF1 PHP library is installed.
    if (($library = libraries_detect('zf1')) && !empty($library['installed'])) {
      $requirements['google_calendar_block_library'] = array(
        'title' => $t('ZF1 PHP library'),
        'value' => $t('Installed'),
        'severity' => REQUIREMENT_OK,
      );
    }
    else {
      $requirements['google_calendar_block_library'] = array(
        'title' => $t('ZF1 PHP library'),
        'value' => $t('Not installed'),
        'description' => $library['error message'],
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}

/**
 * Implements hook_schema().
 */
function google_calendar_block_schema() {
  $schema['google_calendar_block'] = array(
    'description' => 'The table for storing Google Calendar blocks.',
    'fields' => array(
      'bid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'description' => "The block's {block}.bid.",
      ),
      'info' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Block description.',
      ),
      'calendar_user' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Calendar user.',
      ),
      'calendar_visibility' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Calendar visibility.',
      ),
      'data' => array(
        'type' => 'blob',
        'size' => 'big',
        'not null' => TRUE,
        'serialize' => TRUE,
        'description' => 'Serialized data containing the calendar properties.',
      ),
    ),
    'unique keys' => array(
      'info' => array(
        'info',
      ),
      'calendar_visibility' => array(
        'calendar_visibility',
      ),
    ),
    'primary key' => array(
      'bid',
    ),
  );
  $schema['cache_google_calendar_block'] = drupal_get_schema_unprocessed('system', 'cache');
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function google_calendar_block_uninstall() {

  // Remove blocks
  db_delete('block')
    ->condition('module', 'google_calendar_block')
    ->execute();

  // Remove block roles.
  db_delete('block_role')
    ->condition('module', 'google_calendar_block')
    ->execute();

  // Clear the site cache.
  cache_clear_all();
}