Skip to content
coder_upgrade.install 4.73 KiB
Newer Older
 * Install, uninstall, and update functions for the Coder Upgrade module.
 * Copyright 2008-11 by Jim Berry ("solotandem", http://drupal.org/user/240748)
 */

module_load_include('inc', 'coder_upgrade', 'coder_upgrade');

/**
 */
function coder_upgrade_install() {
  // Create the top-level module directory.
  // Because the core function is now recursive, we could start with the
  // subdirectories. However, this code is clean and allows for one else block.
  $dir = coder_upgrade_directory_path('base', FALSE);
  if (file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
    // Create the old and new module directories.
    $dir = coder_upgrade_directory_path('old', FALSE);
    if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
      drupal_set_message(st('The files directory at %directory can not be written to. This is the default directory searched by Coder Upgrade for modules to be converted.', array('%directory' => $dir)), 'error');
    $dir = coder_upgrade_directory_path('new', FALSE);
Jim Berry's avatar
Jim Berry committed
    if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
      drupal_set_message(st('The files directory at %directory can not be written to. This is the default directory to which Coder Upgrade writes converted module code.', array('%directory' => $dir)), 'error');
    $dir = coder_upgrade_directory_path('patch', FALSE);
    if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
      drupal_set_message(st('The files directory at %directory can not be written to. This is the default directory to which Coder Upgrade writes patch files.', array('%directory' => $dir)), 'error');
    drupal_set_message(st('Your files directory at %directory can not be written to. Coder Upgrade places converted module code in subdirectories of this directory.', array('%directory' => $dir)), 'error');

  // Create a core theme information cache.
  $form_state = array();
  coder_upgrade_create_theme_cache_submit(array(), $form_state);
 */
function coder_upgrade_uninstall() {
  // Remove the module input and output directories.
  $dir = coder_upgrade_directory_path('old', FALSE);
  coder_upgrade_clean_directory($dir, TRUE);
  $dir = coder_upgrade_directory_path('new', FALSE);
  coder_upgrade_clean_directory($dir, TRUE);
  $dir = coder_upgrade_directory_path('patch', FALSE);
  coder_upgrade_clean_directory($dir, TRUE);

  // Remove items from {variables} table.
  variable_del('coder_upgrade_dir');
  variable_del('coder_upgrade_dir_old');
  variable_del('coder_upgrade_dir_new');
  variable_del('coder_upgrade_dir_patch');

  variable_del('coder_upgrade_upgrade_core');
  variable_del('coder_upgrade_replace_files');
  variable_del('coder_upgrade_preserve_array_format');
  variable_del('coder_upgrade_enable_debug_output');
  variable_del('coder_upgrade_enable_parser_debug_output');
  variable_del('coder_upgrade_use_separate_process');
 */
function coder_upgrade_requirements($phase) {
  // Ensure translations don't break at install time.
  $t = get_t();

  $requirements = array();

  // Test writeability to files directory.
  if ($phase == 'install') {
    if (module_exists('deadwood')) {
      $requirements['coder_upgrade_modules'] = array(
        'title' => $t('Deadwood module'),
        'description' => $t('The Deadwood module must be uninstalled before the Coder Upgrade module can be installed.'),
    $dir = coder_upgrade_directory_path('', FALSE);
    if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
      $requirements['coder_upgrade_files'] = array(
        'title' => $t('Files directory'),
        'description' => $t('Your files directory at %directory can not be written to. Coder Upgrade places converted module code in subdirectories of this directory.', array('%directory' => $dir)),
    $dir = coder_upgrade_directory_path('new', FALSE);
    if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
      $requirements['coder_upgrade_files'] = array(
        'title' => $t('Coder Upgrade directory'),
        'description' => $t('Your files directory at %directory can not be written to. Coder Upgrade places converted module code in subdirectories of this directory.', array('%directory' => $dir)),
        'severity' => REQUIREMENT_ERROR,
        'value' => $t('Not writeable (%dir)', array('%dir' => $dir))
      $requirements['coder_upgrade_files'] = array(
        'title' => $t('Coder Upgrade directory'),
        'value' => $t('Writeable (%dir)', array('%dir' => $dir))