You are here

function coder_upgrade_install in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_upgrade/coder_upgrade.install \coder_upgrade_install()

Implements hook_install().

1 call to coder_upgrade_install()
CoderUpgradeUnitTestCase::setUp in coder_upgrade/coder_upgrade.test
Sets up unit test environment.

File

coder_upgrade/coder_upgrade.install, line 14

Code

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 module directory.
    $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');
    }

    // Create the new module directory.
    $dir = coder_upgrade_directory_path('new', 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 converted module code.', array(
        '%directory' => $dir,
      )), 'error');
    }

    // Create the patch directory.
    $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');
    }
  }
  else {
    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.
  module_load_include('inc', 'coder_upgrade', 'includes/settings');
  $form_state = array();
  coder_upgrade_create_theme_cache_submit(array(), $form_state);
}