> I assume that I would do this by adding some code somewhere in the
> AppController, but where and how would I call it?
>
> I don't think it would go in beforeFilter() as that would try and run
> even if a user wasn't authorised, or would I put a call in there that
> first checked if the user was logged in and then ran an action which
> would add my extra data to the session?

Well I have gone for the following which is working, but could someone
say if it is the right way to achieve what I want?

[code]
class AppController extends Controller {
  ...

  function beforeFilter() {
    if ($this->Session->check('Auth.User')) {
      $this->__AuthExtra();
    }
  }

  function __AuthExtra() {
    $authUser = $this->Session->read('Auth.User');
    App::import('Model', 'Person');
    $person = new Person;
    $data = $person->find('first', array(
      'conditions' => array('Person.user_id' => $authUser['id']),
      'fields' => array('Person.id', 'Person.title',
'Person.first_name', 'Person.middle_name', 'Person.last_name',
'Organisation.id', 'Organisation.name')
    ));
    if ($authUser['user_group_id'] == 3) {
      $data = Set::merge($data, $person->Organisation->find('first',
array(
        'conditions' => array('Organisation.id' => $data
['Organisation']['id']),
        'fields' => array('Scheme.id')
      )));
    }
    if ($authUser['user_group_id'] == 3) {
      $data = Set::merge($data, $person->Organisation->find('first',
array(
        'conditions' => array('Organisation.id' => $data
['Organisation']['id']),
        'fields' => array('Scheme.id', 'Agency.id')
      )));
    }
    $this->Session->write('AuthExtra', $data);
  }
}
[/code]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to