[EXTENSION] Rights

hello everybody,

I need to sort asignement view by username, I tried to modify AssignmentController:actionView:


		$dataProvider = new RAssignmentDataProvider(array(

            'pagination'=>array(

				'pageSize'=>50,

			),

'sort'=>array('defaultOrder'=>'username'),


		));

but It doesn’t work.

PS: also pagination doesn’t work: I view always 10 results.

someone has implemented the sorting of assignments view?

Hi sravani,

I hope you won’t mind me answering your question.

If you are using the latest version of Rights, you should replace RightsWebUser with RWebUser.

I’m sure you just didn’t had the time to explore this long thread, so let me point you to this post.

Hi,

I’m already using rights (0.9) in other 3 applications and, trying to install the 1.2 to a new one, got stuck in a 403 error. Even my Admin user gets 403 errors. My Controller extends RController, my config:


		'rights'=>array(

		   'install'=>false,	   

		   'userIdColumn'=>'idusuario',

		   'userNameColumn'=>'login',

		   'userClass'=>'CadUsuario',

		   'debug'=>true

		),

 ....

'components'=>array(

		'user'=>array(

			// enable cookie-based authentication

			'class'=>'RWebUser',

			'allowAutoLogin'=>true,

		),

...

'authManager'=>array(

			'class'=>'RDbAuthManager',

			'connectionID'=>'db',

			'defaultRoles'=>array('Guest')

		),




I have a ‘CadUsuario’ class, that control my users with md5+seed password.

The users with ‘Admin’ roles, can access successfully my rights module. I can set permissions like




public function allowedActions(){

		return 'index';

	}



But, my Admin account doesn’t have access to anywhere else.

Error example:




CHttpException


You are not authorized to perform this action. (/***/***/***/webfolder/protected/modules/rights/components/RController.php:62)


#0 /***/***/***/webfolder/protected/modules/rights/components/RightsFilter.php(57): RController->accessDenied()

#1 /***/***/***/yii/1.1.6/framework/web/filters/CFilter.php(39): RightsFilter->preFilter(Object(CFilterChain))

#2 /***/***/***/webfolder/protected/modules/rights/components/RController.php(36): CFilter->filter(Object(CFilterChain))

#3 /***/***/***/yii/1.1.6/framework/web/filters/CInlineFilter.php(59): RController->filterRights(Object(CFilterChain))

#4 /***/***/***/yii/1.1.6/framework/web/filters/CFilterChain.php(130): CInlineFilter->filter(Object(CFilterChain))

#5 /***/***/***/yii/1.1.6/framework/web/CController.php(283): CFilterChain->run()

#6 /***/***/***/yii/1.1.6/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)

#7 /***/***/***/yii/1.1.6/framework/web/CWebApplication.php(328): CController->run('error')

#8 /***/***/***/yii/1.1.6/framework/base/CErrorHandler.php(279): CWebApplication->runController('site/error')

#9 /***/***/***/yii/1.1.6/framework/base/CErrorHandler.php(178): CErrorHandler->render('error', Array)

#10 /***/***/***/yii/1.1.6/framework/base/CErrorHandler.php(103): CErrorHandler->handleException(Object(CHttpException))

#11 /***/***/***/yii/1.1.6/framework/base/CApplication.php(631): CErrorHandler->handle(Object(CExceptionEvent))

#12 [internal function]: CApplication->handleException(Object(CHttpException))

#13 {main}



Maybe, if you guys, could point me the right direction about the “isSuperuser” method in RWebUser, how it compare the users, where it is … because, my best guess, now, is that it is givin’ false where it is suposed to be true.

Sorry taking up your precious time, but, i’m really stuck here.

Sorry by the bad english.

Somehow, re-installing the module make it work. I think the error came because, in my UserIdentity I defined a new getId() method, wich returns the username, instead of the user id.

BTW, great job chris. Keep the good work. I wish someday i could help you.

Hello All,

Sorry for not replying for a while, I’ve been terribly busy at work and I still will be for a couple of weeks.

Hi, i got rights extention installed but i m getting problem while loggin in rights

i m getting this error


include(User.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory


C:\xampp\htdocs\yii\framework\YiiBase.php(396)


384      * @return boolean whether the class has been loaded successfully

385      */

386     public static function autoload($className)

387     {

388         // use include so that the error PHP file may appear

389         if(isset(self::$_coreClasses[$className]))

390             include(YII_PATH.self::$_coreClasses[$className]);

391         else if(isset(self::$classMap[$className]))

392             include(self::$classMap[$className]);

393         else

394         {

395             if(strpos($className,'\\')===false)

396                 include($className.'.php');

397             else  // class name with namespace in PHP 5.3

398             {

399                 $namespace=str_replace('\\','.',ltrim($className,'\\'));

400                 if(($path=self::getPathOfAlias($namespace))!==false)

401                     include($path.'.php');

402                 else

403                     return false;

404             }

405             return class_exists($className,false) || interface_exists($className,false);

406         }

407         return true;

408     }




please help me…

Hi sagarneo11,

It exactly means what it says: it cannot find the User.php, meaning it can’t see the User model. In case you just missed some page in this thread, here’s a trackback link.

Hello All,

Rights 1.3.0 is now released.

Download here

There aren’t that many new features but I’ve fixed most of the issues reported on Google Code.

Enjoy!

hi,

thank you macinville for suggestion… i did how u said… but i m getting a new error now…

following are the details of error


CDbException


CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause'. The SQL statement executed was: SELECT * FROM `user` `t` WHERE id=:ycp0


C:\xampp\htdocs\yii\framework\db\CDbCommand.php(518)


506             return $result;

507         }

508         catch(Exception $e)

509         {

510             if($this->_connection->enableProfiling)

511                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');

512             $errorInfo = $e instanceof PDOException ? $e->errorInfo : null;

513             $message = $e->getMessage();

514             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',

515                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');

516             if(YII_DEBUG)

517                 $message .= '. The SQL statement executed was: '.$this->getText().$par;

518             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',

519                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);

520         }

