示例#1
0
 public function loadRelations()
 {
     // load all this users relations
     $this->user->{'local_relations'} = Relation::get_all_relations($this->user->user_id);
     $this->user->{'external_relations'} = Relation::get_external_relations($this->user->user_id);
 }
function FriendList($content)
{
    global $uid, $service;
    // get relations for this user
    // so we can see if these friends are already added or not
    $external_relations = Relation::get_external_relations($uid);
    // put into more accessible form
    $existing_relations = array();
    foreach ($external_relations as $k => $rel) {
        $existing_relations[$rel['network'] . ':' . $rel['network_uid']] = true;
    }
    echo '<ul class="friendlist">';
    foreach ($content as $k => $friend) {
        echo '<li class="vcard" id="' . $friend->friendid . '">';
        echo '<a class="fn url" rel="friend" href="' . $friend->pageUrl . '" target="_blank">';
        echo '<img class="photo" src="' . $friend->icon . '">';
        echo '<br />';
        echo $friend->name;
        echo '</a>';
        echo '<div class="friendconfig buttonbar"><ul><li>';
        if (isset($existing_relations[$service . ':' . $friend->friendid])) {
            echo '<a href="javascript://" onclick="removerelation(this);">';
            echo 'remove from Widget';
            echo '</a>';
        } else {
            echo '<a href="javascript://" onclick="addrelation(this);">';
            echo 'add to Widget';
            echo '</a>';
        }
        echo '</li></ul></div>';
        echo '</li>';
    }
    echo '</ul>';
    echo '<p class="header">&nbsp;</p>';
}