checkAccess problems

Hi, I’m having troubles with Yii::app()->user->checkAccess() when I am parsing user id as the second parameter.

It still checks if the current user I am logged in as is allowed to access the action…

Using the latest 1.1.6 in svn.

That’s pretty much what it does. :)

Yii::app()->user-> is the current user.

ok, so how do I check for a whatever user? (=

also, is there a way to check if user is currently online?

checkAccess() checks if the current user has access to the operation that need to be run…

Maybe if you explain what is your need… .why you want to check for another user and what you want to do with the result?

That’s a good question. :)

You use theAuthManager->checkAccess(item, user_id) instead.

If Yii::app()->user->id is set, then the user is logged in.

What I am trying to do is check if this comment belongs to administrator, if so, then I need to add different css classes to this comment.

And about the checking if user is online - what I meant is is there any way to check if some user is online? ))

If the current user is not a guest:


if(!Yii::app()->user->isGuest)

thanks for the tips :)

If you want to extend CWebUser, do that. :)

Look at the source for it.

You can add an isAdmin function to it.


class WebUser extends CWebUser

Then set the user to that in your app config:


    	'user' => array(

        	'class' => 'application.components.WebUser',



And then:


	/**

	 * @return boolean whether the current application user is an admin.

	 */

	public function getIsAdmin()

	{

		return $this->getState('__admin')===null;

	}



Then, of course, you need to set the state to __admin when your admin logs in. :)

Then you can:


if(Yii::app()->user->isAdmin) do admin stuff