party_simplenews.install in Party 8.2
Install information for Party Simplenews module
File
modules/party_simplenews/party_simplenews.installView source
<?php
/**
* @file Install information for Party Simplenews module
*/
/**
* Implements hook_schema()
*/
function party_simplenews_schema() {
$schema['party_simplenews_subscriber'] = array(
'description' => 'A table of party ids to subscriber ids',
'fields' => array(
'snid' => array(
'description' => 'Primary key: Unique subscriber ID.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'party_id' => array(
'description' => 'The {party}.pid that has the same email address.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'party_field_ref' => array(
'description' => 'The reference of the field on the party this refers to. Of the form DATA_SET_NAME__ENTITY_ID__FIELD_NAME__DELTA',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'snid',
),
'indexes' => array(
'party_mail' => array(
'party_id',
'party_field_ref',
),
),
'foreign keys' => array(
'party_id' => array(
'table' => 'party',
'columns' => array(
'party_id' => 'pid',
),
),
),
);
$schema['party_subscription_settings'] = array(
'description' => 'Entity table to store subscription settings against',
'fields' => array(
'subscription_settings_id' => array(
'description' => 'Primary key: Unique subscriber ID.',
'type' => 'serial',
'not null' => TRUE,
),
'data' => array(
'description' => 'An of settings to do with this partys subscription',
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
),
),
'primary key' => array(
'subscription_settings_id',
),
);
return $schema;
}
/**
* Add data field so that the entity will actually save
*/
function party_simplenews_update_7004() {
db_add_field('party_subscription_settings', 'data', array(
'description' => 'An of settings to do with this partys subscription',
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
));
}
/**
* Add table for settings Entity and tweak out relation table to be CORRECT
*/
function party_simplenews_update_7003() {
db_change_field('party_simplenews_subscriber', 'snid', 'snid', array(
'description' => 'Primary key: Unique subscriber ID.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
), array(
'primary key' => array(
'snid',
),
));
$table = array(
'description' => 'Entity table to store subscription settings against',
'fields' => array(
'subscription_settings_id' => array(
'description' => 'Primary key: Unique subscriber ID.',
'type' => 'serial',
'not null' => TRUE,
),
),
'primary key' => array(
'subscription_settings_id',
),
);
db_create_table('party_subscription_settings', $table);
}
/**
* Remove fields
*/
function party_simplenews_update_7002() {
db_drop_field("simplenews_subscriber", "party_id");
db_drop_field("simplenews_subscriber", "party_field_ref");
}
/**
* Add relationship table
*/
function party_simplenews_update_7001() {
$table = array(
'description' => 'A table of party ids to subscriber ids',
'fields' => array(
'snid' => array(
'description' => 'Primary key: Unique subscriber ID.',
'type' => 'serial',
'not null' => TRUE,
),
'party_id' => array(
'description' => 'The {party}.pid that has the same email address.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'party_field_ref' => array(
'description' => 'The reference of the field on the party this refers to. Of the form DATA_SET_NAME__ENTITY_ID__FIELD_NAME__DELTA',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'snid',
),
'indexes' => array(
'party_mail' => array(
'party_id',
'party_field_ref',
),
),
'foreign keys' => array(
'party_id' => array(
'table' => 'party',
'columns' => array(
'party_id' => 'pid',
),
),
),
);
db_create_table('party_simplenews_subscriber', $table);
}
Functions
Name![]() |
Description |
---|---|
party_simplenews_schema | Implements hook_schema() |
party_simplenews_update_7001 | Add relationship table |
party_simplenews_update_7002 | Remove fields |
party_simplenews_update_7003 | Add table for settings Entity and tweak out relation table to be CORRECT |
party_simplenews_update_7004 | Add data field so that the entity will actually save |