UBB.Dev
Posted By: AshtarRose Last Posted Viewable on ShowSide/Show Top - 10/06/2007 2:46 AM
I'd like to see if one of you super geniuses would know how to add a mod to my posts that show when the person last posted under their avatar.

It shows last posted in the CPanel so it keeps track somewhere, can that be harnessed and displayed for all users to see when they post.
Code

}

if ($lastpost) {
$lastpost = $html->convert_time($lastpost,$user['USER_TIME_OFFSET'], $user['USER_TIME_FORMAT']);
}

Is there somewhere to enter this?
Posted By: Gizmo Re: Last Posted Viewable on ShowSide/Show Top - 10/06/2007 8:22 AM
I'd immagine so
Well I know where I got it from, whats the right way to work the code into the postside so it doesn't wig everything out. Or is it just that straight code.
In /scripts/showflat.inc.php you should add that code, or something like it that would really work, put it in the posts show thingy array, and show that thingy in the smarty template.

As easy as counting 1,2,3 smile
Your speaking cow to a bird, huh? Heh *twitch*

So I can slip
Code

$query = "
SELECT NOTE_TEXT
FROM {$config['TABLE_PREFIX']}USER_NOTES
WHERE USER_ID = ?
";
$sth = $dbh -> do_placeholder_query($query,array($uid),__LINE__,__FILE__);
list($notes) = $dbh -> fetch_array($sth);
// Setup the default values

if ($lastpost) {
$lastpost = $html->convert_time($lastpost,$user['USER_TIME_OFFSET'], $user['USER_TIME_FORMAT']);
}

Somewhere near
Code

}
}
$postrow[$i]['Username'] = $Username;
$postrow[$i]['Title'] = $Title;
$postrow[$i]['CustomTitle'] = $CustomTitle;

if ( ($config['SHOW_POSTER_IP'] == 1) && $IP) {
$postrow[$i]['IP'] = "($IP)";
}

