You are here

function anonymous_publishing_schema in Anonymous Publishing 7

Same name and namespace in other branches
  1. 8 anonymous_publishing.install \anonymous_publishing_schema()

Implements hook_schema().

File

./anonymous_publishing.install, line 11
Install and uninstall hooks.

Code

function anonymous_publishing_schema() {
  $schema['anonymous_publishing'] = array(
    'description' => 'Record of anonymous nodes (only needed for activation).',
    'fields' => array(
      'apid' => array(
        'description' => 'primary key',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => '{node}.nid reference',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'cid' => array(
        'description' => '{comment}.cid reference',
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'akey' => array(
        'description' => 'activation key',
        'type' => 'char',
        'length' => 60,
        'not null' => FALSE,
        'default' => '',
      ),
      'verified' => array(
        'description' => '0 = not verified',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'alias' => array(
        'description' => 'byline/alias set by user',
        'type' => 'varchar',
        'length' => EMAIL_MAX_LENGTH,
        'not null' => FALSE,
        'default' => NULL,
      ),
      'email' => array(
        'description' => 'activation email',
        'type' => 'varchar',
        'length' => EMAIL_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
      ),
      'phone' => array(
        'description' => 'phone number for activation link [#2646076]',
        'type' => 'varchar',
        'length' => 15,
        'not null' => TRUE,
        'default' => '',
      ),
      'ip' => array(
        'description' => 'IP-address used to post contents.',
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'unique keys' => array(
      'akey' => array(
        'akey',
      ),
    ),
    'primary key' => array(
      'apid',
    ),
    'foreign keys' => array(
      'fk_node' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
      'fk_comment' => array(
        'table' => 'comment',
        'columns' => array(
          'cid' => 'cid',
        ),
      ),
    ),
  );
  $schema['anonymous_publishing_realname'] = array(
    'description' => 'Record of real user name for nodes published asanon.',
    'fields' => array(
      'rnid' => array(
        'description' => 'primary key',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'description' => '{node}.nid reference',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'cid' => array(
        'description' => '{comment}.cid reference',
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
      ),
      'uid' => array(
        'description' => '{users}.uid reference',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'rnid',
    ),
    'foreign keys' => array(
      'fk_node2' => array(
        'table' => 'node',
        'columns' => array(
          'nid' => 'nid',
        ),
      ),
      'fk_comment2' => array(
        'table' => 'comment',
        'columns' => array(
          'cid' => 'cid',
        ),
      ),
      'fk_user2' => array(
        'table' => 'users',
        'columns' => array(
          'uid' => 'uid',
        ),
      ),
    ),
  );
  $schema['anonymous_publishing_emails'] = array(
    'description' => 'For keeping track of emails used by anonymous publishers.',
    'fields' => array(
      'auid' => array(
        'description' => 'anonymous user id',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'email' => array(
        'description' => 'email used to activate',
        'type' => 'varchar',
        'length' => EMAIL_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
      ),
      'alias' => array(
        'description' => 'Alias to be associated with this email (may be used as byline).',
        'type' => 'varchar',
        'length' => EMAIL_MAX_LENGTH,
        'not null' => TRUE,
        'default' => '',
      ),
      'ipaddress' => array(
        'description' => 'IP-address used to activate',
        'type' => 'varchar',
        'length' => 40,
        'not null' => TRUE,
        'default' => '',
      ),
      'firstseen' => array(
        'description' => 'First seen as an ISO formatted date',
        'type' => 'varchar',
        'mysql_type' => 'date',
        'pgsql_type' => 'date',
        'not null' => TRUE,
        'default' => '1970-01-01',
      ),
      'lastseen' => array(
        'description' => 'Last seen as an ISO formatted date',
        'type' => 'varchar',
        'mysql_type' => 'date',
        'pgsql_type' => 'date',
        'not null' => TRUE,
        'default' => '1970-01-01',
      ),
      'blocked' => array(
        'description' => '0 = in good standing; 1 = blocked',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'email' => array(
        'email',
      ),
    ),
    'primary key' => array(
      'auid',
    ),
  );
  $schema['anonymous_publishing_bots'] = array(
    'description' => 'Counts visits by bots based upon IP-address.',
    'fields' => array(
      'id' => array(
        'description' => 'primary index',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'ip' => array(
        'description' => 'IP-address of bot',
        'type' => 'varchar',
        'length' => 16,
        'not null' => TRUE,
        'default' => '',
      ),
      'visits' => array(
        'description' => 'Number of visits',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'first' => array(
        'description' => 'First seen as a Unix timestamp',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'last' => array(
        'description' => 'Last seen as a Unix timestamp',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'ip' => array(
        'ip',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}