Previous Thread
Next Thread
Print Thread
Hop To
Joined: Jun 2006
Posts: 162
M
enthusiast
enthusiast
M Offline
Joined: Jun 2006
Posts: 162
I have got several custom user groups which I need to check the access to some custom pages. As far as I have seen, there's no built in function or variable to check which groups a user belongs to.
Is it right that I have to query the USER_GROUPS table directly each time, to check if one user is in a certain group? Or is there another way? Just to be sure.


##eek##
Joined: Jun 2006
Posts: 16,301
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,301
Likes: 116
Sure there is, second tab on the view user screen from member management.


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Jun 2006
Posts: 162
M
enthusiast
enthusiast
M Offline
Joined: Jun 2006
Posts: 162
Well, I meant from the programming point of view...


##eek##
Joined: Jun 2006
Posts: 16,301
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,301
Likes: 116
Well, the mysql table forums_USER_GROUPS holds what groups what users belong to; so you'd have to craft something for a custom page.


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Sep 2004
Posts: 12
C
stranger
stranger
C Offline
Joined: Sep 2004
Posts: 12
I'm facing this question, too, after updating from 6.5. I had several mods in place that did things on the showflat and showthreaded based on a user's groups, such as custom group icons and so on. In 6.5 I used this kind of code:
PHP Code
// Figure out what to display based on their groups
	if (preg_match("/-5-/",$postergroup))  { // 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/ubbthreads/images/subscriber01.jpg\" border=\"0\"></a>";
	} 
But I hardly know where to begin in the new 7 code. Any thoughts or starters?
Are there any pages in particular that load a user's group and display something based on it, so that I can examine that code?
Thank you!

Joined: Sep 2004
Posts: 12
C
stranger
stranger
C Offline
Joined: Sep 2004
Posts: 12
Ok, here's where I am so far, getting the custom group icons under a user's name in showflat (I never use showthreaded). Any help is appreciated! =)

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}

 
I added this:
PHP Code
<!-- callie hack -->
{$postrow[post].GroupPic}


<!-- 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


Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Test
by Phun - 05/28/2024 7:31 PM
Version 7.7.5 Images suddenly not displaying
by Stovebolt - 05/04/2024 11:19 AM
Do I need to rebuild my database?
by Baldeagle - 04/07/2024 2:58 AM
Who's Online Now
0 members (), 342 guests, and 143 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)