<?php
/*
Simple:Press Forum
Profile Rendering Routines
$LastChangedDate: 2010-01-25 23:00:19 -0700 (Mon, 25 Jan 2010) $
$Rev: 3337 $
*/

if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
	die('Access Denied');
}

function sf_render_profile()
{
	global $sfvars, $current_user;

    $out = '';

	# Maybe a Show Profile page
	if ($sfvars['pageview'] == 'profileshow' || $sfvars['pageview'] == 'profileedit')
    {
        if (!empty($sfvars['member']))
        {
            $userid = sf_get_user_id(urldecode($sfvars['member']));
        } else {
            $userid = $current_user->ID;
        }

        # do we have a valid member profile requested?
        if (!$userid || (!$current_user->sfprofiles && $current_user->ID != $userid && !$current_user->adminstatus))
        {
			$sflogin=sf_get_option('sflogin');
            wp_redirect($sflogin['sfloginurl']);
        }

        if ($sfvars['pageview'] == 'profileshow' || ($current_user->ID != $userid && !$current_user->adminstatus))
        {
            $out.= sf_view_profile($userid);
        } else {
            $out.= sf_profile_form('all', $userid, $sfvars['newuser']);
        }
    }

	return $out;
}

function sf_view_profile($userid)
{
	include_once (SF_PLUGIN_DIR.'/profile/sf-profile-display.php');
	return sf_render_member_profile($userid, 'page');
}

function sf_profile_form($panel, $newuser=0)
{
	include_once (SF_PLUGIN_DIR.'/profile/forms/sf-form-profile.php');
	return sf_render_profile_form($panel, $newuser);
}

function sf_view_permissions()
{
	include_once (SF_PLUGIN_DIR.'/profile/forms/sf-form-permissions.php');
	return sf_render_permissions_form();
}

function sf_view_buddylist()
{
	include_once (SF_PLUGIN_DIR.'/profile/forms/sf-form-buddylist.php');
	return sf_render_buddylist_form();
}

?>