View source
<?php
module_load_include('inc', 'coder_upgrade', 'coder_upgrade');
function coder_upgrade_install() {
$dir = coder_upgrade_directory_path('base', FALSE);
if (file_prepare_directory($dir, FILE_CREATE_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');
}
$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');
}
$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');
}
module_load_include('inc', 'coder_upgrade', 'includes/settings');
$form_state = array();
coder_upgrade_create_theme_cache_submit(array(), $form_state);
}
function coder_upgrade_uninstall() {
$dir = coder_upgrade_directory_path('base', FALSE);
coder_upgrade_clean_directory($dir, TRUE);
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) {
$t = get_t();
$requirements = array();
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.'),
'severity' => REQUIREMENT_ERROR,
);
}
$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 and other files in subdirectories of this directory.', array(
'%directory' => $dir,
)),
'severity' => REQUIREMENT_ERROR,
);
}
}
else {
$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,
)),
);
}
else {
$requirements['coder_upgrade_files'] = array(
'title' => $t('Coder Upgrade directory'),
'value' => $t('Writeable (%dir)', array(
'%dir' => $dir,
)),
);
}
}
return $requirements;
}