 |
 |
 |
 |
#312680 - 01/14/07 10:08 PM
Checking user group for group icons in showflat
|
Power User
Registered: 12/17/02
Posts: 71
|
Hi kids, I had several mods that don't port over from 6.5 to 7 and I'm working on getting them going. One that I wanted was the custom group icons under a user's name in showflat (I never use showthreaded). Here's where I am so far: In showflat.inc.php, changed this (around line 631): $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_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_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
FROM {$config['TABLE_PREFIX']}POSTS AS t1,
{$config['TABLE_PREFIX']}USERS AS t2,
{$config['TABLE_PREFIX']}USER_PROFILE as t3
WHERE t1.TOPIC_ID = ?
AND t1.USER_ID = t2.USER_ID
AND t1.USER_ID = t3.USER_ID
$Viewable
ORDER BY POST_ID
$Limit
";
to this: $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_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_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,t4.GROUP_ID
FROM {$config['TABLE_PREFIX']}POSTS AS t1,
{$config['TABLE_PREFIX']}USERS AS t2,
{$config['TABLE_PREFIX']}USER_PROFILE as t3,
{$config['TABLE_PREFIX']}USER_GROUPS as t4
WHERE t1.TOPIC_ID = ?
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
$Limit
";
and after this (around line 679): $postrow[$i]['UserStatus'] = "";
I added this: $postrow[$i]['GroupId'] = "";
and then BEFORE this (around line 923): I added this: if (preg_match("/-5-/",$GroupId)) { $postrow[$i]['GroupName'] = "Premium";
$postrow[$i]['GroupPic'] = "<a href=\"http://www.hairtell.com/ubbthreads/premium.php\"><img src=\"http://www.hairtell.com/forum/images/subscriber01.jpg\" border=\"0\"></a>";
}
if (preg_match("/-6-/",$GroupId)) { $postrow[$i]['GroupName'] = "Pro";
$postrow[$i]['GroupPic'] = "<a href=\"http://www.hairtell.com/ubbthreads/premium.php\"><img src=\"http://www.hairtell.com/forum/images/subscriber02.jpg\" border=\"0\"></a>";
}
And then in showflat.tpl after this (around line 101): {$postrow[post].Title}
<br />
I added this: <!-- callie hack -->
{$postrow[post].GroupPic}
<br />
<!-- end callie hack -->
But it doesn't work because the groups arent in a string separated by "-", like in the 6.5 database. They are a sequence, inside ubbt_USER_GROUPS. When I ran this, it didn't seem to do anything, so I uncommented the line in showflat.inc.php: and what happened is, it printed the user's post once for each group they belonged to... so that if they belonged to 3, 5 and 7 it printed: UserGuy Hey this is my post! 3 UserGuy Hey this is my post! 5 UserGuy Hey this is my post! 7 So I'm kinda at a stopping point. Any suggestions from you smarties out there? =) Thx, Callie
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#312728 - 01/16/07 04:51 PM
Re: Checking user group for group icons in showflat
[Re: Calpy]
|
Power User
Registered: 12/17/02
Posts: 71
|
|
|
Top
|
|
|
|
 |
 |
 |
 |
 |
 |
 |
 |
#312733 - 01/17/07 03:09 AM
Re: Checking user group for group icons in showfla
[Re: AllenAyres]
|
Power User
Registered: 12/17/02
Posts: 71
|
Thanks, Allen! I have the if/then statements up there in the code I posted, but I did try removing the minus signs from them (/6/ vs /-6-/), and I added $GroupId to the end of showflat.inc.php around line 685: list ($Number,$Username,$Posted,$IP,$Subject,$Body,$Approved,$Picture,$Title,$Color,$Icon,$Poll,$Files,$ParentPost,$PostStatus,$Signature,$LastEdit,$LastEditBy,$Location,$TotalPosts,$Registered,$stars,$picwidth,$picheight,$usernum,$ParentUser,$bday,$showbday,$addsig,$accept_pm,$homepage,$GroupId) = $dbh -> fetch_array($sth);
It actually does what I need, except that it prints a whole post for each group the person belongs to... as an admin, I belong to 4 groups, so I see four of the same post one after another, with the group ID# under my membername if I uncomment the test line I have in the first post. So any idea how to make it not print the person's post multiple times if a person belong to multiple groups? I've attached a screencap to illustrate. You can see that it printed three copies of the post since I belong to three groups, with the group icon added to the iteration where it read that group number:
|
|
Top
|
|
|
|
 |
 |
 |
 |
|
|