function heartbeat_messages_overview in Heartbeat 6.4
Same name and namespace in other branches
- 6.2 heartbeat.admin.inc \heartbeat_messages_overview()
- 6.3 heartbeat.admin.inc \heartbeat_messages_overview()
Overview list of heartbeat messages This page must be viewed to make the messages appear in the database after a module is installed as well as make them translatable
1 string reference to 'heartbeat_messages_overview'
- heartbeat_menu in ./
heartbeat.module - Implementation of hook_menu().
File
- ./
heartbeat.admin.inc, line 784 - Admnistration tasks for heartbeat.
Code
function heartbeat_messages_overview() {
$intro = '';
if (module_exists('rules')) {
$intro = t('Go to !link to add your conditional actions to one of the existing events.', array(
'!link' => l('rules administration', 'admin/rules/trigger'),
));
}
// Try to synchronize messages (insert, delete)
$operations = heartbeat_messages_rebuild();
if ($operations['inserted'] > 0) {
drupal_set_message(t('@count @messages were added to heartbeat.', array(
'@count' => $operations['inserted'],
'@messages' => $operations['inserted'] > 1 ? t('messages') : t('message'),
)));
}
if ($operations['deleted'] > 0) {
drupal_set_message(t('@count messages were deleted.', array(
'@count' => $operations['deleted'],
'@messages' => $operations['deleted'] > 1 ? t('messages') : t('message'),
)));
}
// Fetch the heartbeat_message objects
$messages = heartbeat_messages('all', TRUE, TRUE);
if (count($messages) <= 0) {
return t('No messages yet');
}
$default_rows = $custom_rows = array();
$languages = module_exists('locale') ? locale_language_list() : array();
foreach ($messages as $key => $message) {
// Additional tasks for translatable messages
if ($languages != array()) {
_heartbeat_messages_overview_language($languages, $message);
}
$incode = $message->custom & HEARTBEAT_MESSAGE_DEFAULT;
$links = l(t('edit'), "admin/build/heartbeat/edit/" . $message->hid, array(
'query' => 'destination=admin/build/heartbeat/list',
));
if (!$incode) {
$links .= ' - ' . l(t('delete'), "admin/build/heartbeat/delete/" . $message->hid, array(
'query' => 'destination=admin/build/heartbeat/list',
));
}
if ($incode && $message->custom & HEARTBEAT_MESSAGE_CHANGED || isset($operations['diffs'][$message->message_id])) {
$links .= ' - ' . l(t('revert'), "admin/build/heartbeat/revert/" . $message->hid, array(
'query' => 'destination=admin/build/heartbeat/list',
));
}
$perms = _heartbeat_perms_options();
$row = array(
drupal_strlen($message->description) <= 0 ? str_replace('_', ' ', $message->message_id) : $message->description,
$message->message_id,
$perms[$message->perms],
$links,
);
if ($incode) {
$default_rows[$key] = $row;
}
else {
$custom_rows[$key] = $row;
}
}
$headers = array(
t('Description'),
t('Message id (API usage)'),
t('Access'),
t('Operations'),
);
// we check here if the reader needs to be informed about it.
$intro .= t('<p>The messages are passed to the t-function when parsed to view.</p>');
$intro .= '<h2>' . t('Default message templates') . '</h2>';
$intro .= theme('table', $headers, $default_rows);
if (count($custom_rows) > 0) {
$intro .= '<h2>' . t('Custom message templates') . '</h2>';
$intro .= theme('table', $headers, $custom_rows);
}
return $intro;
}