You are here

bu.module in Browser update 6

Same filename and directory in other branches
  1. 8 bu.module
  2. 7 bu.module

File

bu.module
View source
<?php

function bu_init() {
  drupal_add_js(bu_get_settings(), 'setting');
  drupal_add_js(drupal_get_path('module', 'bu') . '/bu.js', 'module', 'footer', FALSE, TRUE, FALSE);
}
function bu_menu() {
  $items = array();
  $items['admin/settings/bu'] = array(
    'title' => 'Browser update',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'bu_admin_settings',
    ),
    'access arguments' => array(
      'administer browser-update',
    ),
    'file' => 'bu.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}
function bu_perm() {
  return array(
    'administer browser-update',
  );
}
function bu_get_settings() {
  return array(
    'bu' => array(
      'firefox' => (double) bu_get_versions('firefox', variable_get('bu_browsers_firefox', 5)),
      'ie' => (double) bu_get_versions('ie', variable_get('bu_browsers_ie', 3)),
      'opera' => (double) bu_get_versions('opera', variable_get('bu_browsers_opera', 2)),
      'safari' => (double) bu_get_versions('safari', variable_get('bu_browsers_safari', 3)),
      'text' => variable_get('bu_settings_text', ''),
      'reminder' => (int) variable_get('bu_settings_reminder', 3),
      'debug' => (bool) variable_get('bu_settings_debug', 0),
      'blank' => (bool) variable_get('bu_settings_blank', 0),
    ),
  );
}
function bu_get_versions($browser, $key = NULL) {
  $return = array();
  switch ($browser) {
    case 'firefox':
      $return = array(
        '3',
        '3.5',
        '3.6',
        '4',
        '5',
        '6',
        '7',
        '8',
        '9',
        '10',
        '11',
        '12',
        '13',
        '14',
        '15',
      );
      break;
    case 'ie':
      $return = array(
        '6',
        '7',
        '8',
        '9',
      );
      break;
    case 'opera':
      $return = array(
        '10.1',
        '10.5',
        '10.6',
        '11',
      );
      break;
    case 'safari':
      $return = array(
        '3',
        '3.2',
        '4',
        '5',
      );
      break;
  }
  if ($key && isset($return[$key])) {
    return $return[$key];
  }
  return $return;
}