Login certain user

Hi! I have asked this question already but obviously in wrong forum so the post was deleted! I’ll try with my own topic then because i really can’t find the solution anywhere.

In my database table, i have professors and students with attribute TYPE (P and S). I want to allow only Professors to be able to login. How could i do that? I tried with access rules:

public function accessRules() {

        return array(


            array('allow',


                'actions'=>array('login'),


                'users'=> array(LOGIN::model()->findByAttributes(array('TYPE' => array('P')))


                


             )


                )


        );

but this gives me an error:

strtolower() expects parameter 1 to be string, object given.

I’m not even sure if this is what i should be doing, i’m very very new to all this. Help is appreciated!

Thanks

[size=2]This is really similar to this problem: http://www.yiiframework.com/forum/index.php/topic/63760-how-to-create-a-login-with-user-and-admin-role/[/size]

Hello,

you use access rule like Following Code of Controller.

class TestController extends Controller {

public $layout = '//layouts/layout';





public function actions() {





    return array(


        'add' => 'controllers.test.Add',


        'edit' => 'controllers.test.Edit',


        'view' => 'controllers.test.View',


        'delete' => 'controllers.test.Delete',


    );


}


public function filters()


{


	return array( 'accessControl' ); // perform access control for CRUD operations


}





public function accessRules()


{


	return array(


		array('allow',  // allow specified  users to perform 'index','view' and other actions


		'actions'=>array('add','edit','view','delete'),				


                    'roles'=>array('admin'),


		),


	


		array('deny',  // deny all users


		'users'=>array('*'),


		),


	);


}

}

Thanks guys, i did it like this:

$record=LOGIN::model()->findByAttributes(array(‘usrnm’=>$this->username, ‘type’=>‘P’));

and it’s working, only allowing professors to login. Later i’ll have to allow admin and one more user of type E to login, i already tried like this:

$record=LOGIN::model()->findByAttributes(array(‘usrnm’=>$this->username, ‘type’=>‘P’, ‘type’=>‘E’, ‘type’=>‘A’));

but then it only allows admin to login. i assume the ‘type’=>‘A’ overrides conditions before. How could i write this properly?

Next big question: when i certain professor is logged in, he should only see corresponding courses, those that belong to him. Any ideas on where to even start with that? Thanks :)