Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Dec 2002
Posts: 67
Power User
Power User
Joined: Dec 2002
Posts: 67
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):
PHP Code
// Cycle through the posts
$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:
PHP Code
 // Cycle through the posts
$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):
PHP Code
$postrow[$i]['UserStatus'] = ""; 
I added this:
PHP Code
// Callie Hack
$postrow[$i]['GroupId'] = "";
// end Callie Hack
and then BEFORE this (around line 923):
PHP Code
// ---------------------
// Is it their birthday?

I added this:
PHP Code
// callie hack group pic
// Figure out what to display based on their groups
if (preg_match("/-5-/",$GroupId)) { // adjust this group number if needed
$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)) { // adjust this group number if needed
$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>";
}
// test it $postrow[$i]['GroupPic'] =$GroupId;
// end callie hack group pic

And then in showflat.tpl after this (around line 101):
PHP Code
{$postrow[post].Title}
<
br />
I added this:
PHP Code
<!-- 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:
PHP Code
// test it $postrow[$i]['GroupPic'] =$GroupId; 
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

Sponsored Links
Joined: Dec 2002
Posts: 67
Power User
Power User
Joined: Dec 2002
Posts: 67
Any thoughts? Anyone? =)

Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
You could probably do an if/then statement in the template, eh? You are already querying for the usergroup in the base code, why not an if/then in showflat.tpl to show the image/link if the usergroup is the one you want?


- Allen wavey
- What Drives You?
Joined: Dec 2002
Posts: 67
Power User
Power User
Joined: Dec 2002
Posts: 67
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:
PHP Code
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:
[Linked Image]

Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
dumb question here on my part, if you use an elseif statement for the second if would it still call the data from the second if statement since the first was already matched? Perhaps include halt; after the first if and set the second if to elseif and give it a try?


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Sponsored Links
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
I know with .classic we could put html in the user title field so we'd do something like:

user_title
user_title

easy squeezy smile


- Allen wavey
- What Drives You?
Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
yeh but you can't visually check who has that title with a minimal ammount of clicks...


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Joined: Mar 2000
Posts: 21,079
Likes: 3
I type Like navaho
I type Like navaho
Joined: Mar 2000
Posts: 21,079
Likes: 3
We set it per usergroup - everyone in that group got the same icon smile Maybe that was threads 6 :shrug:


- Allen wavey
- What Drives You?
Joined: Dec 2002
Posts: 67
Power User
Power User
Joined: Dec 2002
Posts: 67
Yes, it was much easier for this particular thing in UBB6.5 because user groups was all in a single db entry, and you just parsed out the particular group you were looking for.

I actually need it to read through all the groups a member belongs to, if possible, and not just stop at the first one, because everyone belongs to the group "users", and lots belong to "users" and "mod" or other combinations. So if they belong to a donation group ("angels" on my board) it would need to cycle thru all the group entries for that user ID and assign the grouppic info if *any* of their groups was "group 7" or whatever.

I appreciate y'all looking at what I've done so far and giving this advice! =)

Joined: Jan 2000
Posts: 5,833
Likes: 20
UBBDev / UBBWiki Owner
Time Lord
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,833
Likes: 20
Originally Posted by AllenAyres
We set it per usergroup - everyone in that group got the same icon smile Maybe that was threads 6 :shrug:
:shrug: too much change? lol...



UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
A join in the query won't work in this case, (as the example you posted) as there will be multiple entries in the USER_GROUPS table. So you can only join to one of them. So this won't be possible using the same query. It'll only join to one row in the USER_GROUPS table, probably the first entry. But the users will have an entry in this table for each usergroup they belong to.

You'd either need
a) To do an additional query per post to the USER_GROUP table to grab all the groups that the user belongs to. (That'll add alot of queries - NOT RECOMMENDED)

b) Or you'll need to devise a method to store the image that needs to be displayed in the USER_PROFILE table, so you can grab the image with the rest of the profile info and display it using the same query.

c) You could probably grab all the contents of the USER_GROUP table and store them in an array, then compare against this when you display each post, see if the user is in the group. This would be just one additional query on the page. But if you have alot of users or alot of groups, the array could be sizeable and hog up alot of memory.

I've seen other software products which are structured exactly like the new UBBThreads, and option b is really the way you'd have to go.

Joined: Dec 2002
Posts: 67
Power User
Power User
Joined: Dec 2002
Posts: 67
*Sigh* Thanks, Joshua. It was so simple before, I don't understand why user groups is separated off into not only a separate thing, but into multiple entries now. Off to work...

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Well, the old way was inefficient as you were limited by field size, in theory now, there would be no limit to the number of groups.

Joined: Oct 2006
Posts: 7
Lurker
Lurker
Offline
Joined: Oct 2006
Posts: 7
This mod was awesome on 6 and was really hoping to see it come back on 7 for my supporting members... I wish i could help with this but its way over my head smile

Just my .02 thanks.

Joined: Dec 2002
Posts: 67
Power User
Power User
Joined: Dec 2002
Posts: 67
* Just bumping this. I'm dying to be able to reimpliment this on my board.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)