tanya user level access

tolong bantuannya ane mw buat user level access

saya buat sebuah file dengan nama “EWebUser.php” di /protected/components

<?php

class EWebUser extends CWebUser {

protected &#036;_model;





protected function loadUser() {


    if (&#036;this-&gt;_model === null) {


        &#036;this-&gt;_model = User::model()-&gt;findByPk(&#036;this-&gt;id);


    }


    return &#036;this-&gt;_model;


}





function getLevel() {


    &#036;user = &#036;this-&gt;loadUser();


    if (&#036;user)


        return &#036;user-&gt;level_id;


    return 100;


}

}

terus di /config/main.php sya tambahkan

‘components’ => array(

    'user' =&gt; array(


        // There you go, use our 'extended' version


        'class' =&gt; 'application.components.EWebUser',


        // enable cookie-based authentication


        'allowAutoLogin' =&gt; true,


    ),

dan di user controller sya tulis sbb

public function accessRules() {

    return array(


        array('allow',


            'actions' =&gt; array('create', 'captcha'),


            'users' =&gt; array('*'),


        ),


        array('allow',


            'actions' =&gt; array('update', 'view'),


            'users' =&gt; array('@'),


        ),


        array('allow',


            'actions' =&gt; array('admin', 'index', 'delete'),


            'expression' =&gt; '&#036;user-&gt;getLevel()&lt;=1',


        ),


        array('deny',


            'users' =&gt; array('*'),


        ),


    );


}

tapi muncul error seperti ini

Alias "application.components.EWebUser" is invalid. Make sure it points to an existing PHP file.

tolong bantuannya gan…

mungkin coba kayak gini gan…!





<?php 


class EWebUser extends CWebUser 

{

	// deklarasi awal dulu harus null

	protected $_model=null;

	

	protected function loadUser($id) 

	{

		if ($this->_model === null)

			$this->_model = User::model()->findByPk($id);

		return $this->_model;

	}


	public static function getLevel($id) 

	{

		$level=0;

		$user = $this->loadUser($id);

		if ($user!==null)

			$level=$use->level_id;

		return $level;

	}


}



Bagaimana caranya bgitu login dia bisa di redirect ke controll yg telah kita buat?

di site controller kan sudah ada gan… ini cuplikan kodenya





/**

	 * Displays the login page

	 */

	public function actionLogin()

	{

		$model=new LoginForm;


		// if it is ajax validation request

		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')

		{

			echo CActiveForm::validate($model);

			Yii::app()->end();

		}


		// collect user input data

		if(isset($_POST['LoginForm']))

		{

			$model->attributes=$_POST['LoginForm'];

			// validate user input and redirect to the previous page if valid

			if($model->validate() && $model->login())

			// redirect saat login berhasil

				$this->redirect(Yii::app()->user->returnUrl);

		}

		// display the login form

		$this->render('login',array('model'=>$model));

	}