function upgrade_assist_states in Upgrade Status 5
Same name and namespace in other branches
- 6 upgrade_assist/upgrade_assist.module \upgrade_assist_states()
Return upgrade states.
Parameters
$render: (optional) TRUE to return an task list array suitable for theme_item_list().
1 call to upgrade_assist_states()
- upgrade_assist_block in upgrade_assist/
upgrade_assist.module - Implementation of hook_block().
File
- upgrade_assist/
upgrade_assist.module, line 16 - Assists in upgrading Drupal.
Code
function upgrade_assist_states($render = FALSE) {
$states = array();
$states['offline'] = array(
'title' => t('Site set to offline'),
'status' => variable_get('site_offline', 0),
);
$states['backup-current'] = array(
'title' => t('Backup current site'),
'status' => (bool) module_invoke('demo', 'get_dump', 'upgrade_assist_current'),
);
// @todo Cache this using cache_set(), so it's invalidated when update.php runs.
if (module_exists('update_status')) {
$site_key = md5($base_url . drupal_get_private_key());
$project = array(
'name' => 'drupal',
'version' => VERSION,
);
$url = _update_status_build_fetch_url($project, $site_key);
$xml = drupal_http_request($url);
$data = array();
if (isset($xml->data)) {
$data[] = $xml->data;
}
if ($data) {
$parser = new update_status_xml_parser();
$available = $parser
->parse($data);
}
}
$states['update-modules-5'] = array(
'title' => t('Update 5.x modules'),
'status' => $available['drupal']['recommended version'] < VERSION,
);
$states['backup-updated'] = array(
'title' => t('Backup updated site'),
'status' => (bool) module_invoke('demo', 'get_dump', 'upgrade_assist_updated'),
);
$states['garland-added'] = array(
'title' => t('Ensure Garland theme'),
'status' => (bool) file_exists('./themes/garland'),
);
$states['modules-downloaded'] = array(
'title' => t('Download upgraded modules'),
'status' => (bool) variable_get('upgrade_assist_status_modules_downloaded', FALSE),
);
$states['modules-disabled'] = array(
'title' => t('Disable contrib modules'),
'status' => (bool) variable_get('upgrade_assist_enabled_modules', array()),
);
$states['upgraded-drupal-core'] = array(
'title' => t('Upgrade Drupal core'),
'status' => (bool) (strpos(VERSION, '6') === 0),
);
// @todo States for 6.x.
$states['ran-drupal-core-update'] = array(
'title' => t('Run update.php for Drupal core'),
'status' => (bool) (strpos(VERSION, '6') === 0),
);
$modules = variable_get('upgrade_assist_enabled_modules', array());
if (isset($modules['content'])) {
$states['enabled-cck-core'] = array(
'title' => t('Enable CCK core'),
'status' => (bool) module_exists('content'),
);
$states['upgraded-cck-core'] = array(
'title' => t('Upgrade CCK core'),
'status' => (bool) (strpos(VERSION, '6') === 0),
);
$states['ran-cck-core-update'] = array(
'title' => t('Run update.php for CCK core'),
'status' => (bool) (strpos(VERSION, '6') === 0),
);
}
$states['upgraded-modules'] = array(
'title' => t('Upgrade contrib modules'),
'status' => (bool) (strpos(VERSION, '6') === 0),
);
$states['ran-modules-update'] = array(
'title' => t('Run update.php for contrib modules'),
'status' => (bool) (strpos(VERSION, '6') === 0),
);
// Prepare states to be displayed in block as tasks.
if ($render) {
$items = array();
$active = TRUE;
foreach ($states as $name => $item) {
$items[$name]['data'] = $item['title'];
if ($item['status'] && $active) {
$items[$name]['class'] = 'done';
}
else {
$items[$name]['class'] = $active ? 'active' : '';
$active = FALSE;
}
}
return $items;
}
return $states;
}