⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Restrict default records list...need help..



Wong Erynnyes
  • profile picture
  • Member

Posted 30 June 2013 - 13:09 PM

Hi all, first thanks to this Awesome plugin, life become way more easier!!

 

My questions is very straight forward: I got 2 tables, one is teachers, the other one is students. teacher can log in and CRUD students. But after i log in, i just wanna see the students that created by that specific teacher, not all students.. I got a field called teacher_id in students table, so everytime after teacher login, i wanna do sth like

"SELECT *

  FROM students

  WHERE teacher_id = 6"

Assume 6 is the id of the teacher in teachers' table..So in this case i can see students created by me instead of all students...Because Now after i added a new student, i got a list showing all the students..... Any help would be much appreciated!!!


Wong Erynnyes
  • profile picture
  • Member

Posted 30 June 2013 - 17:52 PM

I was so dumb... should have read all the API functions... simply put $crud->where('staff_id','6'); done..


Robert
  • profile picture
  • Member

Posted 01 July 2013 - 13:21 PM

Hi im trying to make the same think, are you using ion auth by any chance. I have made :

if ($this->ion_auth->is_admin())

{
 $crud->where('xxxx','3');
}
elseif ($this->ion_auth->is_agent())
{
 $crud->where('xxxxx','2');
}

 

If anyone here uses ion auth on there CI and know how can i set  if ($this->ion_auth->is_admin()) to be on username or id not the group so i can sort the table depending on login member it will be great.


davidoster
  • profile picture
  • Member

Posted 02 July 2013 - 08:57 AM

 

 

If anyone here uses ion auth on there CI and know how can i set  if ($this->ion_auth->is_admin()) to be on username or id not the group so i can sort the table depending on login member it will be great.

 

Check your messages.