I am developing a app and I am new to cake and somewhat new to php. Here
is what I have . Multiple admins each with admin control over their schools
(groups). When the admin goes to admin/templates/index they only should see
templates that belongTo that school. below is how I do this. All seems well.
The problem is when models do not directly belong to school. Ex: "Room"
belongs to "School", "Program" belongs to "Room", "class" belongs to
"program", "schedule" belongs to "class". so if admin (school #1) goes to
admin/schedules/index how do I alter the query to display only classes with
extended model association to school #1 .
here is what I am doing: in appcontroller, beforeFilter I read the session
data:
$user_group_id = $this->Session->read('Userinfo.group_id');
$session_school_id = $this->Session->read('Userinfo.currentSchoolid');
if ($user_group_id == 1) {
// make currentAdminSchoolId available to all models
$this->{$this->modelClass}->currentAdminSchoolId = $session_school_id;
}
then in the template model I alter $queryData to reflect school_id:
function beforeFind($queryData) {
//debug ($this->Session->read('Userinfo.school_id'));
$queryData['conditions'] = array('school_id =
'.$this->currentAdminSchoolId);
return $queryData;
}
Thanks
Robert
--
View this message in context: http://cakephp.1045679.n5.nabble.com/how-would-YOU-do-this-admin-groups-tp4369031p4369031.html
Sent from the CakePHP mailing list archive at Nabble.com.
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment