You are here

function commons_follow_get_followed_content in Drupal Commons 7.3

Get a list of all content that a user is following.

Return value

An array keyed on the flag name with values corresponding to the IDs of the flagged entities.

1 call to commons_follow_get_followed_content()
commons_follow_get_followed_message_ids in modules/commons/commons_follow/commons_follow.module
Find a list of message IDs that correspond to events that the current user is following.

File

modules/commons/commons_follow/commons_follow.module, line 304

Code

function commons_follow_get_followed_content($account = array()) {
  if (empty($account)) {
    global $user;
    $account = $user;
  }
  $results = array();
  $flag_ids = commons_follow_get_flag_ids();

  // Get a list of everything that the user is following.
  $result = db_query("SELECT fid, entity_id FROM {flagging} WHERE fid IN (:fids) AND uid = :uid", array(
    ':fids' => array_keys($flag_ids),
    ':uid' => $account->uid,
  ));
  foreach ($result as $this_result) {
    $results[$flag_ids[$this_result->fid]][] = $this_result->entity_id;
  }
  return $results;
}