Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Limit / Filter based on Joomla User. 22 Oct 2012 05:00 #4689

HI,

I have a 3 level deep structure

Franchisers <-> Joomla User
Klanten
UIzendkrachten

I want the Franchiser to login with his Joomla user account.

The Administrator creates the Franchisers at the backend and links them to a Joomla user
The Franchiser at the front-end can create Klanten & Uizendkrachten (only under his franchiser account)

The Franchiser should see only the Klanten & Uitzendkrachten that are linked to it's own Franchiser account.
How can I accomplish this the best way?
Now the Franchiser can see ALL Klanten & Uitzendkrachten, so somewhere I should apply the filter automatically based on his Franchiser ID.

Any suggestions? Please let me know :-)



Please Log in or Create an account to join the conversation.

Re: Limit / Filter based on Joomla User. 22 Oct 2012 07:32 #4690

Solved it!

In model klanten.php just before the //WHERE - FILTER : Franchiser ID
// cobiz Set Franchise Filter to current user
$user =& JFactory::getUser();
$db = JFactory::getDBO();
$myquery = "SELECT id FROM #__franchisers WHERE joomla_user='".$user->id."'";
$db->setQuery($myquery);
$this->setState('filter.franchiser_id', $db->loadResult());

And in model klant.php just before the first function in the class
public function save($data)
{
	// cobiz Set Franchise ID to current user
	$user =& JFactory::getUser();
	$db = JFactory::getDBO();
	$myquery = "SELECT id FROM #__franchisers WHERE joomla_user='".$user->id."'";
	$db->setQuery($myquery);
	$data['franchiser_id']=$db->loadResult();		
	parent::save($data);
	return true;
}
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

Last edit: by goslingcools.

Re: Limit / Filter based on Joomla User. 24 Oct 2012 07:59 #4710

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Cool, thank you for sharing.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: Limit / Filter based on Joomla User. 27 Oct 2012 22:14 #4783

gosslingcools

I am trying to do a similar idea for weeks now but only 1 level deep and it is for quite a different type a business. My problem is that no matter what I do, they see every user....noy just the onea they sponsor or create.

I am a beginner at programming but quite advanced with working in Joomla and have tried everything from working with my ACLs to trying different foreign key configurations. Nothing seems to work. Could you give me a little more detailed break down of what you did.
whispiri

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.061 seconds
In the begining i would like to say that j-cook is absolutly fantastic tool! And the person who created it is a genius.
Czyżak (Forum)  

Get Started