/**
  * returns a list of ids from online-identities connected to
  * the user
  *
  * @author Matthias Pfefferle
  * @param int $pUserId
  * @return array
  */
 public static function getIdsOfFriendsByUserId($pUserId)
 {
     $lOis = array();
     $lQueryString = array();
     // @todo refactor this to query only the ids
     $lOwnedOis = OnlineIdentityTable::retrieveByUserId($pUserId);
     foreach ($lOwnedOis as $lIdentity) {
         if ($lIdentity->getFriendIds() != '') {
             $lQueryString[] = '(oi.community_id = ' . $lIdentity->getCommunityId() . ' AND oi.original_id IN (' . $lIdentity->getFriendIds() . '))';
         }
     }
     $q = new Doctrine_RawSql();
     $q->select('{oi.id}')->from('online_identity oi')->distinct()->addComponent('oi', 'OnlineIdentity');
     // !empty means, ther's at least 1 contact
     if (!empty($lQueryString)) {
         $q->where(implode(' OR ', $lQueryString));
         $lOis = $q->execute(array(), Doctrine_Core::HYDRATE_NONE);
     }
     return HydrationUtils::flattenArray($lOis);
 }