word_link.install in Word Link 7
Same filename and directory in other branches
Install, update, and uninstall functions for the word_link module.
File
word_link.installView source
<?php
/**
 * @file
 * Install, update, and uninstall functions for the word_link module.
 */
/**
 * Implements hook_install().
 */
function word_link_install() {
  $t = get_t();
  drupal_set_message($t('Word Link module succesfully installed. Visit the <a href="@link">configuration page</a>.', array(
    '@link' => url('admin/config/content/word-link/configuration'),
  )));
}
/**
 * Implements of hook_uninstall().
 */
function word_link_uninstall() {
  variable_del('word_link_limit');
  variable_del('word_link_tags_except');
  variable_del('word_link_node_types');
  variable_del('word_link_css');
  variable_del('word_link_highlight');
}
/**
 * Implements of hook_schema().
 */
function word_link_schema() {
  $schema['word_link'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'text' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'case_sensitive' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1,
        'size' => 'tiny',
      ),
      'url' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'url_title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'class' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => 'word-link',
      ),
      'rel' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'visibility' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'size' => 'tiny',
      ),
      'except' => array(
        'type' => 'text',
        'length' => 255,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}
/**
 * Adding visibility field.
 */
function word_link_update_7001() {
  // Add the visibility field to the db.
  if (!db_field_exists('word_link', 'visibility')) {
    db_add_field('word_link', 'visibility', array(
      'type' => 'int',
      'not null' => TRUE,
      'default' => 0,
      'size' => 'tiny',
    ));
  }
}
/**
 * Adding rel field.
 */
function word_link_update_7002() {
  $schema = word_link_schema();
  $field = 'rel';
  $table = 'word_link';
  // Add the rel field to the db.
  if (!db_field_exists($table, $field)) {
    db_add_field($table, $field, $schema[$table]['fields'][$field]);
  }
}Functions
| 
            Name | 
                  Description | 
|---|---|
| word_link_install | Implements hook_install(). | 
| word_link_schema | Implements of hook_schema(). | 
| word_link_uninstall | Implements of hook_uninstall(). | 
| word_link_update_7001 | Adding visibility field. | 
| word_link_update_7002 | Adding rel field. |