You are here

class flag_heartbeat_message in Heartbeat 7

Same name and namespace in other branches
  1. 6.4 modules/flag_heartbeat/class.flag_heartbeat_message.inc \flag_heartbeat_message
  2. 6.3 modules/flag_heartbeat/class.flag_heartbeat_message.inc \flag_heartbeat_message

Exposes a Heartbeat Message Flag.

Hierarchy

Expanded class hierarchy of flag_heartbeat_message

1 string reference to 'flag_heartbeat_message'
HeartbeatFlagAttachmentPlugin::flagDefinitions in modules/heartbeat_plugins/plugins/flagattachment.inc
flagDefinitions(). Defines the flag definition.

File

modules/heartbeat_plugins/plugins/flagattachment.inc, line 271

View source
class flag_heartbeat_message extends flag_flag {
  function options_form(&$form) {
    parent::options_form($form);
    $form['access']['types'] = array(
      // A user flag doesn't support node types.
      // TODO: Support heartbeat templates instead of node types.
      '#type' => 'value',
      '#value' => array(
        0 => 0,
      ),
    );
  }
  function _load_content($content_id) {
    $heartbeatActivity = HeartbeatMessagePool::getInstance()
      ->getMessage($content_id);
    return is_numeric($content_id) ? $heartbeatActivity : NULL;
  }
  function applies_to_content_object($message_instance) {
    if ($message_instance) {
      return TRUE;
    }
    return FALSE;
  }
  function get_content_id($heartbeat_message) {
    return $heartbeat_message->uaid;
  }
  function uses_hook_link($teaser) {
    return TRUE;
  }
  function get_labels_token_types() {
    return array_merge(array(
      'heartbeat_activity',
    ), parent::get_labels_token_types());
  }
  function replace_tokens($label, $contexts, $options, $content_id) {
    if ($content_id) {
      if ($content_id instanceof HeartbeatActivity) {
        $contexts['heartbeat_activity'] = $content_id;
        $content_id = $contexts['heartbeat_activity']->uaid;
      }
      elseif ($message = $this
        ->fetch_content($content_id)) {
        $contexts['heartbeat_activity'] = $message;
      }
    }
    return parent::replace_tokens($label, $contexts, $options, $content_id);
  }
  function get_flag_action($content_id) {
    $flag_action = parent::get_flag_action($content_id);
    $flag_action->content_title = $this
      ->fetch_content($content_id)->message;
    return $flag_action;
  }
  function get_relevant_action_objects($content_id) {
    return array(
      'heartbeat_activity' => $this
        ->fetch_content($content_id),
    );
  }
  function rules_get_event_arguments_definition() {
    return array(
      'heartbeat_activity' => array(
        'type' => 'heartbeat_activity',
        'label' => t('flagged heartbeat message'),
        'handler' => 'flag_rules_get_event_argument',
      ),
    );
  }
  function rules_get_element_argument_definition() {
    return array(
      'type' => 'heartbeat_activity',
      'label' => t('Flagged heartbeat message'),
    );
  }
  function get_views_info() {
    return array(
      'views table' => 'heartbeat_activity',
      'title field' => 'message',
      'title' => t('Activity flag'),
      'help' => t('Limit results to only those messages flagged by a certain flag; Or display information about the flag set on an activity message.'),
      'counter title' => t('Activity flag counter'),
      'counter help' => t('Include this to gain access to the flag counter field.'),
    );
  }
  function applies_to_content_id_array($content_ids) {
    $passed = array();
    foreach ($content_ids as $uaid) {
      $passed[$uaid] = TRUE;
    }
    return $passed;
  }

}

Members