SimplePortal

Customization => Custom Coding => Topic started by: hot rides on December 09, 2008, 05:56:35 PM

Title: User Info block alt.
Post by: hot rides on December 09, 2008, 05:56:35 PM
I modified my User Info block to suit my site's needs, I also have seen a couple topics on here requesting help for the exact changes I made so I thought I would share.

Its the exact same code that comes with SimplePortal with the addition of the 'unread post' & 'new replies' links and the 'Total time logged' statement so that I could remove it from my header.

Code: [Select]
global $context, $txt, $scripturl, $settings, $memberContext, $modSettings, $member_id, $sc;
global $color_profile;

if($context['user']['is_logged']) {
$member_id = $context['user']['id'];
loadMemberData($member_id);
loadMemberContext($member_id);

//If you install the Membercolor Link the colors will be autmaticly set.
if(empty($modSettings['MemberColorLinkInstalled']) && sp_loadColors($member_id) !== false)
$memberContext[$member_id]['colored_name'] = $color_profile[$member_id]['colored_name'];

$memberContext[$member_id]['karma']['total'] = $memberContext[$member_id]['karma']['good'] - $memberContext[$member_id]['karma']['bad'];
}
echo '<div align="center">';

if ($context['user']['is_guest'])
echo '<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '">
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td align="right"><label for="user">', $txt[35], ':</label> </td>
<td><input type="text" id="user" name="user" size="9" value="', !empty($user_info['username']) ? $user_info['username'] : '', '" /></td>
</tr><tr>
<td align="right"><label for="passwrd">', $txt[36], ':</label> </td>
<td><input type="password" name="passwrd" id="passwrd" size="9" /></td>
</tr><tr>
<td><input type="hidden" name="cookielength" value="-1" /></td>
<td><input type="submit" value="', $txt[34], '" /></td>
</tr>
</table>
</form>', $txt['welcome_guest'];

else
{
echo $txt['hello_member'], ' <b>', (!empty($memberContext[$member_id]['colored_name']) ? $memberContext[$member_id]['colored_name'] : $context['user']['name']), '</b><br /><br />';

if (!empty($context['user']['avatar']))
echo $context['user']['avatar']['image'], '<br />';

if ($context['user']['is_logged'])
{
echo '
<span style="font-size: 75%;"> <a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a> <br />
<a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a><br /></span><br>';

}
if (!empty($memberContext[$member_id]['group']))
echo $memberContext[$member_id]['group'];
else
echo $memberContext[$member_id]['post_group'];

echo '<br />', $memberContext[$member_id]['group_stars'], '<br /><br /></div>
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt[21], ': ',$memberContext[$member_id]['posts'],'<br />';

if(!empty($modSettings['karmaMode']))
echo '
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-userkarma'], ': ';

if($modSettings['karmaMode'] == '1')
echo $memberContext[$member_id]['karma']['total'],'<br />';
elseif($modSettings['karmaMode'] == '2')
echo '+', $memberContext[$member_id]['karma']['good'],'/-', $memberContext[$member_id]['karma']['bad'], '<br />';

}

if(allowedTo('pm_read'))
echo '
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-usertmessage'], ': <a href="' . $scripturl . '?action=pm">' . $context['user']['messages'], '</a><br />
<img src="' . $settings['images_url'] . '/dot.gif" alt="', $txt['sp-dot'], '" /> ', $txt['sp-usernmessage'], ': ' . $context['user']['unread_messages'], '<br /><br />';

if (!empty($context['user']['total_time_logged_in']))

{

echo '

<span style="font-size: 75%;"> ', $txt['totalTimeLogged1'];
echo'
         <br>';
// If days is just zero, don't bother to show it.
                            if ($context['user']['total_time_logged_in']['days'] > 0)

echo $context['user']['total_time_logged_in']['days'] . $txt['totalTimeLogged2'];


// Same with hours - only show it if it's above zero.

if ($context['user']['total_time_logged_in']['hours'] > 0)

echo $context['user']['total_time_logged_in']['hours'] . $txt['totalTimeLogged3'];



// But, let's always show minutes - Time wasted here: 0 minutes ;).

echo $context['user']['total_time_logged_in']['minutes'], $txt['totalTimeLogged4'], '<br /></span>';

}
// Now, onto our second set of info, are they logged in again?
if ($context['user']['is_logged'])
{
// Is the forum in maintenance mode?
if ($context['in_maintenance'] && $context['user']['is_admin'])
echo '
<b>', $txt[616], '</b><br />';

}

just toss the code in a PHP block

you can see it working at my site (http://hot-rides.net/forum)
user; testuser
passwrd; testpassword

this is a smf 1.1.x only change
Title: Re: User Info block alt.
Post by: Burke Knight on December 09, 2008, 07:03:36 PM
Actually, we cannot see it fully in action, unless we were to join, as most of it does not show for guests... LOL :P

Nice job, though. :)


EDIT:

I also see this is for SMF 1.1.x as I'm not sure, but I think the coding may be different in the SMF 2.0 line. Will need a dev member to verify. :)
Title: Re: User Info block alt.
Post by: ???1031 on December 10, 2008, 05:01:03 AM
Yes the language strings are diffrent in SMF 2.0, this will only work in SMF 1.1.x ;).
Title: Re: User Info block alt.
Post by: hot rides on December 11, 2008, 11:25:52 AM
Actually, we cannot see it fully in action, unless we were to join, as most of it does not show for guests... LOL :P

Nice job, though. :)


EDIT:

I also see this is for SMF 1.1.x as I'm not sure, but I think the coding may be different in the SMF 2.0 line. Will need a dev member to verify. :)
opps, sorry bout that.
heres a test account;
user; testuser
passwrd; testpassword

and yes its only smf 1.1 I completely forget about 2 as I dont use it
SimplePortal 2.3.8 © 2008-2024, SimplePortal