function sf_sendpm_tag($userid, $text = '')
{
    global $current_user, $sfvars;
    sf_initialise_globals($sfvars['forumid']);
    # dont display tag if not a registered user
    if ($current_user->ID == '' || !$current_user->sfusepm) {
        return;
    }
    $out = '';
    if ($userid) {
        $buddy_name = stripslashes(sf_get_member_item($userid, "display_name"));
        $url = sf_build_qurl("pmaction=sendpm&pms={$current_user->ID}&pmtoname={$buddy_name}");
        if ($text == '') {
            $out .= '<a class="sfsendpmtag" href="' . $url . '"><img src="' . SFRESOURCES . 'sendpm-small.png" title="' . __("Send PM", "sforum") . '" />&nbsp;' . sf_render_icons("Send PM") . '</a>';
        } else {
            $out .= str_replace('%%', $url, $text);
        }
    }
    echo $out;
    return;
}
function sf_group_link($groupid, $linktext = '', $listtags = true)
{
    global $wpdb, $current_user, $sfvars;
    sf_initialise_globals($sfvars['forumid']);
    if (empty($groupid)) {
        return '';
    }
    $out = '';
    $forums = $wpdb->get_results("SELECT forum_id FROM " . SFFORUMS . " WHERE group_id='" . $groupid . "'");
    if ($forums) {
        foreach ($forums as $forum) {
            if (sf_can_view_forum($forum->forum_id)) {
                $grouprec = sf_get_group_record($groupid);
                if (empty($linktext)) {
                    $linktext = stripslashes($grouprec->group_name);
                }
                if ($listtags) {
                    $out .= "<li>\n";
                }
                $out .= '<a href="' . sf_build_qurl('group=' . $groupid) . '">' . $linktext . '</a>' . "\n";
                if ($listtags) {
                    $out .= "</li>\n";
                }
                break;
            }
        }
    } else {
        $out = printf(__('Group %s Not Found', 'sforum'), $groupid) . "\n";
    }
    echo $out;
    return;
}