You are here

function flags_widget in Heartbeat 6.4

Implementation of <attchement>_widget().

File

modules/flag_heartbeat/flag_heartbeat.module, line 49

Code

function flags_widget($attachments, $message) {
  $flags = $attachments['flags'];
  $widgetfields = array();
  if (!empty($flags)) {
    foreach ($flags as $flagname) {
      if (!empty($flagname) && !is_numeric($flagname)) {

        // Two possibilities.
        // 1. with a persistent rendered flag message.

        //$flag = flag_get_flag($flagname);

        //$widgetfield = $flag->theme($flag->is_flagged($message->uaid) ? 'unflag' : 'flag', $message->uaid, TRUE);

        // 2. showing the link and the count separately.
        $widgetfield = flag_create_link($flagname, $message->uaid);

        // $counts = flag_get_counts('heartbeat_message', $message->uaid);
        // $widgetfield .= ' ' . t('@count users like this', array('@count' => (isset($counts[$flagname]) ? $counts[$flagname] : 0)));
        // Solution is coming up from Drupal7 version.
        $widgetfields[] = $widgetfield;
      }
    }
  }
  return implode(' - ', $widgetfields);
}