Welcome, Guest
Username: Password: Remember me

TOPIC: Limit / Filter based on Joomla User.

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

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
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 :-)



The administrator has disabled public write access.

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

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
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;
}
Last Edit: 22 Oct 2012 07:44 by goslingcools.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

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

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Cool, thank you for sharing.
Coding is now a piece of cake
The administrator has disabled public write access.

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

  • whispiri
  • whispiri's Avatar
  • Offline
  • Junior Member
  • Posts: 32
  • Thank you received: 1
  • Karma: -3
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
The administrator has disabled public write access.
Time to create page: 0.096 seconds

Get Started