You are here

jsonlog.install in JSONlog 7.2

Install, update and uninstall functions for the JSONlog module.

File

jsonlog.install
View source
<?php

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

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

  // The equivalent server environment vars are named 'drupal_'....
  variable_del('jsonlog_severity_threshold');
  variable_del('jsonlog_truncate');
  variable_del('jsonlog_siteid');
  variable_del('jsonlog_canonical');
  variable_del('jsonlog_dir');
  variable_del('jsonlog_file_time');
  variable_del('jsonlog_tags');
}

/**
 * Removes obsolete conf variables.
 */
function jsonlog_update_7001() {
  db_delete('variable')
    ->condition('name', array(
    'jsonlog_fields',
    'jsonlog_format_version',
  ), 'IN')
    ->execute();
}

/**
 * Converts conf variable jsonlog_file to jsonlog_dir.
 */
function jsonlog_update_7002() {
  if (!db_select('variable')
    ->fields('variable', array(
    'value',
  ))
    ->condition('name', 'jsonlog_dir', '=')
    ->execute()
    ->fetchField() && ($file = db_select('variable')
    ->fields('variable', array(
    'value',
  ))
    ->condition('name', 'jsonlog_file', '=')
    ->execute()
    ->fetchField())) {
    $dir = dirname(unserialize($file));
    db_insert('variable')
      ->fields(array(
      'name',
      'value',
    ), array(
      'jsonlog_dir',
      serialize($dir),
    ))
      ->execute();
    db_delete('variable')
      ->condition('name', array(
      'jsonlog_file',
    ), 'IN')
      ->execute();
  }
}

Functions

Namesort descending Description
jsonlog_uninstall Implements hook_uninstall().
jsonlog_update_7001 Removes obsolete conf variables.
jsonlog_update_7002 Converts conf variable jsonlog_file to jsonlog_dir.