Forums

CC V4 show record of a particula group of user

jonnyblog1976 11 Feb, 2013
Hi,
hello,
I have a problem with a ChronoConnectivity connection.My joomla have 10 user groups and each group contains 5 users. I made a form to enter requests. later that user should see only the demands of his group. I created the connection and everything works fine, except that everyone sees everything. how can I make sure to show each user only requests related to his group?
GreyHead 11 Feb, 2013
Hi jonnyblog1976,

You'll need to add some code in the WHERE box to check the current user's group and filter the results to match.

Bob
jonnyblog1976 11 Feb, 2013
Hi Bob thank you,
how do i get the group of the active user?
using JFactory::getUser()?
GreyHead 11 Feb, 2013
Hi jonnyblog1976,

In Joomla! 1.5 that will do it because the user can only belong to one group and $user->gid will give it to you.

Joomla! 1.6+ is more complex because the user can belong to many groups. I think this is the right code:
<?php
$user =& JFactory::getUser();
$user_groups = $user->getAuthorisedGroups();
?>
This will return an array of groups though so you still need to check if the group you are interested in is in the array:
<?php
if ( in_array( 'some_group', $user_groups ) ) {
  // do something
}
?>

Bob
jonnyblog1976 11 Feb, 2013
Hi Bob thank you for your help.
Jonny
jonnyblog1976 11 Feb, 2013
hi Bob
from which joomla table getAuthorisedGroups() take the data?
and how to see this data: <?php echo $user_groups->id; ?> ?
every user have only one group
GreyHead 11 Feb, 2013
Hi Jonny,

I think that the tables are #_users, #_groups and an ACL map table that links the two - but you'd need to dig into the Joomla! code or docs to be sure.

Even if the user only belongs to one group the result you get will still be an array - with just one entry.

Bob
This topic is locked and no more replies can be posted.