Development

Changeset 8943

You must first sign up to be able to contribute.

Changeset 8943

Show
Ignore:
Timestamp:
05/14/08 07:00:58 (5 months ago)
Author:
Jonathan.Wage
Message:

Fixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfGuardDoctrinePlugin/trunk/lib/model/doctrine/PluginsfGuardUser.class.php

    r8776 r8943  
    140140    $up = new sfGuardUserPermission(); 
    141141    $up->setsfGuardUser($this); 
    142     $up->sfsfGuardPermission($permission); 
     142    $up->setsfGuardPermission($permission); 
    143143 
    144144    $up->save($con); 
     
    147147  public function hasGroup($name) 
    148148  { 
    149     if (!$this->groups) 
    150     { 
    151       $this->getGroups(); 
    152     } 
    153  
     149    $this->loadGroupsAndPermissions(); 
    154150    return isset($this->groups[$name]); 
    155151  } 
    156152 
    157   public function getGroups() 
    158   { 
    159     if (!$this->groups) 
    160     { 
    161       $this->groups = array(); 
    162  
    163       $ugs = Doctrine_Query::create() 
    164               ->from('sfGuardUserGroup ug') 
    165               ->leftJoin('ug.sfGuardGroup g') 
    166               ->where('ug.user_id = ?', $this->getId()) 
    167               ->execute(); 
    168  
    169       foreach ($ugs as $ug) 
    170       { 
    171         $group = $ug->getsfGuardGroup(); 
    172         $this->groups[$group->getName()] = $group; 
    173       } 
    174     } 
    175  
    176     return $this->groups; 
    177   } 
    178  
    179153  public function getGroupNames() 
    180154  { 
    181     return array_keys($this->getGroups()); 
     155    $this->loadGroupsAndPermissions(); 
     156    return array_keys($this->groups); 
    182157  } 
    183158 
    184159  public function hasPermission($name) 
    185160  { 
    186     if (!$this->permissions) 
    187     { 
    188       $this->getPermissions(); 
    189     } 
    190  
     161    $this->loadGroupsAndPermissions(); 
    191162    return isset($this->permissions[$name]); 
    192163  } 
    193164 
    194   public function getPermissions() 
    195   { 
    196     if (!$this->permissions) 
    197     { 
    198       $this->permissions = array(); 
    199  
    200       $ups = Doctrine_Query::create() 
    201               ->from('sfGuardUserPermission up') 
    202               ->leftJoin('up.sfGuardPermission p') 
    203               ->where('up.user_id = ?', $this->getId()) 
    204               ->execute(); 
    205  
    206       foreach ($ups as $up) 
    207       { 
    208         $permission = $up->getPermission(); 
    209         $this->permissions[$permission->getName()] = $permission; 
    210       } 
    211     } 
    212  
    213     return $this->permissions; 
    214   } 
    215  
    216165  public function getPermissionNames() 
    217166  { 
    218     return array_keys($this->getPermissions()); 
     167    $this->loadGroupsAndPermissions(); 
     168    return array_keys($this->permissions); 
    219169  } 
    220170 
     
    243193  } 
    244194 
     195  public function loadGroupsAndPermissions() 
     196  { 
     197    $this->getAllPermissions(); 
     198    if (!$this->permissions) 
     199    { 
     200      $permissions = $this->getPermissions(); 
     201      foreach ($permissions as $permission) 
     202      { 
     203        $this->permissions[$permission->getName()] = $permission; 
     204      } 
     205    } 
     206    if (!$this->groups) 
     207    { 
     208      $groups = $this->getGroups(); 
     209      foreach ($groups as $group) 
     210      { 
     211        $this->groups[$group->getName()] = $group; 
     212      } 
     213    } 
     214  } 
    245215  public function reloadGroupsAndPermissions() 
    246216  { 
  • plugins/sfGuardDoctrinePlugin/trunk/modules/sfGuardGroup/config/generator.yml

    r8942 r8943  
    1212      title:          Edit "%%name%%" group 
    1313      fields: 
    14         permissions:  { type: doctrine_admin_double_list, params: through_class=sfGuardGroupPermission } 
     14        permissions:  { type: doctrine_admin_check_list, params: through_class=sfGuardGroupPermission } 
    1515      display:        [ name, description, permissions ] 
  • plugins/sfGuardDoctrinePlugin/trunk/modules/sfGuardUser/config/generator.yml

    r8942 r8943  
    1616        password: 
    1717        password_bis: 
    18         groups:       { name: Groups/Roles, type: doctrine_admin_double_list, params: through_class=sfGuardUserGroup } 
     18        groups:       { name: Groups/Roles, type: doctrine_admin_check_list, params: through_class=sfGuardUserGroup } 
    1919        permissions:  { name: Permissions, type: doctrine_admin_check_list, params: through_class=sfGuardUserPermission } 
    2020        last_login:   { type: plain }