Wednesday, September 26, 2012

Re: function beforeFilter

and this is my User helper user.php 

<?php
class UserHelper extends SessionHelper
{
  var $user = null;
  var $uses = array('GroupFavorite');
  
  function UserHelper()
  {
    $this->user = $this->read('user');
  }
  
  function is_user()
  {
    return isset($this->user);
  }
  
  function is_admin()
  {
    return $this->is_user() && array_key_exists('rank', $this->user) && $this->user['rank'] == array_search('admin', Configure::read('User.ranks'));
  }
  

On Wednesday, September 26, 2012 5:18:52 AM UTC-7, Jeremy Burns wrote:
Why not describe your problem?

Jeremy Burns
Class Outfit

http://www.classoutfit.com

On 26 Sep 2012, at 13:10:17, Chris <chri...@yahoo.com> wrote:

function beforeFilter working on a 1.2,... trying to migrate whole script to 1.3,... 
having problem,... what can be wrong,... ??? please help,... thanks 

  
  function beforeFilter()
  {
    if($this->Session->check('user'))
      $this->user = $this->Session->read('user');
    
    if(!$this->is_user())
    {
      $username = $this->Cookie->read('User.username');
      $hashed_password = $this->Cookie->read('User.hashed_password');
      
      if($username && $hashed_password)
      {
        if(!class_exists('User'))
          loadModel('user');
          
        $User = new User();
        
        if($user = $User->findByUsernameAndHashedPassword($username, $hashed_password))
        {
          $this->Session->write('user', array('id' => $user['User']['id'], 'username' => $user['User']['username'], 'rank' => $user['User']['rank'], 'gender' => $user['User']['gender'], 'firstname' => $user['User']['firstname'], 'lastname' => $user['User']['lastname']));
          $this->set_language($user['User']['language']);
          if($this->Session->check('user'))
            $this->user = $this->Session->read('user');
        }
      }
    }
    



--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake...@googlegroups.com.
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
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 cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: