You are here

function flag_heartbeat_form_alter in Heartbeat 6.3

Implementation of hook_form_alter().

File

modules/flag_heartbeat/flag_heartbeat.module, line 32
Provides flag integration on heartbeat messages.

Code

function flag_heartbeat_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'heartbeat_messages_edit') {
    if (arg(3) == 'edit' && arg(4) > 0) {

      // Get messages
      $result = db_query("SELECT * FROM {heartbeat_messages} WHERE hid = %d LIMIT 1", arg(4));
      $message = db_fetch_object($result);

      // concat args , if merging is set
      $variables = heartbeat_decode_message_variables($message->concat_args);
    }
    $flags = flag_get_flags('heartbeat_message');
    foreach ($flags as $option) {
      $options[$option->name] = $option->title;
    }
    $form['data']['flags'] = array(
      '#type' => 'checkboxes',
      '#default_value' => isset($variables['flags']) ? drupal_map_assoc($variables['flags']) : array(),
      '#title' => t('Add flags to this message'),
      '#options' => $options,
      '#weight' => 25,
    );
  }
}