You are here

addtohomescreen.install in Add to homescreen 7

Same filename and directory in other branches
  1. 8 addtohomescreen.install

Install, update and uninstall functions for the addtohomescreen module.

File

addtohomescreen.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the addtohomescreen module.
 */

/**
 * Implements hook_requirements().
 */
function addtohomescreen_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime') {
    if (!function_exists('libraries_detect')) {
      $requirements['addtohomescreen'] = array(
        'title' => $t('Add to homescreen'),
        'value' => $t('Libraries module is not installed.'),
        'description' => $t('Add to homescreen requires the Libraries module. Please install it from <a href="@download_url">here</a>.', array(
          '@download_url' => 'http://www.drupal.org/project/libraries',
        )),
        'severity' => REQUIREMENT_ERROR,
      );
      return $requirements;
    }
    if (($library = libraries_detect('addtohomescreen')) && !empty($library['installed'])) {
      $requirements['addtohomescreen'] = array(
        'title' => $t('Add to homescreen version'),
        'value' => $library['version'],
        'severity' => REQUIREMENT_OK,
      );
    }
    else {
      $requirements['addtohomescreen'] = array(
        'title' => $t('Add to homescreen'),
        'value' => $t('Add to homescreen library could not be found, check the <a href="@readme_url">installation instructions</a> for the Add to homescreen module.', array(
          '@readme_url' => '/' . drupal_get_path('module', 'addtohomescreen') . '/README.txt',
        )),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}

/**
 * Implements hook_enable().
 */
function addtohomescreen_enable() {
  drupal_set_message(t('Add to homescreen was successfully enabled. The drush command "drush addtohomescreen" is now available to automatically download the library. For manual installation instructions check <a href="@readme_url">README.txt</a>.', array(
    '@readme_url' => DRUPAL_ROOT . drupal_get_path('module', 'addtohomescreen') . '/README.txt',
  )));
}

/**
 * Implements hook_uninstall().
 */
function addtohomescreen_uninstall() {
  variable_del('addtohomescreen_debug');
  variable_del('addtohomescreen_modal');
  variable_del('addtohomescreen_mandatory');
  variable_del('addtohomescreen_skipfirstvisit');
  variable_del('addtohomescreen_autostart');
  variable_del('addtohomescreen_icon');
  variable_del('addtohomescreen_startdelay');
  variable_del('addtohomescreen_lifespan');
  variable_del('addtohomescreen_displaypace');
  variable_del('addtohomescreen_maxdisplaycount');
  variable_del('addtohomescreen_use_custom_message');
  variable_del('addtohomescreen_message_ios');
  variable_del('addtohomescreen_message_android');
  variable_del('addtohomescreen_compression_type');
}

/**
 * Migrate custom message to both iOS and Android custom message.
 */
function addtohomescreen_update_7001() {
  $message = variable_get('addtohomescreen_message');
  variable_set('addtohomescreen_message_ios', $message);
  variable_set('addtohomescreen_message_android', $message);
  variable_del('addtohomescreen_message');
}

Functions

Namesort descending Description
addtohomescreen_enable Implements hook_enable().
addtohomescreen_requirements Implements hook_requirements().
addtohomescreen_uninstall Implements hook_uninstall().
addtohomescreen_update_7001 Migrate custom message to both iOS and Android custom message.