You are here

function heartbeat_plugins_modal_flagging_users in Heartbeat 7

CTools ajax callback to show the users who flagged the content.

1 string reference to 'heartbeat_plugins_modal_flagging_users'
HeartbeatFlagAttachmentPlugin::getMenuItems in modules/heartbeat_plugins/plugins/flagattachment.inc
getMenuItems().

File

modules/heartbeat_plugins/includes/heartbeatflagplugin.inc, line 10
Heartbeat Flag Base Plugin and some required utility functions.

Code

function heartbeat_plugins_modal_flagging_users($js, $heartbeatActivity) {
  $uaid = $heartbeatActivity->uaid;
  $result = db_query("SELECT u.name, files.uri, f.uid FROM {file_managed} files INNER JOIN {users} u ON u.picture = files.fid INNER JOIN {flag_content} f ON f.uid = u.uid WHERE content_id = :uaid AND content_type = 'heartbeat_activity' ", array(
    ':uaid' => $uaid,
  ));
  $output = '';
  $list = array();
  $use_ds = module_exists('ds');
  foreach ($result as $account) {
    if ($use_ds) {
      $list[] = drupal_render(user_view($account, 'heartbeat_user'));
    }
    else {
      $list[] = theme('heartbeat_flagging', array(
        'heartbeatactivity' => $heartbeatActivity,
        'uri' => $account->uri,
        'name' => $account->name,
        'uid' => $account->uid,
      ));
    }
  }
  $output = theme('item_list', array(
    'items' => $list,
  ));

  // Fall back if $js is not set.
  if (!$js) {
    return $output;
  }
  else {
    ctools_include('ajax');
    $commands = array();
    $commands[] = ajax_command_html('#modal-content', $output);
    print ajax_render($commands);
    exit;
  }
}