You are here

function subscriptions_install in Subscriptions 7

Same name and namespace in other branches
  1. 5.2 subscriptions.install \subscriptions_install()
  2. 5 subscriptions.install \subscriptions_install()
  3. 6 subscriptions.install \subscriptions_install()
  4. 2.0.x subscriptions.install \subscriptions_install()

Implements hook_install().

File

./subscriptions.install, line 91
Subscriptions module installation.

Code

function subscriptions_install() {

  // Remove old cruft if it's still around.
  if (db_table_exists('subscriptions_mail_edit')) {
    db_drop_table('subscriptions_mail_edit');

    // old table from 5.x-2.x
  }
  if (db_table_exists('subscriptions_old')) {
    db_drop_table('subscriptions_old');

    // old backup from 5.x-1.x
  }
  if (db_table_exists('subscriptions_holding')) {
    db_drop_table('subscriptions_holding');

    // old left-over from 5.x-1.x
  }
  if (db_table_exists('subscriptions_holding_old')) {
    db_drop_table('subscriptions_holding_old');

    // old backup from 5.x-1.x
  }
  if (db_table_exists('subscriptions_sent')) {

    // old left-over from first
    db_drop_table('subscriptions_sent');

    // incarnation of 5.x-2.0
  }

  // Create initial data.
  db_insert('subscriptions_user')
    ->fields(array(
    'uid' => -DRUPAL_AUTHENTICATED_RID,
    'digest' => 0,
    'secure_links' => 0,
    'send_interval' => 1,
    'send_updates' => 1,
    'send_comments' => 1,
    'send_interval_visible' => 0,
    'send_updates_visible' => 0,
    'send_comments_visible' => 0,
    'autosub_on_post' => 0,
    'autosub_on_update' => 0,
    'autosub_on_comment' => 0,
    'send_self' => 1,
  ))
    ->execute();
  $select = db_select('users', 'u')
    ->fields('u', array(
    'uid',
  ))
    ->condition('u.uid', 0, '>');
  db_insert('subscriptions_user')
    ->from($select)
    ->execute();
}