View source
<?php
require_once __DIR__ . '/varbase_install.inc';
function varbase_install_tasks() {
$max_nesting_level = ini_get('xdebug.max_nesting_level');
if ($max_nesting_level > 0 && $max_nesting_level <= '200') {
ini_set('xdebug.max_nesting_level', 200);
}
}
function varbase_install_tasks_alter(&$tasks, $install_state) {
$needs_translations = count($install_state['locales']) > 1 && !empty($install_state['parameters']['locale']) && $install_state['parameters']['locale'] != 'en';
if ($install_state['parameters']['profile'] == 'varbase') {
$varbase_install_load_profile_extra = array(
'varbase_install_load_profile_extra' => array(
'run' => INSTALL_TASK_RUN_IF_REACHED,
),
);
_array_splice_assoc($tasks, 3, 0, $varbase_install_load_profile_extra);
}
$tasks['install_verify_requirements']['function'] = 'varbase_install_verify_requirements';
$tasks['install_finished']['function'] = 'varbase_install_finished';
$tasks['install_finished']['type'] = 'batch';
$tasks['install_finished']['display'] = TRUE;
}
function varbase_install_load_profile_extra(&$install_state) {
$install_state['profile_info']['dependencies'][] = 'varbase_default_settings';
}
function varbase_install_verify_requirements(&$install_state) {
$requirements = install_check_requirements($install_state);
$requirements += varbase_verify_requirments($install_state);
$requirements += drupal_verify_profile($install_state);
$severity = drupal_requirements_severity($requirements);
if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING && empty($install_state['parameters']['continue'])) {
if ($install_state['interactive']) {
drupal_set_title(st('Requirements problem'));
$status_report = theme('status_report', array(
'requirements' => $requirements,
));
$status_report .= st('Check the error messages and <a href="!url">proceed with the installation</a>.', array(
'!url' => check_url(drupal_requirements_url($severity)),
));
return $status_report;
}
else {
$failures = array();
foreach ($requirements as $requirement) {
if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) {
$failures[] = $requirement['title'] . ': ' . $requirement['value'] . "\n\n" . $requirement['description'];
}
}
if (!empty($failures)) {
throw new Exception(implode("\n\n", $failures));
}
}
}
}
function varbase_install_finished(&$install_state) {
drupal_static_reset();
drupal_get_schema(NULL, TRUE);
variable_set('install_profile', drupal_get_profile());
db_update('system')
->fields(array(
'weight' => 1000,
))
->condition('type', 'module')
->condition('name', drupal_get_profile())
->execute();
$batch = _varbase_install_batch_finished();
return $batch;
}
function _varbase_install_batch_finished() {
$operations = array();
$operations[] = array(
'_varbase_install_rebuild_features_keys',
array(),
);
$operations[] = array(
'_varbase_install_rebuild_features_defaultconfig_rebuild',
array(),
);
$operations[] = array(
'_varbase_install_rebuild_features_all',
array(),
);
$operations[] = array(
'_varbase_install_drupal_cc_all',
array(),
);
$batch = array(
'operations' => $operations,
'finished' => '_varbase_install_finished_batch_finished',
'title' => t('Finishing install'),
'init_message' => t('please wait for until we finalize your installation.'),
'progress_message' => t('Finalizing installation.'),
'error_message' => t('Installtion have encountered error please contact the site admin as your database maybe corrupted.'),
'file' => drupal_get_path('profile', 'varbase') . '/varbase_batch.inc',
);
return $batch;
}
function varbase_install() {
theme_enable(array(
'vartheme_admin',
'vartheme',
'adminimal',
));
theme_disable(array(
'bartik',
));
variable_set('theme_default', 'vartheme');
variable_set('admin_theme', 'vartheme_admin');
}
function _array_splice_assoc(&$input, $offset, $length, $replacement) {
$replacement = (array) $replacement;
$key_indices = array_flip(array_keys($input));
if (isset($input[$offset]) && is_string($offset)) {
$offset = $key_indices[$offset];
}
if (isset($input[$length]) && is_string($length)) {
$length = $key_indices[$length] - $offset;
}
$input = array_slice($input, 0, $offset, TRUE) + $replacement + array_slice($input, $offset + $length, NULL, TRUE);
}
function varbase_update_7200() {
if (module_exists('remember_me')) {
module_disable(array(
'remember_me',
));
drupal_uninstall_modules(array(
'remember_me',
));
}
if (module_exists('persistent_login')) {
module_enable(array(
'persistent_login',
));
}
}