You are here

function heartbeat_messages_add_submit in Heartbeat 6.3

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

Accept the form submission to add messages.

File

./heartbeat.admin.inc, line 344

Code

function heartbeat_messages_add_submit($form, &$form_state) {
  if ($form_state['clicked_button']['#value'] != t('Save')) {
    return;
  }
  if (!empty($form_state['values']['message'])) {
    $variables = array(
      'type' => $form_state['values']['type'],
      'group_by' => $form_state['values']['group_by'],
      'group_target' => $form_state['values']['group_target'],
      'merge_separator' => $form_state['values']['merge_separator'],
      'merge_end_separator' => $form_state['values']['merge_end_separator'],
      'perms' => $form_state['values']['perms'],
    );
    if (!empty($form_state['values']['data'])) {
      $variables = array_merge($variables, $form_state['values']['data']);
    }
    $concat_args = heartbeat_encode_message_variables($variables);
    $result = db_query("INSERT INTO {heartbeat_messages} SET message_id ='%s', custom = %d, message ='%s', message_concat ='%s',\n    message_type = '%s', perms = %d, description = '%s', module = '%s', concat_args = '%s'  ", $form_state['values']['message_id'], (int) $form_state['values']['custom'], $form_state['values']['message'], $form_state['values']['message_concat'], $form_state['values']['message_type'], $form_state['values']['perms'], $form_state['values']['description'], $form_state['values']['module'], $concat_args);
    drupal_set_message(t('New message was added and can be used in actions of a rule'));

    //dsm($result);
  }

  //$form_state['redirect'] = 'admin/settings/heartbeat/messages';
  return;
}