|
Joined: Jun 2006
Posts: 162
enthusiast
|
enthusiast
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.
####
|
|
|
|
Joined: Jun 2006
Posts: 16,301 Likes: 116
|
Joined: Jun 2006
Posts: 16,301 Likes: 116 |
Sure there is, second tab on the view user screen from member management.
|
|
|
|
Joined: Jun 2006
Posts: 162
enthusiast
|
enthusiast
Joined: Jun 2006
Posts: 162 |
Well, I meant from the programming point of view...
####
|
|
|
|
Joined: Jun 2006
Posts: 16,301 Likes: 116
|
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.
|
|
|
|
Joined: Sep 2004
Posts: 12
stranger
|
stranger
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: if (preg_match("/-5-/",$postergroup)) { $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
stranger
|
stranger
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): $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): I added this: <!-- 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: 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
|
|
|
Test
by Phun - 05/28/2024 7:31 PM
|
|
|
|
0 members (),
342
guests, and
143
robots. |
Key:
Admin,
Global Mod,
Mod
|
|
|
|