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.084 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started