View source
<?php
function guestbook_schema() {
$schema['guestbook'] = array(
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'recipient' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'author' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'anonname' => array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
'default' => '',
),
'anonemail' => array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
'default' => '',
),
'anonwebsite' => array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
'default' => '',
),
'message' => array(
'type' => 'text',
'not null' => TRUE,
),
'commentauthor' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'comment' => array(
'type' => 'text',
'not null' => TRUE,
),
'status' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
),
'created' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'message_format' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'The {filter_format}.format of the message.',
),
'comment_format' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'The {filter_format}.format of the comment.',
),
),
'indexes' => array(
'recipient' => array(
'recipient',
),
'commentauthor' => array(
'commentauthor',
),
'created' => array(
'created',
),
),
'primary key' => array(
'id',
),
);
return $schema;
}
function guestbook_uninstall() {
db_delete('variable')
->condition('name', 'guestbook_%', 'LIKE')
->execute();
}
function guestbook_update_6200() {
db_update('role_permission')
->fields(array(
'permission' => 'moderate all guestbooks',
))
->condition('permission', 'administer all guestbooks')
->condition('module', 'guestbook')
->execute();
}
function guestbook_update_6201() {
db_change_field('guestbook', 'anonname', 'anonname', array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
'default' => '',
));
db_change_field('guestbook', 'anonemail', 'anonemail', array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
'default' => '',
));
db_change_field('guestbook', 'anonwebsite', 'anonwebsite', array(
'type' => 'varchar',
'length' => '128',
'not null' => FALSE,
'default' => '',
));
}
function guestbook_update_7000() {
$format_id = (string) variable_get('guestbook_input_format', 1);
db_add_field('guestbook', 'message_format', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'initial' => $format_id,
'description' => 'The {filter_format}.format of the message.',
));
db_add_field('guestbook', 'comment_format', array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'The {filter_format}.format of the comment.',
));
db_update('guestbook')
->fields(array(
'comment_format' => $format_id,
))
->condition('comment', '', '<>')
->execute();
variable_del('guestbook_input_format');
variable_del('guestbook_filter_tips');
}
function guestbook_update_7201() {
if (!db_field_exists('guestbook', 'status')) {
db_add_field('guestbook', 'status', array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 1,
));
}
}