function heartbeat_messages_import_submit in Heartbeat 6.4
Import for heartbeat message templates().
File
- ./
heartbeat.admin.inc, line 1417 - Admnistration tasks for heartbeat.
Code
function heartbeat_messages_import_submit($form, &$form_state) {
@eval('$import = ' . $form_state['values']['import'] . ';');
if (isset($import) && is_array($import) && count($import)) {
$messages = array();
foreach (heartbeat_messages('all', TRUE) as $template) {
$messages[$template->message_id] = $template->hid;
}
foreach ($import as $key => $message) {
$message['custom'] = HEARTBEAT_MESSAGE_CUSTOM;
if (isset($messages[$message['message_id']])) {
heartbeat_message_update($message);
drupal_set_message(t('Updated %template.', array(
'%template' => $message['message_id'],
)));
}
else {
heartbeat_message_insert($message);
drupal_set_message(t('Imported %template.', array(
'%template' => $message['message_id'],
)));
}
}
}
else {
drupal_set_message(t('Import failed.'), 'error');
}
}