elseif ( ($config['SHOW_POSTER_IP'] == 2) && ( ($user['USER_MEMBERSHIP_LEVEL'] == "Administrator") || ($ismod=='yes') ) && ($IP) ) {
$postrow[$i]['IP'] = "($IP)";

On showflat.inc.php

...

But the rest of what your saying.. erg?
Posted By: sirdude Re: Last Posted Viewable on ShowSide/Show Top - 10/07/2007 12:04 AM
um that's easy peasy..

if Yarp™ hasn't done it by later on today i can whip it up for you..

should be a 5 minute dealio
In my head it seems like it should be super easy to do, I want people to know when someone made their last post and to me it almost seems like plugging code into a new spot. But its still intimidating.
Posted By: blaaskaak Re: Last Posted Viewable on ShowSide/Show Top - 10/07/2007 12:21 AM
I'll start the frying pan to cook things up smile

Where do you want it? Right under the avatar?
http://www.riddledindarkness.com/hp...flat&Number=537264&Main=17197#Post537264

I want to be able to slip it under Posts:

Posts:
Last Posted:


he board revolves around activity, if their posting somewhere on the board then I'd like it to be known their active even if they've not responded to a thread they've started.
Posted By: blaaskaak Re: Last Posted Viewable on ShowSide/Show Top - 10/07/2007 12:31 AM
I just had a looksy, and it is pretty easy to do, but it will put an extra serverload to your forum because we have to join in a 4th table (ubbt_USER_DATA) to the main query of showflat.inc.php which will make the query run longer. How much the impact really is, I don't know smile

It's not just showing some field that's there anyway but not shown.
Registered: 08/29/07
Posts: 2
01/01/70 01:00 AM

bleh... fix fix fix...

edit: fixed smile
Done! SD can take the time to finished up sunday evenings zip smile

in /scripts/showflat.inc.php there's a line with
Code
	// This is the main query that will be used

Replace the beautifull query below it with this one:
Code
	$query = "
SELECT t1.POST_ID,t2.USER_DISPLAY_NAME,t1.POST_POSTED_TIME,t1.POST_POSTER_IP,t1.POST_SUBJECT,t1.POST_BODY,t1.POST_IS_APPROVED,t3.USER_AVATAR,t3.USER_TITLE,t3.USER_CUSTOM_TITLE,t3.USER_NAME_COLOR,t1.POST_ICON,t1.POST_HAS_POLL,t1.POST_HAS_FILE,t1.POST_PARENT_ID,t2.USER_MEMBERSHIP_LEVEL,t3.USER_SIGNATURE,t1.POST_LAST_EDITED_TIME,t1.POST_LAST_EDIT_REASON,t1.POST_LAST_EDITED_BY,t3.USER_LOCATION,t3.USER_TOTAL_POSTS,t2.USER_REGISTERED_ON,t3.USER_RATING,t3.USER_AVATAR_WIDTH,t3.USER_AVATAR_HEIGHT,t2.USER_ID,t1.POST_PARENT_USER_ID,t3.USER_BIRTHDAY,t3.USER_PUBLIC_BIRTHDAY,t1.POST_ADD_SIGNATURE,t3.USER_ACCEPT_PM,t3.USER_HOMEPAGE,t3.USER_VISIBLE_ONLINE_STATUS,t3.USER_MOOD,t1.POST_POSTER_NAME,t4.USER_LAST_POST_TIME
FROM {$config['TABLE_PREFIX']}POSTS AS t1,
{$config['TABLE_PREFIX']}USERS AS t2,
{$config['TABLE_PREFIX']}USER_PROFILE as t3,
{$config['TABLE_PREFIX']}USER_DATA as t4
WHERE t1.PREG_QUERY_FIELD = ?
AND t1.USER_ID = t2.USER_ID
AND t1.USER_ID = t3.USER_ID
AND t1.USER_ID = t4.USER_ID
$Viewable
ORDER BY POST_ID
";

Find:
Code
		list ($Number,$Username,$Posted,$IP,$Subject,$Body,$Approved,$Picture,$Title,$CustomTitle,$Color,$Icon,$Poll,$Files,$ParentPost,$PostStatus,$Signature,$LastEdit,$LastEditReason,$LastEditBy,$Location,$TotalPosts,$Registered,$stars,$picwidth,$picheight,$usernum,$ParentUser,$bday,$showbday,$addsig,$accept_pm,$homepage,$visible,$mood,$postername) = $results[$i];

Replace with
Code

list ($Number,$Username,$Posted,$IP,$Subject,$Body,$Approved,$Picture,$Title,$CustomTitle,$Color,$Icon,$Poll,$Files,$ParentPost,$PostStatus,$Signature,$LastEdit,$LastEditReason,$LastEditBy,$Location,$TotalPosts,$Registered,$stars,$picwidth,$picheight,$usernum,$ParentUser,$bday,$showbday,$addsig,$accept_pm,$homepage,$visible,$mood,$postername,$userlastpost) = $results[$i];



Find
Code
		$PrintLastEdit = "";

Add below:
Code

if ($userlastpost) {
$userlastpost = $html -> convert_time($userlastpost,$useroffset,$user['USER_TIME_FORMAT']);
}
$postrow[$i]['userlastpost'] = "Last post: $userlastpost";

in /templates/default/post_side.tpl
find
Code
{$postrow[post].TotalPosts}

add below:
Code
{if $postrow[post].userlastpost}
<br />
{$postrow[post].userlastpost}
{/if}

Replace #1 adjusts the query so that the lastpost time is available in the query.

Replace #2 makes sure the output of that new field is available for the script

Replace #3 Formats the data and makes it available for the template.

Replace #4 just adds it to the template.

I am pretty sure you can do what you need to do for post_top.

Enjoy! And if there something wrong, let me know. I probably spend only 10 seconds after I thought it was finished.
Hack Working! Kick Ass! There is no excuse to abandon a thread if someone can clearly see wether you are active or not.
Posted By: blaaskaak Re: Last Posted Viewable on ShowSide/Show Top - 10/07/2007 10:22 AM
Heck, there's even a last visit field where the actual last time of visit is kept in if you want to take it further.

If you would want that, change in replace #1 t4.USER_LAST_POST_TIME by t4.USER_LAST_VISIT_TIME

And change the text ofcourse.
© UBB.Developers