You are here

nicemessages.install in Nice messages 7.2

Same filename and directory in other branches
  1. 7 nicemessages.install

Module install file. Attaching boolean nicemessages_enabled field to user objects.

File

nicemessages.install
View source
<?php

/**
 * @file
 * Module install file.
 * Attaching boolean nicemessages_enabled field to user objects.
 */

/**
 * Implements hook_install();
 */
function nicemessages_install() {

  // Clear the field cache to be sure the new field type is available.
  field_cache_clear();
  $field = array(
    'field_name' => NICEMESSAGES_FIELDNAME,
    'type' => 'list_boolean',
    'settings' => array(
      'allowed_values' => array(
        1 => t('Yes'),
        0 => t('No'),
      ),
      'default_value' => 0,
    ),
  );
  field_create_field($field);
  $instance = array(
    'field_name' => NICEMESSAGES_FIELDNAME,
    'entity_type' => 'user',
    'bundle' => 'user',
    'label' => t('Display messages in popups.'),
    'required' => FALSE,
    'widget' => array(
      'type' => 'options_select',
    ),
  );
  field_create_instance($instance);
}

/**
 * Implements hook_uninstall().
 */
function nicemessages_uninstall() {
  db_delete('variable')
    ->condition('name', '%nicemessages%', 'LIKE')
    ->execute();
  field_delete_instance('field_user_nicemessages_enabled');
  field_delete_field('field_user_nicemessages_enabled');

  // purge all field information
  field_purge_batch(100);
}

Functions