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

Although I found this tool some time ago I just started learning experimenting and building this first component on Monday and now on Thursday afternoon it's already online. Although I already had a working version done with another tool this is much easier to build and at the end you have the freedom to own your own component. Once you know how to use Cook you will boost your productivity as the learning curve is really moderate compared to many other tools.
Giori (Forum)

Get Started