how to relate the prefilter condition of a list with te login user

radvla

Member
1?)I have defined a list . I have to set up a prefilter condition.

2?) One of the field of the list it is the client name. In joomla I have set up a user group called clients

3?) To access to the web , each client have a username="xxxx" and a passwor="yyyyy".

4?) The prefiltercondition I want to set up it is the value of the field client equals the value of the joomla username, so us different joomlausers will see only the resgister that belong to them as clients.

5?) ?How can i defined the condition

Where=client EQUALS Value= "???????" Applied to ="CLIENTS" that i must specified in the list filtering chapter "prefilter"

I need urgent help
 
Joomla userid and username (better is to use userid) of the logged in user can be accessed with {$my->id} and {$my->username}.
If you want to pick the group you must do it by yourself (a user can belong to mutiple groups), you can use a (sub)query or php code in the prefilter "value" field (set Type = Query or Eval)

And don't mix up usergroups with access levels ("Applied to" is an access level)
 
- What I need it is to stablished the condition filter as a condition between

variable=variable and not variable=concrete value so as the same condition take account of all the situation

-If i choose to set up in the value field set Type = query

which would be the SQL PHP sentence to say valued of the field "client" equals value of the joomla userid?

I need urgent asistance
 
One thing that I don't clearly understand is when you say:

so us different joomlausers will see only the resgister that belong to them as clients

Does that mean you want to restrict each user to seeing only other users row's that belong to the same group(s) as them?

In other words, how are you defining "belongs to"?

-- hugh
 
I want to let each user to see only the registers of any user of his group, and restrict him for seeing other group register
 
this is not that easy as users can belong to more than one group. Here's a screen shot of what i found to work:

http://screencast.com/t/UzOd3vlBt

Please note that the element should be the element that contains the logged in user's id.
below is the code you will need to copy in:

Code:
$user = JFactory::getUser();
$groups = $user->getAuthorisedGroups();
JArrayHelper::toInteger($groups);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('user_id')->from('#__user_usergroup_map')->where('group_id IN (' . implode(',', $groups) . ')');
$db->setQuery($query);
$userid = $db->loadColumn();
$userid = array_map(array($db, 'quote'), $userid);
return implode(',', $userid);
 
I have a similar question, I have a simple dropdown element and it has each users name in it. I control the user's names, I want to make a prefilter pull up only the logged in users name for the table (er... list?). Can I get some help for this one?
 
you would need to use a database join element and not a dropdown.

You would then use the following settings:

table: #_session (# will be replaced with your Joomla installs database prefix)
value: userid
label: username

If you wanted to limit to those users logged into the front end you would add this:

Joins where and/or order by statement (SQL): where client_id = 0

However, please be aware that if you do this then editing records can become highly problematic as if the previously selected user is not logged in when you edit the record, his entry will not appear in the list and will be erased from the record when the form is submitted.
 
I see... so I guess in order to avoid the issues with this I should just make a copy of the list for each user and then I can prefilter off the dropdown? they can then use the list which is assoiciated to their name
 
Is there any reason you can't use a 'user' element, which (among other things) was designed to do exactly what I think you are asking, which is to filter lists according to the logged on user?

-- hugh
 
Does the dropdown really have to be ONLY of those users currently logged in?
As Hugh said you can filter a list per user, but what I read was that you wanted a dropdown list in a form with only the currently logged in users showing
 
Back
Top