You are here

charts_graphs.install in Charts and Graphs 7

Same filename and directory in other branches
  1. 6.2 charts_graphs.install
  2. 7.2 charts_graphs.install

Install file for Charts and Graphs module.

File

charts_graphs.install
View source
<?php

/**
 * @file
 *   Install file for Charts and Graphs module.
 *
 */

/**
 * Implements hook_uninstall().
 */
function charts_graphs_uninstall() {

  // TODO Please review the conversion of this statement to the D7 database API syntax.

  /* db_query("DELETE FROM {variable} WHERE name LIKE 'charts_graphs_%%'") */
  db_delete('variable')
    ->condition('name', 'charts_graphs_%%', 'LIKE')
    ->execute();
  cache_clear_all('variables', 'cache');
}

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

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime') {
    if (count(charts_graphs_apis()) == 0) {
      $requirements['charts_graphs_submodule'] = array(
        'title' => $t('Charts and Graphs charting library'),
        'description' => $t('Charts and Graphs requires at least one charting
          library enabled. Please go to !modules_page and enable at least one
          charting library.', array(
          '!modules_page' => l(t('modules list page'), 'admin/modules/list'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('None enabled'),
      );
    }
    $path = dirname(realpath(__FILE__)) . '/';
    $file = $path . 'apis/charts_google_charts';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_google_charts'] = array(
        'title' => $t('Google Charts at old path'),
        'description' => $t("You have Google Charts for Charts and Graphs\n          available at it's old path: %old_path. Please remove it.", array(
          '%old_path' => $file,
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    $file = $path . 'apis/amcharts';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_amcharts'] = array(
        'title' => $t('amCharts at old path'),
        'description' => $t("You have amCharts for Charts and Graphs\n          available at it's old path: %old_path. Please remove it. Remember to\n          copy the downloaded files from the old %downloaded_path path to the\n          new one", array(
          '%old_path' => $file,
          '%downloaded_path' => $file . '/downloaded/',
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    $file = $path . 'apis/charts_openflash';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_openflash'] = array(
        'title' => $t('Open Flash Chart 2 at old path'),
        'description' => $t("You have Open Flash Chart 2 for Charts and Graphs\n          available at it's old path: %old_path. Please remove it.", array(
          '%old_path' => $file,
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    $file = $path . 'apis/charts_bluff';
    if (file_exists($file)) {
      $requirements['charts_graphs_old_path_bluff'] = array(
        'title' => $t('Bluff at old path'),
        'description' => $t("You have Bluff for Charts and Graphs\n          available at it's old path: %old_path. Please remove it. Remember to\n          copy the downloaded files from the old %downloaded_path path to the\n          new one", array(
          '%old_path' => $file,
          '%downloaded_path' => $file . '/bluff/',
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Old path'),
      );
    }
    if (variable_get('charts_graphs_check_chart_api', 1) && module_exists('chart')) {
      $requirements['charts_graphs_check_chart_api'] = array(
        'title' => $t('Chart API'),
        'description' => $t("You have both !charts_graphs and !chart_api\n          installed. Unless you have different modules that require both the\n          Charts and Graphs module and the Chart API module one of them\n          should be uninstalled. A common module that requires Charts and\n          Graphs is the Views Charts module so if you use the later, you need\n          the first. If you don't want this warning to be shown any more, please\n          set the proper option at !charts_graphs_settings_page.", array(
          '!charts_graphs' => l(t('Charts and Graphs'), 'http://drupal.org/project/charts_graphs'),
          '!chart_api' => l(t('Chart API'), 'http://drupal.org/project/chart'),
          '!charts_graphs_settings_page' => l(t('Charts and Graphs settings page'), 'admin/config/charts_graphs'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Enabled'),
      );
    }
    if (variable_get('charts_graphs_check_charts', 1) && module_exists('charts')) {
      $requirements['charts_graphs_check_charts'] = array(
        'title' => $t('Charts'),
        'description' => $t("You have both !charts_graphs and !charts\n          installed. Unless you have different modules that require both the\n          Charts and Graphs module and the Charts module one of them\n          should be uninstalled. A common module that requires Charts and\n          Graphs is the Views Charts module so if you use the later, you need\n          the first. If you don't want this warning to be shown any more, please\n          set the proper option at !charts_graphs_settings_page.", array(
          '!charts_graphs' => l(t('Charts and Graphs'), 'http://drupal.org/project/charts_graphs'),
          '!charts' => l(t('Charts'), 'http://drupal.org/project/charts'),
          '!charts_graphs_settings_page' => l(t('Charts and Graphs settings page'), 'admin/config/charts_graphs'),
        )),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Enabled'),
      );
    }
  }
  return $requirements;
}

Functions