How To Set A User As Admin

this is my database

3809

Screenshot from 2013-01-31 13:10:31.png

and this is my authenticate function in UserIdentity.php


public function authenticate()

	{

		$user_email = strtolower($this->username);

		$users=Users::model()->find('LOWER(users_email)=?',array($user_email));

		

		if($users===null)

			$this->errorCode=self::ERROR_USERNAME_INVALID;

		else if(!$users->validatePassword($this->password))

			 $this->errorCode=self::ERROR_PASSWORD_INVALID;

		else

		{	if($users->users_role==1){

			$this->setState('isAdmin',1);

			$this->setState('userId',$users->users_id);

			$this->setState('name', $users->users_name);

			}	

			$this->_id=$users->users_id;

			$this->username=$users->users_name;

			$this->errorCode=self::ERROR_NONE;

		}

		return $this->errorCode==self::ERROR_NONE;

	}

How can I set the user having Role=2 is the admin. The above method is not working.

please help me

thanks

yii user + rights is the best way to solve this,

try this link

http://www.yiiframework.com/wiki/423/installing-yii-users-and-rights-to-newly-created-yii-app/

try like this

hope this helps.

try to assign like this after getting the user information by using email




            $this->_id=$user->id;

            $this->setState('lastLoginTime', $user->lastLoginTime);