EWebUser.php
<?php class EWebUser extends CWebUser{ protected $_model; protected function loadUser() { if ( $this->_model === null ) { $this->_model = StaffDb::model()->findByPk($this->id); } return $this->_model; } function getLevel() { $user=$this->loadUser(); if ($user->kdstpeg == 02){ if(substr($user->kdorg,1,4) == '0000') $level=1; else if (substr($user->kdorg,2,3) == '000') $level=2; return $level; } return 100; }
UserIdentity.php
<?php /** * UserIdentity represents the data needed to identity a user. * It contains the authentication method that checks if the provided * data can identity the user. */ class UserIdentity extends CUserIdentity { private $_id; public function authenticate() { $username = strtolower($this->username); $user = MUser::model()->find('LOWER(username)=?', array($username)); if($user===null) $this->errorCode=self::ERROR_USERNAME_INVALID; else if ($user->pwd!=$this->password) $this->errorCode = self::ERROR_PASSWORD_INVALID; else { $this->_id = $user->oldStaffCode; $this->username = $user->username; $this->errorCode = self::ERROR_NONE; } return $this->errorCode == self::ERROR_NONE; } public function getId() { return $this->_id; } }
and StaffDb.php (one of my model)
public static function model($className=__CLASS__) { return parent::model($className); } /** * @return string the associated database table name */ public function tableName() { return 'staffdb'; } /** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. return array( array('oldStaffCode', 'required'), ... array('kdstpeg', 'max'=>2), array('...', 'safe'), // The following rule is used by search(). // Please remove those attributes that should not be searched. array('oldStaffCode, kdstpeg, ..., 'safe', 'on'=>'search'), ); } public function primaryKey() { return 'oldStaffCode'; }
When i'm trying to access this application, the error "Trying to get property of non-object" is shown. Then, i put this code on EWebUser.php
print_r ($user);in order to see what kind of $user's view. But it didn't have any effect.

My question is, did I miss something in that codes? Because in my opinion, all of objects are complete. I hope there's a suggestion to solve this problem. Thanks in advance.