521     }

522 

523     /**

524      * Builds a SQL SELECT statement from the given query specification.

525      * @param array $query the query specification in name-value pairs. The following

526      * query options are supported: {@link select}, {@link distinct}, {@link from},

527      * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},

528      * {@link limit}, {@link offset} and {@link union}.

529      * @return string the SQL statement

530      * @since 1.1.6




Will any one will suggest me?

me too,

I think, Chris forgot to change it.

Change in rights\components\RAuthorizer.php line 294-295 :

from :




		$criteria = new CDbCriteria();

		$criteria->addInCondition('id', $userIdList);



to :




		$criteria = new CDbCriteria();

		$criteria->addInCondition(Rights::module()->userIdColumn, $userIdList);



Thanks, I was clarified where to put the ‘defaultRoles’, should be part of ‘authManager’.

Hello sbasuki,

You’re totally correct. I’ve fixed this and repacked the module, please update. I’m sorry for the inconvenience.

Thanks Chris,

No problem,

Not sure if this has been already discussed, but here it goes.

In generating permissions, maybe it would be better if there’s a filter for modules and/or controllers. In my case, I have over a hundred actions already, and generating a permission will require me to search for the particular action. Having this feature will make it more presentable, too! :)

Well, just my 2 cents. :)

Hi Chris,

I have another question for you ;-).

Is it possible to check the rights for a link in a view?

Example:

View Action with Edit Button.

I want to disable the Edit Button, if the user hasn´t the rights for

the action/link.

Is there a correct way for this, I´ve nothing found so far?

Greetings tronga

Well yes, you can simply call Yii::app()->user->checkAccess() before displaying the link.

If you have a menu you can set the visible-setting to what checkAccess returns.


<?php if(Yii::app()->user->checkAccess('Controller.edit')): ?>


//view edit button


<?php endif: ?>

if you use CMenu you can set items visible:


'visible' => user()->checkAccess('Controller.edit')

Thanks it works perfectly in both cases.

Yii is awesome :wink:

Hi, Chris

I found a bug, well, maybe it is my mistaken configuration…

I tried to add another user as a admin (which is the super user) with "admin" user, after I add it, the current

“admin” is not working anymore, I’m not sure if there’s any configuration I missed and get this failure?

for now, I can only hack your extension and remove the “admin” user from the dropdownlist for all users’ assignments for a quick fix, does this “admin” super user supposed to be like a linux “root” user, which is the only one in the system?

Thanks

zippo

Hi!

I actually have the 1.2 version and I want to update to 1.3 … so I download it and replace it 1.2 to 1.3 rights folder but when I try to login I get the 403 error


You are not authorized to perform this action.

Why?? … with the previous version I didn’t have that problem :huh:

regards