You are here

better_messages.install in Better Messages 7.2

File

better_messages.install
View source
<?php

/**
 * Implements hook_install().
 */
function better_messages_install() {
  db_query("UPDATE {system} SET weight = 9999 WHERE name = 'better_messages'");

  // Add default skin data
  _better_messages_insert_default_settings();
}

/**
 * Implements hook_schema().
 */
function better_messages_schema() {
  $schema['better_messages'] = array(
    'description' => 'Better Messages settings table.',
    'fields' => array(
      'name' => array(
        'description' => 'Better Messages skin machine name.',
        'type' => 'varchar',
        'length' => 128,
      ),
      'data' => array(
        'description' => 'The settings of the Better Messages skin.',
        'type' => 'blob',
        'size' => 'normal',
      ),
    ),
    'unique keys' => array(
      'name' => array(
        'name',
      ),
    ),
    'primary key' => array(
      'name',
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function better_messages_uninstall() {
  db_query("DELETE FROM {variable} WHERE name LIKE 'better_messages%'");
  db_query("DELETE FROM {system} WHERE name = 'better_messages'");
}

/**
 * Add default Better Messages skins.
 */
function _better_messages_insert_default_settings() {
  $default_settings = _better_messages_default_settings();

  // Facebook style skin
  $fb_settings = $default_settings;
  $fb_settings['admin']['title'] = t('Facebook style');
  $fb_settings['admin']['css'] = drupal_get_path('module', 'better_messages') . '/skins/facebook_style/skin.css';
  $fb_style = array(
    'name' => 'facebook_style',
    'data' => serialize($fb_settings),
  );
  drupal_write_record('better_messages', $fb_style);

  // Stackoverflow style skin
  $so_settings = $default_settings;
  $so_settings['admin']['title'] = t('Stackoverflow style');
  $so_settings['admin']['css'] = drupal_get_path('module', 'better_messages') . '/skins/stackoverflow_style/skin.css';
  $so_settings['placement']['pos_x'] = 'l';
  $so_settings['placement']['pos_y'] = 't';
  $so_settings['placement']['width'] = '100%';
  $so_settings['animation']['popin']['effect'] = 'slideDown';
  $so_settings['animation']['popout']['effect'] = 'slideUp';
  $so_style = array(
    'name' => 'stackoverflow_style',
    'data' => serialize($so_settings),
  );
  drupal_write_record('better_messages', $so_style);

  // Growl style skin
  $growl_settings = $default_settings;
  $growl_settings['admin']['title'] = t('Growl style');
  $growl_settings['admin']['css'] = drupal_get_path('module', 'better_messages') . '/skins/growl_style/skin.css';
  $growl_settings['placement']['pos_x'] = 'r';
  $growl_settings['placement']['pos_y'] = 't';
  $growl_settings['placement']['space_x'] = '20';
  $growl_settings['placement']['space_y'] = '20';
  $growl_settings['placement']['width'] = '300px';
  $growl_style = array(
    'name' => 'growl_style',
    'data' => serialize($growl_settings),
  );
  drupal_write_record('better_messages', $growl_style);

  // Now set the current default skin to Facebook style.
  variable_set('better_messages_default', 'facebook_style');
}

/**
 * Default settings array schema.
 */
function _better_messages_default_settings() {
  return array(
    'placement' => array(
      'pos_x' => 'center',
      'pos_y' => 'center',
      'space_x' => 0,
      'space_y' => 0,
      'width' => '400px',
      'fixed' => 1,
    ),
    'animation' => array(
      'popin' => array(
        'effect' => 'fadeIn',
        'easing' => 'easeOutExpo',
        'duration' => 'slow',
        'opendelay' => 0.3,
      ),
      'popout' => array(
        'effect' => 'fadeOut',
        'easing' => 'easeOutExpo',
        'duration' => 'slow',
        'autoclose' => array(
          'seconds' => 8,
          'show_countdown' => 1,
          'disable_autoclose_error' => 1,
          'disable_autoclose_hover' => 1,
        ),
      ),
    ),
    'jquery_ui' => array(
      'draggable' => 0,
    ),
    'admin' => array(
      'visibility' => array(
        'visibility' => 0,
        'pages' => '',
      ),
      'title' => '',
      'css' => '',
      'storage' => 'system',
    ),
  );
}

Functions

Namesort descending Description
better_messages_install Implements hook_install().
better_messages_schema Implements hook_schema().
better_messages_uninstall Implements hook_uninstall().
_better_messages_default_settings Default settings array schema.
_better_messages_insert_default_settings Add default Better Messages skins.