function drush_prod_monitor_updates in Production check & Production monitor 6
Same name and namespace in other branches
- 7 prod_monitor/prod_monitor.drush.inc \drush_prod_monitor_updates()
Update status page callback.
1 string reference to 'drush_prod_monitor_updates'
- prod_monitor_drush_command in prod_monitor/
prod_monitor.drush.inc - Implementation of hook_drush_command().
File
- prod_monitor/
prod_monitor.drush.inc, line 315
Code
function drush_prod_monitor_updates() {
$id = func_get_args();
// Fetch ALL.
if (empty($id)) {
if (!drush_confirm(dt('Do you really want to check ALL sites for module updates?'))) {
drush_set_error('prod_monitor', dt('Aborting.'));
return;
}
else {
module_load_include('inc', 'prod_monitor', 'includes/prod_monitor.admin');
// Batch process update checking.
_prod_monitor_fetch_all_data_batcher_create(FALSE, TRUE, FALSE);
drush_backend_batch_process();
}
}
else {
$id = $id['0'];
// Get module info.
$modules = _prod_monitor_get_site_modules($id);
$url = _prod_monitor_get_url($id);
if (empty($modules)) {
if (empty($url)) {
drush_set_error('prod_monitor', dt('No site found with ID') . ' ' . $id . '!');
return;
}
else {
drush_set_error('prod_monitor', dt('No module data found for') . ' ' . $url . '!');
return;
}
}
elseif (empty($modules['available'])) {
drush_set_error('prod_monitor', dt('No update data found for') . ' ' . $url . '!');
// No data, ask for refresh.
_drush_prod_monitor_update_refresh($id, $modules);
}
// Refresh if user asked for it.
if (drush_get_option('check')) {
_drush_prod_monitor_update_refresh($id, $modules);
}
$security_only = drush_get_option('security-only');
$last = $modules['lastupdate'];
module_load_include('inc', 'prod_monitor', 'includes/prod_monitor.update');
$projects = _prod_monitor_calculate_project_data($id, $modules['projects'], $modules['available']);
// Cleanup.
unset($modules);
// Table headers.
$rows[] = array(
dt('Name'),
dt('Installed version'),
dt('Proposed version'),
dt('Status'),
);
// Process releases, notifying user of status and building a list of proposed updates
drush_include_engine('update_info', 'drupal', NULL, DRUSH_BASE_PATH . '/commands/pm/update_info');
drush_include(DRUSH_BASE_PATH . '/commands/pm', 'updatecode.pm');
foreach ($projects as $project) {
// Only show security updates if the user requested it.
if ($security_only && $project['status'] !== UPDATE_NOT_SECURE) {
continue;
}
// Add color to the status.
$color = "\33[0m";
switch ($project['status']) {
case UPDATE_CURRENT:
$color = "\33[1;32m";
break;
case UPDATE_NOT_CURRENT:
$color = "\33[1;33m";
break;
case UPDATE_NOT_SECURE:
$color = "\33[1;31m";
break;
}
// Translate status to readable name and fill 'candidate_version'.
$status = pm_update_filter($project);
// Generate row.
$rows[] = array(
$project['name'],
$project['existing_version'],
$project['candidate_version'],
$color . $status . "\33[0m",
);
}
drush_print("\33[1m" . dt('Module update status for') . ' ' . $url . "\33[0m", 1);
drush_print(dt('Update information last refreshed:') . ' ' . ($last ? format_date($last) : dt('Never')) . "\n", 1);
if (count($rows) > 1) {
drush_print_table($rows, TRUE);
}
else {
drush_print("\33[1m" . dt('No updates to show!') . "\33[0m", 1);
}
}
}