You are here

function heartbeat_messages_add_submit in Heartbeat 6.4

Same name and namespace in other branches
  1. 6.3 heartbeat.admin.inc \heartbeat_messages_add_submit()

Accept the form submission to add messages.

File

./heartbeat.admin.inc, line 1174
Admnistration tasks for heartbeat.

Code

function heartbeat_messages_add_submit($form, &$form_state) {
  if (!($form_state['clicked_button']['#value'] == t('Save') || $form_state['clicked_button']['#value'] == t('Import'))) {
    return;
  }
  if (!empty($form_state['values']['message'])) {
    $message = new stdClass();
    $message->message_id = $form_state['values']['message_id'];
    $message->message = $form_state['values']['message'];
    $message->message_concat = $form_state['values']['message_concat'];
    $message->perms = $form_state['values']['perms'];
    $message->custom = HEARTBEAT_MESSAGE_CUSTOM;
    $message->description = $form_state['values']['description'];
    $message->tags = $form_state['values']['tags'];
    $concat_args = array(
      'type' => $form_state['values']['type'],
      'group_by' => $form_state['values']['group_by'],
      'group_target' => $form_state['values']['group_target'],
      'group_by_target' => $form_state['values']['group_by_target'],
      'group_num_max' => $form_state['values']['group_num_max'],
      'merge_separator' => $form_state['values']['merge_separator'],
      'merge_end_separator' => $form_state['values']['merge_end_separator'],
      'show_remaining_items' => $form_state['values']['show_remaining_items'],
      'roles' => $form_state['values']['roles'],
    );
    $message->concat_args = $concat_args;
    if (!empty($form_state['values']['attachments'])) {
      $message->attachments = $form_state['values']['attachments'];
    }
    if (!empty($form_state['values']['data'])) {
      $message->variables = $form_state['values']['data'];
    }
    heartbeat_message_insert($message);
    drupal_set_message(t('New message was added and can be used in actions of a rule'));
  }
  return;
}