contact_save.install in Contact Save 7
Install, update, and uninstall functions for the contact_save module.
File
contact_save.installView source
<?php
/**
* @file
* Install, update, and uninstall functions for the contact_save module.
*/
/**
* Implements hook_schema().
*/
function contact_save_schema() {
$schema['contact_save'] = array(
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'cid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 1,
),
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'mail' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'subject' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
'message' => array(
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
'created' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'read' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
),
'foreign keys' => array(
'category' => array(
'table' => 'contact',
'columns' => array(
'cid' => 'cid',
),
),
'mail_author' => array(
'table' => 'users',
'columns' => array(
'uid' => 'uid',
),
),
),
'primary key' => array(
'id',
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function contact_save_install() {
db_update('system')
->fields(array(
'weight' => 10,
))
->condition('type', 'module')
->condition('name', 'contact_save')
->execute();
}
/**
* Update the module weight.
*/
function contact_save_update_7001() {
db_update('system')
->fields(array(
'weight' => 100,
))
->condition('type', 'module')
->condition('name', 'contact_save')
->execute();
}
/**
* Introduce a 'Read' flag for messages and mark all existing messages as having
* been read.
*/
function contact_save_update_7002(&$sandbox) {
$definition = array(
'type' => 'int',
'description' => "Flag for message read status",
'not null' => TRUE,
'default' => 0,
);
db_add_field('contact_save', 'read', $definition);
db_update('contact_save')
->fields(array(
'`read`' => REQUEST_TIME,
))
->execute();
}
Functions
Name![]() |
Description |
---|---|
contact_save_install | Implements hook_install(). |
contact_save_schema | Implements hook_schema(). |
contact_save_update_7001 | Update the module weight. |
contact_save_update_7002 | Introduce a 'Read' flag for messages and mark all existing messages as having been read. |