You are here

responsive_favicons.install in Responsive Favicons 7

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

Responsive favicons install file.

File

responsive_favicons.install
View source
<?php

/**
 * @file
 * Responsive favicons install file.
 */

/**
 * Implements hook_requirements().
 */
function responsive_favicons_requirements($phase) {
  $requirements = array();
  if ($phase === 'runtime') {

    // Make sure that the favicons exist.
    $tags = responsive_favicons_load_all_icons();
    if (!empty($tags['missing'])) {
      $requirements['responsive_favicons_missing'] = array(
        'title' => t('Responsive favicons'),
        'value' => implode('<br/>', array_map('check_plain', $tags['missing'])),
        'description' => t('The favicon files are missing for the tags above. Go to <a href="@config-url">configuration page</a> to add missing files.', array(
          '@config-url' => url('admin/config/user-interface/responsive_favicons'),
        )),
        'severity' => REQUIREMENT_ERROR,
      );
    }
    if (!empty($tags['found'])) {
      $requirements['responsive_favicons_found'] = array(
        'title' => t('Responsive favicons'),
        'value' => format_plural(count($tags['found']), 'Found 1 favicon', 'Found @count favicons'),
        'severity' => REQUIREMENT_OK,
      );
    }

    // Point out the potential conflict with the favicon module.
    if (module_exists('favicon')) {
      $requirements['responsive_favicons_favicon_module'] = array(
        'title' => t('Responsive favicons'),
        'value' => t('You do not need to have the favicon module enabled when you have the responsive favicons module enabled. Please see the README for more information.'),
        'severity' => REQUIREMENT_WARNING,
      );
    }
  }
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function responsive_favicons_uninstall() {
  variable_del('responsive_favicons_path');
  variable_del('responsive_favicons_tags');
  variable_del('responsive_favicons_remove_default');
}

/**
 * Implementations of hook_update_N().
 */

/**
 * Tidy up the tags variable.
 */
function responsive_favicons_update_7100() {
  $tags = variable_get('responsive_favicons_tags', array());
  if (!empty($tags)) {
    $new_tags = array();
    foreach ($tags as $pos => $tag) {
      if (!empty($tag)) {
        $new_tags[] = trim($tag);
      }
    }
    variable_set('responsive_favicons_tags', $new_tags);
  }
}

/**
 * Grants "administer responsive favicons" permission to those with "administer
 * themes".
 */
function responsive_favicons_update_7101() {
  $roles = user_roles(TRUE, 'administer themes');
  foreach ($roles as $rid => $role) {
    user_role_grant_permissions($rid, array(
      'administer responsive favicons',
    ));
  }
}

Functions

Namesort descending Description
responsive_favicons_requirements Implements hook_requirements().
responsive_favicons_uninstall Implements hook_uninstall().
responsive_favicons_update_7100 Tidy up the tags variable.
responsive_favicons_update_7101 Grants "administer responsive favicons" permission to those with "administer themes".