You are here

flag_heartbeat.module in Heartbeat 6.3

Same filename and directory in other branches
  1. 6.4 modules/flag_heartbeat/flag_heartbeat.module

Provides flag integration on heartbeat messages.

File

modules/flag_heartbeat/flag_heartbeat.module
View source
<?php

// by Stalski (Jochen Stals) - ONE-agency - www.one-agency.be

/**
 * @file
 * Provides flag integration on heartbeat messages.
 */

/**
 * Implementation of hook_init().
 */
function flag_heartbeat_init() {
  include 'class.flag_heartbeat_message.inc';
}

/**
 * Implementation of hook_flag_definitions().
 */
function flag_heartbeat_flag_definitions() {
  return array(
    'heartbeat_message' => array(
      'title' => t('Heartbeat message'),
      'description' => t("Heartbeat messages are activity streams for occurring actions."),
      'handler' => 'flag_heartbeat_message',
    ),
  );
}

/**
 * Implementation of hook_form_alter().
 */
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,
    );
  }
}

Functions

Namesort descending Description
flag_heartbeat_flag_definitions Implementation of hook_flag_definitions().
flag_heartbeat_form_alter Implementation of hook_form_alter().
flag_heartbeat_init Implementation of hook_init().