Yii Framework Forum: Get All Authitems - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Get All Authitems Rate Topic: -----

#1 User is offline   Kostas Apazidis (KonApaz) 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,369
  • Joined: 21-February 11
  • Location:Greece

Posted 21 August 2013 - 08:06 AM

Hi

Is there a simple to get an array of roles from Yii::app()->authManager ?
something like that Yii::app()->authManager->getAllRoles() (not from specific user)

or I have to fetch all data by sql query ?
I create administrator panel and I want the admin to assign roles to other members

An way is

$connection=Yii::app()->db; 
$command=$connection->createCommand("select name from authitem where type=2");
$dataReader=$command->queryAll();


I don't want third part - extensions

Thanks
Yii is the best php framework in the world!
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

#2 User is offline   Ronald van Belzen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 157
  • Joined: 04-July 13
  • Location:The Netherlands

Posted 21 August 2013 - 08:20 AM

View PostKonApaz, on 21 August 2013 - 08:06 AM, said:

Hi

Is there a simple to get an array of roles from Yii::app()->authManager ?
something like that Yii::app()->authManager->getAllRoles() (not from specific user)

or I have to fetch all data by sql query ?
I create administrator panel and I want the admin to assign roles to other members

An way is

$connection=Yii::app()->db; 
$command=$connection->createCommand("select name from authitem where type=2");
$dataReader=$command->queryAll();


I don't want third part - extensions

Thanks

Why not use Yii::app()->authManager->getRoles() ?
1

#3 User is offline   Kostas Apazidis (KonApaz) 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,369
  • Joined: 21-February 11
  • Location:Greece

Posted 21 August 2013 - 08:36 AM

View PostRonald_, on 21 August 2013 - 08:20 AM, said:

Why not use Yii::app()->authManager->getRoles() ?


I really forgot that!
Also I think that Yii::app()->authManager->getRoles
requires the user id but this is optional!
(like Yii::app()->authManager->getRoles(Yii::app()->user->id) )

 $roles = Yii::app()->authManager->getRoles();
          $list=array();
          foreach ($roles as $key=>$val) {
             $list[] = $key;
          }


thanks Ronald! :)
Yii is the best php framework in the world!
It is also powerful and flexible for large scale websites
find our demo Yii extension on www.webkit.gr
Is it post useful? please v++ ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users