PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
How to get the Rights linked to a specific group

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication
View previous topic :: View next topic  
Author Message
gaorellana



Joined: 28 Feb 2007
Posts: 2

PostPosted: Wed Feb 28, 2007 1:00 am    Post subject: How to get the Rights linked to a specific group Reply with quote

Hi all,

I am using LiveUser_Admin and given I didnīt found an Admin GUI for it, I am doing it by myself.

Anyway, the point is that I want to be able to display for a specified group what rights are granted. I wonder if there's a method or function to get this.
I am using the Complex permission configuration. My function look mlike this but when I get $res as below, $res returns me all rights feined instead of only those for my $group ($group->getId()) retunrs the value of 'group_id' field of liveuser_groups table).

Code:

function getRightsForGroup($group)
{
   $params=array(
         'group_id'=>$group->getId()
         );
   $res=$this->admin->getRights($params);
   $rights=array();
   for($i=0;$i<count($res);$i++)
   {
   $rights[]=$dao->make($res[$i]);
   }
   $ok=$this->evaluate($rights,'getRightsForGroup');
     if($ok)
   return $rights;
     else
   return 0;            
}


Thanks
Back to top
View user's profile Send private message
gaorellana



Joined: 28 Feb 2007
Posts: 2

PostPosted: Wed Feb 28, 2007 5:38 am    Post subject: Reply with quote

I found myself the answer, but I would like to make a contribution for somebody that could face the same problem

the key is in how we define the $params array of the function admin->getRights($params). The key 'selectable_tables' tells LiveUserAdmin which tables should join to get the job done.

Sorry for the excessive tabbing, but I cant get better formattin for the code in this page.

Code:
function getRightsForGroup($group)
      {
      /*parameter array */      
            $params=array(
                                                'container'=>'perm',
                                                'filters'=>array(
                                                                                    'group_id'=>$group->getId()
                                                                              ),
                                                'by_group'=>1,
                                                'selectable_tables'=>array(
                                                                                                            'rights',
                                                                                                            'grouprights'
                                                                                                            )
                                                );
                                                
            $res=$this->admin->getRights($params);
            
            $dao=new RightDao();
            $rights=array();
            for($i=0;$i<count($res);$i++)
            {
                  $rights[]=$dao->make($res[$i]);
            }
            
            $ok=$this->evaluate($rights,'getRightsForGroup');
            
            if($ok)
                  return $rights;
            else
                  return 0;
      }


Regards
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Authentication All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software