Hello,

I am learning to trace through my code to debug results that I don't
understand.
I have the following setup (in part):
(And apologies for running on in my attempt to describe the
situation.)

in app_controller.php:
        var $uses = array('User');
        var $components = array('Acl', 'Auth', 'Session');

        function beforeFilter() {
                // Configure AuthComponent
                $this->Auth->autoRedirect = false;
                $this->Auth->authorize = 'actions';
                $this->Auth->loginAction = array('controller' => 'users', 
'action'
=> 'login');
                $this->Auth->allowedActions = array('display', 'login', 
'logout');

                // Remember user who is logged in
                $activeUser = $this->User->find(array($this->Auth->user('id')));
                $this->set('activeUser', $activeUser);
        } // end beforeFilter()
        . . .

in users_controller.php:
        function login() {
                if( $this->Auth->user() ) {
                        $this->redirect( array('controller' => 'pages', 
'action' =>
'start') );
                }
        } // end login()
        . . .

I have introductory content in home.ctp with a link to login.ctp which
on success redirects to start.ctp. This 'start' page is where I am
trying to setup different menus depending on the users access
privileges.

In start.ctp:
        // Debugging info begin
        $oldDebug = Configure::read('debug');
        Configure::write('debug', 3);
        Debugger::dump(isset($activeUser));
        Debugger::dump($activeUser);
        Debugger::dump($activeUser['User']);
        Debugger::dump($activeUser['Group']);
        Configure::write('debug', $oldDebug);
        // Debugging info end

        if(isset($activeUser)) {
                switch ($activeUser['Group']['id']):
                    case 1: // user is in administrator group
                        echo $this->element('adm_menu');
                        break;
                    case 2: // moderator group
                        echo $this->element('mod_menu');
                        break;
                    case 3: // user group
                        echo $this->element('usr_menu');
                        break;
                    default: // guest group
                        echo $this->element('gst_menu');
                endswitch;
        }
        . . .

The dump calls output:
        Debugger::dump(isset($activeUser));
                true

        Debugger::dump($activeUser);
                array(
                        "User" => array(),
                        "Group" => array()
                )

        Debugger::dump($activeUser['User']);
                array(
                        "id" => "1",
                        "username" => "xxx",
                        "first" => "xxx",
                        "last" => "xxx",
                        "password" => "xxx",
                        "group_id" => "1",
                        "created" => "2009-08-27 14:51:52",
                        "modified" => "2009-08-27 14:51:52"
                )

        Debugger::dump($activeUser['Group']);
                array(
                        "id" => "1",
                        "name" => "Administrator",
                        "created" => "2009-08-27 14:50:33",
                        "modified" => "2009-08-27 14:50:33"
                )


All acceptable, however my question is: How can I dump the full
contents of $activeUser with sub components in a way that I do not
have to call the 'User' and 'Group' arrays separately? Or extended to
work on a variable where I don't have to know it's full structure.

Many thanx in advance, McS

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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