"User has been authorized" cannot be viewed in the srbac extension of Yii

Source: Internet
Author: User

Yii Srbac extension in the "User has been authorized" point drop-down box, when you select a user who has permissions, you cannot list permissions at all.

The reason is that srbac the ID in the database table to the number, like 123, but if it's not a number like ' y0f22ffc2fef712fd602a1ef64ab319t '. Then this is not going to come out, then you can only modify the code.

Modify the Actionshowassignments method in the \protected\modules\srbac\controllers\authitemcontroller.php file

The source code is as follows

   Public functionactionshowassignments () {$userid=isset($_get["id"]) ?$_get["id"]:$_post[Helper::findmodule (' Srbac ')->userclass] [$this->module->UserID]; $user=$this->module->getusermodel ()->FINDBYPK ($userid); $username=$user->{$this->module->username}; $r=Array(0 =Array(0 =Array())); if($userid> 0) {      $auth= Yii::app ()AuthManager; /*@var $auth Cdbauthmanager*/      $ass=$auth->getauthitems (2,$userid); $r=Array(); foreach($ass  as $i=$role) {        $curRole=$role-name; $r[$i] =$curRole; $children=$auth->getitemchildren ($curRole); $r[$i] =Array(); foreach($children  as $j=$task) {          $curTask=$task-name; $r[$i][$j] =$curTask; $grandchildren=$auth->getitemchildren ($curTask); $r[$i][$j] =Array(); foreach($grandchildren  as $k=$oper) {            $curOper=$oper-name; $r[$i][$j][$k] =$curOper; }        }      }      //Add always allowed Opers      $r["Alwaysallowed"] [""] =$this->module->getalwaysallowed (); $this->renderpartial (' userassignments ',Array(' Data ' =$r, ' username ' =$username)); }  }

We modify the 7th line of the judgment statement under if ($userid > 0)

Modify the If (count ($user) > 0), and the modified code is as follows

   Public functionactionshowassignments () {$userid=isset($_get["id"]) ?$_get["id"]:$_post[Helper::findmodule (' Srbac ')->userclass] [$this->module->UserID]; $user=$this->module->getusermodel ()->FINDBYPK ($userid); $username=$user->{$this->module->username}; $r=Array(0 =Array(0 =Array())); if(Count($user) > 0) {      $auth= Yii::app ()AuthManager; /*@var $auth Cdbauthmanager*/      $ass=$auth->getauthitems (2,$userid); $r=Array(); foreach($ass  as $i=$role) {        $curRole=$role-name; $r[$i] =$curRole; $children=$auth->getitemchildren ($curRole); $r[$i] =Array(); foreach($children  as $j=$task) {          $curTask=$task-name; $r[$i][$j] =$curTask; $grandchildren=$auth->getitemchildren ($curTask); $r[$i][$j] =Array(); foreach($grandchildren  as $k=$oper) {            $curOper=$oper-name; $r[$i][$j][$k] =$curOper; }        }      }      //Add always allowed Opers      $r["Alwaysallowed"] [""] =$this->module->getalwaysallowed (); $this->renderpartial (' userassignments ',Array(' Data ' =$r, ' username ' =$username)); }  }

You can see the effect after the change, the effect is as follows

If you do not understand why, you can analyze the source code.

The user has been authorized in the SRBAC extension of Yii cannot be viewed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.