You are here

function simplenews_schema in Simplenews 7

Same name and namespace in other branches
  1. 8.2 simplenews.install \simplenews_schema()
  2. 8 simplenews.install \simplenews_schema()
  3. 6.2 simplenews.install \simplenews_schema()
  4. 6 simplenews.install \simplenews_schema()
  5. 7.2 simplenews.install \simplenews_schema()
  6. 3.x simplenews.install \simplenews_schema()

Implements hook_schema().

File

./simplenews.install, line 11
Install, update and uninstall functions for the simplenews module

Code

function simplenews_schema() {
  $schema['simplenews_category'] = array(
    'description' => 'Simplenews newsletter categories.',
    'fields' => array(
      'tid' => array(
        'description' => '{taxonomy_term_data}.tid used as newsletter category.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'format' => array(
        'type' => 'varchar',
        'length' => 8,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Format of the newsletter email (plain, html).',
      ),
      'priority' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Email priority according to RFC 2156 and RFC 5231 (0 = none; 1 = highest; 2 = high; 3 = normal; 4 = low; 5 = lowest).',
      ),
      'receipt' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
        'description' => 'Boolean indicating request for email receipt confirmation according to RFC 2822.',
      ),
      'from_name' => array(
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Sender name for newsletter emails.',
      ),
      'email_subject' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Subject of newsletter email. May contain tokens.',
      ),
      'from_address' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Sender address for newsletter emails',
      ),
      'hyperlinks' => array(
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'Flag indicating type of hyperlink conversion (1 = hyperlinks are in-line; 0 = hyperlinks are placed at email bottom).',
      ),
      'new_account' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'How to treat subscription at account creation (none = None; on = Default on; off = Default off; silent = Invisible subscription).',
      ),
      'opt_inout' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'How to treat subscription confirmation (hidden = Newsletter is hidden from the user; single = Single opt-in; double = Double opt-in).',
      ),
      'block' => array(
        'description' => 'For this category a subscription block is available.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'tid',
    ),
  );
  $schema['simplenews_newsletter'] = array(
    'description' => 'Simplenews newsletter data.',
    'fields' => array(
      'nid' => array(
        'description' => '{node} that is used as newsletter.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'tid' => array(
        'description' => 'The newsletter category {simplenews_category}.tid this newsletter belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'sent status of the newsletter issue (0 = not sent; 1 = pending; 2 = sent, 3 = send on publish).',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'sent_subscriber_count' => array(
        'description' => 'The count of subscribers to the newsletter when it was sent.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
    'foreign keys' => array(
      'nid' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
    ),
  );
  $schema['simplenews_subscriber'] = array(
    'description' => 'Subscribers to {simplenews_category}. Many-to-many relation via {simplenews_subscription}',
    'fields' => array(
      'snid' => array(
        'description' => 'Primary key: Unique subscriber ID.',
        'type' => 'serial',
        'not null' => TRUE,
      ),
      'activated' => array(
        'description' => 'Boolean indicating the status of the subscription.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'mail' => array(
        'description' => "The subscriber's email address.",
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'uid' => array(
        'description' => 'The {users}.uid that has the same email address.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'language' => array(
        'type' => 'varchar',
        'length' => 12,
        'not null' => TRUE,
        'default' => '',
        'description' => 'Subscriber preferred language.',
      ),
      'timestamp' => array(
        'description' => 'UNIX timestamp of when the user is (un)subscribed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'changes' => array(
        'description' => 'Contains the requested subscription changes',
        'type' => 'text',
        'serialize' => TRUE,
      ),
      'created' => array(
        'description' => 'UNIX timestamp of when the subscription record was added.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'snid',
    ),
    'indexes' => array(
      'mail' => array(
        'mail',
      ),
      'uid' => array(
        'uid',
      ),
    ),
    'foreign keys' => array(
      'uid' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['simplenews_subscription'] = array(
    'description' => 'Newsletter subscription data. Which subscriber is subscribed to which mailing list.',
    'fields' => array(
      'snid' => array(
        'description' => 'The {simplenews_subscriber}.snid who is subscribed.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'tid' => array(
        'description' => 'The category ({simplenews_category}.tid) the subscriber is subscribed to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'A flag indicating whether the user is subscribed (1) or unsubscribed (0).',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 1,
      ),
      'timestamp' => array(
        'description' => 'UNIX timestamp of when the user is (un)subscribed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'source' => array(
        'description' => 'The source via which the user is (un)subscription.',
        'type' => 'varchar',
        'length' => 24,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array(
      'snid',
      'tid',
    ),
    'foreign keys' => array(
      'snid' => array(
        'table' => 'simplenews_subscriber',
        'columns' => array(
          'snid' => 'snid',
        ),
      ),
      'tid' => array(
        'table' => 'simplenews_category',
        'columns' => array(
          'tid' => 'tid',
        ),
      ),
    ),
  );
  $schema['simplenews_mail_spool'] = array(
    'description' => 'Spool for temporary storage of newsletter emails.',
    'fields' => array(
      'msid' => array(
        'description' => 'The primary identifier for a mail spool record.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'mail' => array(
        'description' => 'The formatted email address of mail message recipient.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'nid' => array(
        'description' => 'The {node}.nid of this newsletter.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'tid' => array(
        'description' => 'The {simplenews_category}.tid this newsletter belongs to.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'status' => array(
        'description' => 'The sent status of the email (0 = hold, 1 = pending, 2 = done).',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'error' => array(
        'description' => 'A boolean indicating whether an error occured while sending the email.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'timestamp' => array(
        'description' => 'The time status was set or changed.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'data' => array(
        'type' => 'text',
        'not null' => FALSE,
        'size' => 'big',
        'serialize' => TRUE,
        'description' => 'A serialized array of name value pairs that are related to the email address.',
      ),
      'snid' => array(
        'description' => 'Foreign key for subscriber table ({simplenews_subscriptions}.snid)',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'msid',
    ),
    'indexes' => array(
      'tid' => array(
        'tid',
      ),
      'status' => array(
        'status',
      ),
      'snid_tid' => array(
        'snid',
        'tid',
      ),
    ),
    'foreign keys' => array(
      'nid' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
      'tid' => array(
        'table' => 'simplenews_category',
        'columns' => array(
          'tid',
        ),
      ),
      'snid_tid' => array(
        'table' => 'simplenews_subscription',
        'columns' => array(
          'snid' => 'snid',
          'tid' => 'tid',
        ),
      ),
    ),
  );
  return $schema;
}