load($uid); $cols = 2; $col_width_pix = 90; $badge_width_pix = $cols * $col_width_pix; $html = << EOF; if ($show_what == 'show') { // new-style blog badge $badge_tag = $param; try { $badge = $user->get_blog_badge_config($badge_tag); } catch (PAException $e) { if ($e->code != ROW_DOES_NOT_EXIST) throw $e; $html = "

User has not yet created a blog badge.

"; $badge = array(); } $friends =& $badge['friends']; if (@$friends['enabled']) { $html .= "

My friends

"; $rel = Relation::get_relations($user->user_id); // now, for all of the user's $rel_incl = $friends['included']; $rel_show = array(); $rel_show_two = array(); $n_rel = count($rel); if ($n_rel < 2) { $rel_random = array_keys($rel); } else { $rel_random = array_rand($rel, $n_rel); } foreach ($rel_random as $rel_k) { $rel_id = (int)$rel[$rel_k]; if (@$rel_incl[$rel_id]) { $rel_show[] = $rel_id; } else { $rel_show_two[] = $rel_id; } } // if we're showing unselected users too, add them in if ($friends['show'] == 'all') { $rel_show = array_merge($rel_show, $rel_show_two); } $show_max = 8; // show max 8 friends in the badge foreach ($rel_show as $rel_id) { if ($show_max-- <= 0) break; $person_url_enc = $base_url."/user.php?uid=$rel_id"; $rel_user = new User(); $rel_user->load($rel_id); $person_name_enc = htmlspecialchars("$rel_user->first_name $rel_user->last_name"); $img = uihelper_resize_mk_user_img($rel_user->picture, 75, 75); $html .= <<
$img
$person_name_enc
EOS; } $html .= << EOS; } $groups =& $badge['groups']; if (@$groups['enabled']) { $html .= "

My groups

"; } } else { // old-style friends / groups badge $html .= "

user_id\">$user->first_name $user->last_name's $show_what:

"; $show_all_url = ""; switch ($show_what) { case 'friends': $perpage = (int)$param; $relations = Relation::get_all_relations($user->user_id, 0, FALSE, $param, $page); $n = count($relations); $rows = intval($n/3) + ($n % 3 ? 1 : 0); $pos = 0; $html .= ""; for ($y = 0; $y < $rows; ++$y) { $html .= ""; for ($x = 0; $x < $cols && $pos < $n; ++$x, ++$pos) { $html .= '"; } $html .= ""; } $show_all_url = "$base_url/view_all_members.php?view_type=relations&uid=$user->user_id"; $html .= ""; for ($i = 0; $i < $cols - 1; ++$i) $html .= ''; $html .= ""; $html .= "
'; $rel = $relations[$pos]; $html .= ''; if ($rel['picture'] && file_exists("files/".$rel['picture'])) { $html .= uihelper_resize_mk_user_img($rel['picture'], 50, 50) . "
"; } $html .= htmlspecialchars($rel['login_name']).'
'; $html .= "
show all
"; break; case 'groups': $perpage = (int)$param; $html .= ""; break; } } $html .= '

'; $html .= ""; } else { $html = "Error parsing URL ($path)."; } switch ($format) { case 'js': header("Content-Type: application/x-javascript"); echo "document.write('".str_replace("\n", "\\n", str_replace("'", "\\'", $html))."');"; break; case 'html': echo $html; break; } ?>