function theme_update_detailed_email_message in Update Status Detailed Email 7
Same name and namespace in other branches
- 6 update_detailed_email.module \theme_update_detailed_email_message()
Theme the detailed update email.
Much of the code is taken from the original theme_update_report(). The changes are primarily focused on making the outputted HTML more email-friendly.
Parameters
array $variables: An array of update information for installed modules.
Return value
string Themed output.
1 theme call to theme_update_detailed_email_message()
- theme_update_detailed_email in ./
update_detailed_email.module - Theme function to override the original update theme function.
File
- ./
update_detailed_email.module, line 156 - Adds detail to the email message Drupal core's Update Status sends.
Code
function theme_update_detailed_email_message($variables) {
$output = '<style type="text/css"><!-- body { margin: 1em; font-size: 100%; background: none; } --></style>';
$sep = "<br />\n";
$data = $variables['data'];
if (!is_array($data)) {
$output .= '<p>' . $data . '</p>';
return $output;
}
$rows = array();
$notification_level = variable_get('update_notification_threshold', 'all');
foreach ($data as $project) {
// Don't include modules that are up to date.
//
// If set to only notify of security updates, don't include
// non-security updates in the email.
if ($notification_level == 'all' && $project['status'] != UPDATE_CURRENT || $notification_level == 'security' && $project['status'] == UPDATE_NOT_SECURE) {
$row = '<p>';
switch ($project['status']) {
case UPDATE_NOT_SECURE:
$row .= t('Security update required!');
break;
case UPDATE_REVOKED:
$row .= t('Revoked!');
break;
case UPDATE_NOT_SUPPORTED:
$row .= t('Not supported!');
break;
case UPDATE_NOT_CURRENT:
$row .= t('Update available');
break;
default:
$row .= check_plain($project['reason']);
break;
}
$row .= $sep;
// Project title.
if (isset($project['title'])) {
if (isset($project['link'])) {
$row .= l($project['title'], $project['link']);
}
else {
$row .= check_plain($project['title']);
}
}
else {
$row .= check_plain($project['name']);
}
// Project version.
$row .= ' ' . check_plain($project['existing_version']);
// Project date.
if ($project['install_type'] == 'dev' && !empty($project['datestamp'])) {
$row .= ' (' . format_date($project['datestamp'], 'custom', 'Y-M-d') . ')';
}
// Versions.
if (isset($project['recommended'])) {
// Recommended.
if ($project['existing_version'] !== $project['recommended']) {
$row .= theme('update_detailed_email_message_version', array(
'version' => $project['releases'][$project['recommended']],
'title' => 'Recommended version:',
));
// Now, print any security updates.
if (!empty($project['security updates'])) {
foreach ($project['security updates'] as $security_update) {
$row .= theme('update_detailed_email_message_version', array(
'version' => $security_update,
'title' => 'Security update:',
));
}
}
}
// Latest.
if ($project['recommended'] !== $project['latest_version']) {
$row .= theme('update_detailed_email_message_version', array(
'version' => $project['releases'][$project['latest_version']],
'title' => 'Latest version:',
));
}
// Development.
if ($project['install_type'] == 'dev' && isset($project['dev_version']) && $project['recommended'] !== $project['dev_version']) {
$row .= theme('update_detailed_email_message_version', array(
'version' => $project['releases'][$project['dev_version']],
'title' => 'Development version:',
));
}
}
// Also available.
if (isset($project['also'])) {
foreach ($project['also'] as $also) {
$row .= theme('update_detailed_email_message_version', array(
'version' => $project['releases'][$also],
'title' => 'Also available:',
));
}
}
$row .= $sep;
// Extra.
if (!empty($project['extra'])) {
foreach ($project['extra'] as $key => $value) {
$row .= check_plain($value['label']) . ': ';
$row .= theme('placeholder', $value['data']);
$row .= $sep;
}
}
// Includes.
sort($project['includes']);
$row .= t('Includes: %includes', array(
'%includes' => implode(', ', $project['includes']),
));
// Base themes.
if (!empty($project['base_themes'])) {
sort($project['base_themes']);
// We use !dependencies and manually call theme('placeholder')
// here to avoid breaking the D6 string freeze. This identical
// string is already in modules/system/system.admin.inc.
$row .= $sep;
$dep_args = array(
'!dependencies' => theme('placeholder', implode(', ', $project['base_themes'])),
);
$row .= t('Depends on: !dependencies', $dep_args);
}
// Sub-themes.
if (!empty($project['sub_themes'])) {
sort($project['sub_themes']);
// We use !required and manually call theme('placeholder')
// here to avoid breaking the D6 string freeze. This identical
// string is already in modules/system/system.admin.inc.
$row .= $sep;
$req_args = array(
'!required' => theme('placeholder', implode(', ', $project['sub_themes'])),
);
$row .= t('Required by: !required', $req_args);
}
$row .= "</p>\n\n";
if (!isset($rows[$project['project_type']])) {
$rows[$project['project_type']] = array();
}
$row_key = isset($project['title']) ? drupal_strtolower($project['title']) : drupal_strtolower($project['name']);
$rows[$project['project_type']][$row_key] = array(
'data' => array(
$row,
),
);
}
}
$project_types = array(
'core' => t('Drupal core'),
'module' => t('Modules'),
'theme' => t('Themes'),
'disabled-module' => t('Disabled modules'),
'disabled-theme' => t('Disabled themes'),
);
foreach ($project_types as $type_name => $type_label) {
if (!empty($rows[$type_name])) {
ksort($rows[$type_name]);
$output .= '<p><strong>' . $type_label . "</strong></p>\n\n";
foreach ($rows[$type_name] as $list) {
$output .= $list['data'][0] . "\n\n";
}
}
}
return $output;
}