You are here

zoomapi.install in Zoom API 7

Same filename and directory in other branches
  1. 8 zoomapi.install
  2. 7.2 zoomapi.install
  3. 2.0.x zoomapi.install

Install, update, and uninstall hooks for the Zoom API module.

File

zoomapi.install
View source
<?php

/**
 * @file
 * Install, update, and uninstall hooks for the Zoom API module.
 */

/**
 * Generate the Zoom API meeting tracker tables.
 */
function zoomapi_update_7101() {
  $schema = zoomapi_schema();
  foreach ($schema as $table_name => $info) {
    if (!db_table_exists($table_name)) {
      db_create_table($table_name, $info);
    }
  }
}

/**
 * Add uuid column to meeting tracker table.
 */
function zoomapi_update_7102() {
  if (!db_field_exists('zoomapi_meeting_tracker', 'uuid')) {
    $schema = zoomapi_schema();
    $field = $schema['zoomapi_meeting_tracker']['fields']['uuid'];
    db_add_field('zoomapi_meeting_tracker', 'uuid', $field, [
      'indexes' => [
        'uuid' => [
          'uuid',
        ],
      ],
    ]);
  }
}

/**
 * Add uuid data to meeting tracker table.
 */
function zoomapi_update_7103() {
  $sql = 'SELECT meeting_id, host_zoom_user_id, data FROM {zoomapi_meeting_tracker}';
  $results = db_query($sql)
    ->fetchAll();
  foreach ($results as $result) {
    $zoom_meeting = unserialize($result->data);
    if (!empty($zoom_meeting['uuid'])) {
      db_update('zoomapi_meeting_tracker')
        ->fields([
        'uuid' => $zoom_meeting['uuid'],
      ])
        ->condition('meeting_id', $result->meeting_id)
        ->condition('host_zoom_user_id', $result->host_zoom_user_id)
        ->execute();
    }
  }
}

/**
 * Change to zoomapi meeting tracker primary key and indexes.
 */
function zoomapi_update_7104() {
  db_drop_primary_key('zoomapi_meeting_tracker');
  db_add_primary_key('zoomapi_meeting_tracker', [
    'uuid',
  ]);
  $indexes = [
    'uuid',
    'meeting_id',
    'host_zoom_user_id',
    'meeting_type',
    'start_time',
    'created',
    'entity_type',
    'entity_id',
    'expires',
  ];
  foreach ($indexes as $index) {
    db_drop_index('zoomapi_meeting_tracker', $index);
    db_add_index('zoomapi_meeting_tracker', "zoomapi_{$index}", [
      $index,
    ]);
  }
}

/**
 * Implements hook_uninstall().
 */
function zoomapi_uninstall() {
  variable_del('zoomapi_key');
  variable_del('zoomapi_secret');
  variable_del('zoomapi_url');
  variable_del('zoomapi_sendrequests_enabled');
  variable_del('zoomapi_user_type_default');
  variable_del('zoomapi_webhooks_enabled');
  variable_del('zoomapi_webhooks_username');
  variable_del('zoomapi_webhooks_password');
}

/**
 * Implements hook_schema().
 */
function zoomapi_schema() {
  $schema['zoomapi_meeting_tracker'] = [
    'description' => 'Temporary meeting tracker to assist with looking up basic meeting info',
    'fields' => [
      'uuid' => [
        'description' => 'The Zoom meeting UUID',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ],
      'meeting_id' => [
        'description' => 'The Zoom provided meeting ID.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ],
      'host_zoom_user_id' => [
        'description' => 'The meeting host zoom provided user ID.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ],
      'topic' => [
        'description' => 'The meeting topic.',
        'type' => 'varchar',
        'length' => 300,
        'not null' => TRUE,
        'default' => '',
      ],
      'meeting_type' => [
        'description' => 'The Zoom meeting type. (1 instant, 2 normal scheduled, 3 recurring no fixed time, 8 recurring fixed time.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'start_time' => [
        'description' => 'The meeting start timestamp.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'duration' => [
        'description' => 'The meeting duration (minutes). For scheduled meeting only.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'timezone' => [
        'description' => 'The meeting timezone.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ],
      'start_url' => [
        'description' => 'The meeting host start/join URL.',
        'type' => 'varchar',
        'length' => 2000,
        'not null' => TRUE,
        'default' => '',
      ],
      'join_url' => [
        'description' => 'The meeting participant join URL.',
        'type' => 'varchar',
        'length' => 2000,
        'not null' => TRUE,
        'default' => '',
      ],
      'created' => [
        'description' => 'The timestamp when this record was created.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'entity_type' => [
        'description' => 'The Drupal entity the meeting was created for.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ],
      'entity_id' => [
        'description' => 'The Drupal entity ID the meeting was created for.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
      'data' => [
        'description' => 'The meeting array / data provided from Zoom.',
        'type' => 'blob',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
      ],
      'expires' => [
        'description' => 'Timestamp when this record is no longer necessary. 0 for permanent.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ],
    ],
    'indexes' => [
      'zoomapi_uuid' => [
        'uuid',
      ],
      'zoomapi_meeting_id' => [
        'meeting_id',
      ],
      'zoomapi_host_zoom_user_id' => [
        'host_zoom_user_id',
      ],
      'zoomapi_meeting_type' => [
        'meeting_type',
      ],
      'zoomapi_start_time' => [
        'start_time',
      ],
      'zoomapi_created' => [
        'created',
      ],
      'zoomapi_entity_type' => [
        'entity_type',
      ],
      'zoomapi_entity_id' => [
        'entity_id',
      ],
      'zoomapi_expires' => [
        'expires',
      ],
    ],
    'primary key' => [
      'uuid',
    ],
  ];
  return $schema;
}

Functions

Namesort descending Description
zoomapi_schema Implements hook_schema().
zoomapi_uninstall Implements hook_uninstall().
zoomapi_update_7101 Generate the Zoom API meeting tracker tables.
zoomapi_update_7102 Add uuid column to meeting tracker table.
zoomapi_update_7103 Add uuid data to meeting tracker table.
zoomapi_update_7104 Change to zoomapi meeting tracker primary key and indexes.