Development

Changeset 12075

You must first sign up to be able to contribute.

Changeset 12075

Show
Ignore:
Timestamp:
10/08/08 18:15:03 (5 years ago)
Author:
noel
Message:

[sfGuardPlugin] 1.2 : backported changes from 1.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfGuardPlugin/branches/1.2/README

    r9999 r12075  
    1 = sfGuard plugin (for symfony 1.1) = 
     1sfGuard plugin 
     2============== 
    23 
    34The `sfGuardPlugin` is a symfony plugin that provides authentication and 
     
    89a configurable plugin. 
    910 
    10 == Installation == 
     11Installation 
     12------------ 
    1113 
    1214  * Install the plugin 
    1315 
    14     {{{ 
    15       symfony plugin:install sfGuardPlugin 
    16     }}} 
     16        $ symfony plugin:install sfGuardPlugin 
    1717 
    1818  * Rebuild your model 
    1919 
    20     {{{ 
    21       symfony propel:build-model 
    22       symfony propel:build-sql 
    23     }}} 
     20        $ symfony propel:build-model 
     21        $ symfony propel:build-sql 
    2422 
    2523  * Update you database tables by starting from scratch (it will delete all 
    2624    the existing tables, then re-create them): 
    2725 
    28     {{{ 
    29       symfony propel:insert-sql 
    30     }}} 
     26        $ symfony propel:insert-sql 
    3127 
    3228    or you can just create the new tables by using the generated SQL 
     
    3531  * Load default fixtures (optional - it creates a superadmin user) 
    3632 
    37     {{{ 
    38       mkdir data/fixtures/ 
    39       cp plugins/sfGuardPlugin/data/fixtures/fixtures.yml.sample data/fixtures/sfGuard.yml 
    40  
    41       symfony propel:data-load frontend # replace frontend with the name of one of your application 
    42     }}} 
     33        $ mkdir data/fixtures/ 
     34        $ cp plugins/sfGuardPlugin/data/fixtures/fixtures.yml.sample data/fixtures/sfGuard.yml 
     35 
     36        $ symfony propel:data-load frontend # replace frontend with the name of one of your application 
    4337 
    4438  * Enable one or more modules in your `settings.yml` (optional) 
     
    4640    * For your frontend application: sfGuardAuth 
    4741 
    48     {{{ 
    49       all: 
    50         .settings: 
    51           enabled_modules:      [default, sfGuardGroup, sfGuardUser, sfGuardPermission] 
    52     }}} 
     42            [php] 
     43            all: 
     44              .settings: 
     45                enabled_modules:      [default, sfGuardGroup, sfGuardUser, sfGuardPermission] 
    5346 
    5447  * Clear you cache 
    5548 
    56     {{{ 
    57       symfony cc 
    58     }}} 
     49        $ symfony cc 
    5950 
    6051  * Optionally enable the "Remember Me" filter in `filters.yml` 
    6152 
    62     {{{ 
    63       security: 
    64         class: sfGuardBasicSecurityFilter 
    65     }}} 
    66  
    67 === Secure your application === 
     53        [yml] 
     54        security: 
     55          class: sfGuardBasicSecurityFilter 
     56 
     57Secure your application 
     58----------------------- 
    6859 
    6960To secure a symfony application: 
     
    7162  * Enable the module `sfGuardAuth` in `settings.yml` 
    7263 
    73   {{{ 
    74     all: 
    75       .settings: 
    76         enabled_modules: [..., sfGuardAuth] 
    77   }}} 
     64        [yml] 
     65        all: 
     66          .settings: 
     67            enabled_modules: [..., sfGuardAuth] 
    7868 
    7969  * Change the default login and secure modules in `settings.yml` 
    8070 
    81   {{{ 
    82     login_module:           sfGuardAuth 
    83     login_action:           signin 
    84  
    85     secure_module:          sfGuardAuth 
    86     secure_action:          secure 
    87   }}} 
     71        [yml] 
     72        login_module:           sfGuardAuth 
     73        login_action:           signin 
     74 
     75        secure_module:          sfGuardAuth 
     76        secure_action:          secure 
    8877 
    8978  * Change the parent class in `myUser.class.php` 
    9079 
    91   {{{ 
    92     class myUser extends sfGuardSecurityUser 
    93     { 
    94     } 
    95   }}} 
     80        [php] 
     81        class myUser extends sfGuardSecurityUser 
     82        { 
     83        } 
    9684 
    9785  * Optionally add the following routing rules to `routing.yml` 
    9886 
    99   {{{ 
    100     sf_guard_signin: 
    101       url:   /login 
    102       param: { module: sfGuardAuth, action: signin } 
    103  
    104     sf_guard_signout: 
    105       url:   /logout 
    106       param: { module: sfGuardAuth, action: signout } 
    107  
    108     sf_guard_password: 
    109       url:   /request_password 
    110       param: { module: sfGuardAuth, action: password } 
    111   }}} 
     87        [yml] 
     88        sf_guard_signin: 
     89          url:   /login 
     90          param: { module: sfGuardAuth, action: signin } 
     91 
     92        sf_guard_signout: 
     93          url:   /logout 
     94          param: { module: sfGuardAuth, action: signout } 
     95 
     96        sf_guard_password: 
     97          url:   /request_password 
     98          param: { module: sfGuardAuth, action: password } 
    11299 
    113100  You can customize the `url` parameter of each route. 
     
    118105  in the `app.yml` configuration file: 
    119106 
    120   {{{ 
    121     all: 
    122       sf_guard_plugin: 
    123         routes_register: false 
    124   }}} 
     107      [yml] 
     108      all: 
     109        sf_guard_plugin: 
     110          routes_register: false 
    125111 
    126112  * Secure some modules or your entire application in `security.yml` 
    127113 
    128   {{{ 
    129     default: 
    130       is_secure: on 
    131   }}} 
     114        [yml] 
     115        default: 
     116          is_secure: on 
    132117 
    133118  * You're done. Now, if you try to access a secure page, you will be redirected 
     
    136121    username and `admin` as password. 
    137122 
    138 == Manage your users, permissions and groups == 
     123Manage your users, permissions and groups 
     124----------------------------------------- 
    139125 
    140126To be able to manage your users, permissions and groups, `sfGuardPlugin` comes 
     
    144130  * Enable the modules in `settings.yml` 
    145131 
    146   {{{ 
    147     all: 
    148       .settings: 
    149         enabled_modules: [..., sfGuardGroup, sfGuardPermission, sfGuardUser] 
    150   }}} 
     132        [yml] 
     133        all: 
     134          .settings: 
     135            enabled_modules: [..., sfGuardGroup, sfGuardPermission, sfGuardUser] 
    151136 
    152137  * Access the modules with the default route: 
    153138 
    154   {{{ 
    155     http://www.example.com/backend.php/sfGuardUser 
    156   }}} 
    157  
    158 == Customize sfGuardAuth module templates == 
     139        http://www.example.com/backend.php/sfGuardUser 
     140 
     141Customize sfGuardAuth module templates 
     142-------------------------------------- 
    159143 
    160144By default, `sfGuardAuth` module comes with 2 very simple templates: 
     
    173157  * symfony now renders your template instead of the default one 
    174158 
    175 == Customize `sfGuardAuth` module actions == 
     159Customize `sfGuardAuth` module actions 
     160-------------------------------------- 
    176161 
    177162If you want to customize or add methods to the sfGuardAuth: 
     
    183168    as it can't be autoloaded by symfony) 
    184169 
    185   {{{ 
    186     <?php 
    187  
    188     require_once(sfConfig::get('sf_plugins_dir').'/sfGuardPlugin/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php'); 
    189  
    190     class sfGuardAuthActions extends BasesfGuardAuthActions 
    191    
    192       public function executeNewAction() 
    193      
    194         return $this->renderText('This is a new sfGuardAuth action.'); 
    195      
    196    
    197   }}} 
    198  
    199 == `sfGuardSecurityUser` class == 
     170        [php] 
     171        <?php 
     172 
     173        require_once(sfConfig::get('sf_plugins_dir').'/sfGuardPlugin/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php'); 
     174 
     175        class sfGuardAuthActions extends BasesfGuardAuthActions 
     176       
     177          public function executeNewAction() 
     178         
     179            return $this->renderText('This is a new sfGuardAuth action.'); 
     180         
     181       
     182 
     183`sfGuardSecurityUser` class 
     184--------------------------- 
    200185 
    201186This class inherits from the `sfBasicSecurityUser` class from symfony and is 
     
    214199For example, to get the current username: 
    215200 
    216   {{{ 
     201    [php] 
    217202    $this->getUser()->getGuardUser()->getUsername() 
    218203 
    219204    // or via the proxy method 
    220205    $this->getUser()->getUsername() 
    221   }}} 
    222  
    223 == Super administrator flag == 
     206 
     207Super administrator flag 
     208------------------------ 
    224209 
    225210`sfGuardPlugin` has a notion of super administrator. A user that is a super 
     
    229214directly in the database or use the pake task: 
    230215 
    231   {{{ 
    232     symfony promote-super-admin admin 
    233   }}} 
    234  
    235 == Validators == 
     216    $ symfony promote-super-admin admin 
     217 
     218Validators 
     219---------- 
    236220 
    237221`sfGuardPlugin` comes with a validator that you can use in your modules: 
     
    241225password and automatically signin the user. 
    242226 
    243 == Customize the `sfGuardUser` model == 
     227Customize the `sfGuardUser` model 
     228--------------------------------- 
    244229 
    245230The `sfGuardUser` model is quite simple. There is no `email` or `first_name` 
     
    251236Here is a simple example of a `sfGuardProfile` class that you can add to `schema.yml`: 
    252237 
    253   {{{ 
     238    [yml] 
    254239    sf_guard_user_profile: 
    255240      _attributes: { phpName: sfGuardUserProfile } 
     
    259244      last_name:   varchar(20) 
    260245      birthday:    date 
    261   }}} 
    262246 
    263247You can now access the user profile via the user object: 
    264248 
    265   {{{ 
     249    [php] 
    266250    $this->getUser()->getGuardUser()->getProfile()->getFirstName() 
    267251 
    268252    // or via the proxy method 
    269253    $this->getUser()->getProfile()->getFirstName() 
    270   }}} 
    271254 
    272255The `getProfile()` method gets the associated user profile object or creates a 
     
    278261`app.yml`: 
    279262 
    280   {{{ 
     263    [yml] 
    281264    all: 
    282265      sf_guard_plugin: 
    283266        profile_class:      sfGuardUserProfile 
    284267        profile_field_name: user_id 
    285   }}} 
    286  
    287 == Check the user password with an external method == 
     268 
     269Check the user password with an external method 
     270----------------------------------------------- 
    288271 
    289272If you don't want to store the password in the database because you already 
     
    292275function) in `app.yml`: 
    293276 
    294   {{{ 
     277    [yml] 
    295278    all: 
    296279      sf_guard_plugin: 
    297280        check_password_callable: [MyLDAPClass, checkPassword] 
    298   }}} 
    299281 
    300282When symfony will call the `$this->getUser()->checkPassword()` method, it will 
     
    303285or false. Here is a template for such a function: 
    304286 
    305   {{{ 
     287    [php] 
    306288    function checkLDAPPassword($username, $password) 
    307289    { 
     
    316298      } 
    317299    } 
    318   }}} 
    319  
    320 == Change the algorithm used to store passwords == 
     300 
     301Change the algorithm used to store passwords 
     302-------------------------------------------- 
    321303 
    322304By default, passwords are stored as a `sha1()` hash. But you can change this 
    323305with any callable in `app.yml`: 
    324306 
    325   {{{ 
     307    [yml] 
    326308    all: 
    327309      sf_guard_plugin: 
    328310        algorithm_callable: [MyCryptoClass, MyCryptoMethod] 
    329   }}} 
    330311 
    331312or 
    332313 
    333   {{{ 
     314    [yml] 
    334315    all: 
    335316      sf_guard_plugin: 
    336317        algorithm_callable: md5 
    337   }}} 
    338318 
    339319As the algorithm is stored for each user, you can change your mind later 
    340320without the need to regenerate all passwords for the current users. 
    341321 
    342 == Change the name or expiration period of the "Remember Me" cookie == 
     322Change the name or expiration period of the "Remember Me" cookie 
     323---------------------------------------------------------------- 
    343324 
    344325By default, the "Remember Me" feature creates a cookie named `sfRemember` 
    345326that will last 15 days.  You can change this behavior in `app.yml`: 
    346327 
    347   {{{ 
     328    [yml] 
    348329    all: 
    349330      sf_guard_plugin: 
    350331         remember_key_expiration_age:  2592000   # 30 days in seconds 
    351332         remember_cookie_name:         myAppRememberMe 
    352   }}} 
    353  
    354  
    355 == Customize `sfGuardAuth` redirect handling == 
     333 
     334Customize `sfGuardAuth` redirect handling 
     335----------------------------------------- 
    356336 
    357337If you want to redirect the user to his profile after a success login or 
     
    360340You can change the redirect values in `app.yml`: 
    361341 
    362   {{{ 
     342    [yml] 
    363343    all: 
    364344      sf_guard_plugin: 
    365345        success_signin_url:      @my_route?param=value # the plugin use the referer as default 
    366346        success_signout_url:     module/action         # the plugin use the referer as default 
    367   }}} 
    368  
    369 == TODO == 
     347 
     348Configure the signin form 
     349------------------------- 
     350 
     351You can change the signin form used by the `sfGuardAuth` module in `app.yml`: 
     352 
     353    [yml] 
     354    all: 
     355      sf_guard_plugin: 
     356        signin_form:    sfGuardFormSigninCustom 
     357 
     358TODO 
     359---- 
    370360 
    371361  * finish the `getPassword` method 
    372362  * add support for HTTP Basic authentication 
    373  
    374 == Changelog == 
    375  
    376 === 2.2.0 === 
    377  
    378 === 2.1.0-PRE === 
    379  
    380   * fabien: optimized getAllPermissions() number of database requests (#3238) 
    381   * fabien: added the user object as a third parameter when calling the `app_sf_guard_plugin_check_password_callable` callable (#3231) 
    382   * fabien: fixed `isSuperAdmin()` method (#2719) 
    383   * fabien: fixed schema for IPv6 (#3626) 
    384   * fabien: fixed typo (#3501) 
    385   * fabien: added forms (migrated sfGuardAuth) 
    386   * fabien: added guard:create_user and guard:promote tasks 
    387  
    388 === 2.0.0 === 
    389  
    390  * fabien: initial release based on the symfony 1.0 code 
  • plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardFormSignin.class.php

    r7745 r12075  
    88      'username' => new sfWidgetFormInput(), 
    99      'password' => new sfWidgetFormInput(array('type' => 'password')), 
     10      'remember' => new sfWidgetFormInputCheckbox(), 
    1011    )); 
    1112 
     
    1314      'username' => new sfValidatorString(), 
    1415      'password' => new sfValidatorString(), 
     16      'remember' => new sfValidatorBoolean(), 
    1517    )); 
    1618 
  • plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardUserForm.class.php

    r7745 r12075  
    1010class sfGuardUserForm extends BasesfGuardUserForm 
    1111{ 
     12  protected 
     13    $pkName = null; 
     14 
    1215  public function configure() 
    1316  { 
     17    unset( 
     18      $this['last_login'], 
     19      $this['created_at'], 
     20      $this['salt'], 
     21      $this['algorithm'], 
     22      $this['is_active'], 
     23      $this['is_super_admin'], 
     24      $this['sf_guard_user_group_list'], 
     25      $this['sf_guard_user_permission_list'] 
     26    ); 
     27 
     28    $this->widgetSchema['password'] = new sfWidgetFormInputPassword(); 
     29    $this->validatorSchema['password']->setOption('required', false); 
     30    $this->widgetSchema['password_again'] = new sfWidgetFormInputPassword(); 
     31    $this->validatorSchema['password_again'] = clone $this->validatorSchema['password']; 
     32 
     33    $this->widgetSchema->moveField('password_again', 'after', 'password'); 
     34 
     35    $this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'password_again', array(), array('invalid' => 'The two passwords must be the same.'))); 
     36 
     37    // profile form? 
     38    $profileFormClass = sfConfig::get('app_sf_guard_plugin_profile_class', 'sfGuardUserProfile').'Form'; 
     39    if (class_exists($profileFormClass)) 
     40    { 
     41      $profileForm = new $profileFormClass(); 
     42      unset($profileForm[$this->getPrimaryKey()]); 
     43      unset($profileForm[sfConfig::get('app_sf_guard_plugin_profile_field_name', 'user_id')]); 
     44 
     45      $this->mergeForm($profileForm); 
     46    } 
     47  } 
     48 
     49  public function updateObject() 
     50  { 
     51    parent::updateObject(); 
     52 
     53    // update defaults for profile 
     54    if (!is_null($profile = $this->getProfile())) 
     55    { 
     56      $values = $this->getValues(); 
     57      unset($values[$this->getPrimaryKey()]); 
     58 
     59      $profile->fromArray($values, BasePeer::TYPE_FIELDNAME); 
     60      $profile->save(); 
     61    } 
     62 
     63    return $this->object; 
     64  } 
     65 
     66  public function updateDefaultsFromObject() 
     67  { 
     68    parent::updateDefaultsFromObject(); 
     69 
     70    // update defaults for profile 
     71    if (!is_null($profile = $this->getProfile())) 
     72    { 
     73      $values = $profile->toArray(BasePeer::TYPE_FIELDNAME); 
     74      unset($values[$this->getPrimaryKey()]); 
     75 
     76      // update defaults for the main object 
     77      if ($this->isNew) 
     78      { 
     79        $this->setDefaults(array_merge($values, $this->getDefaults())); 
     80      } 
     81      else 
     82      { 
     83        $this->setDefaults(array_merge($this->getDefaults(), $values)); 
     84      } 
     85    } 
     86  } 
     87 
     88  protected function getProfile() 
     89  { 
     90    try 
     91    { 
     92      return $this->object->getProfile(); 
     93    } 
     94    catch (sfException $e) 
     95    { 
     96      // no profile 
     97      return null; 
     98    } 
     99  } 
     100 
     101  protected function getPrimaryKey() 
     102  { 
     103    if (!is_null($this->pkName)) 
     104    { 
     105      return $this->pkName; 
     106    } 
     107 
     108    $profileClass = sfConfig::get('app_sf_guard_plugin_profile_class', 'sfGuardUserProfile'); 
     109    if (class_exists($profileClass)) 
     110    { 
     111      $tableMap = call_user_func(array($profileClass.'Peer', 'getTableMap')); 
     112      foreach ($tableMap->getColumns() as $column) 
     113      { 
     114        if ($column->isPrimaryKey()) 
     115        { 
     116          return $this->pkName = call_user_func(array($profileClass.'Peer', 'translateFieldname'), $column->getPhpName(), BasePeer::TYPE_PHPNAME, BasePeer::TYPE_FIELDNAME); 
     117        } 
     118      } 
     119    } 
    14120  } 
    15121} 
  • plugins/sfGuardPlugin/branches/1.2/lib/model/plugin/PluginsfGuardGroupPeer.php

    r7634 r12075  
    2525    return self::doSelectOne($c); 
    2626  } 
     27 
     28  // TBB (tom@punkave.com): we implement our own criteria for the 
     29  // groups filter. But the admin generator still has nonfunctional code  
     30  // for it in the base class, code that wants to see a GROUPS constant here.  
     31  // We prevent that code from actually executing by temporarily unsetting  
     32  // $filter['groups'], and in PHP 5.2.x, that is sufficient. However,  
     33  // a future version of PHP might refuse to compile code that refers to a  
     34  // nonexistent constant at all, even if it never runs. So let's be thorough  
     35  // and define the GROUPS constant that the base class code is looking for. 
     36 
     37  const GROUPS = 'dummy'; 
    2738} 
  • plugins/sfGuardPlugin/branches/1.2/lib/model/plugin/PluginsfGuardUser.php

    r11426 r12075  
    5858  public function checkPassword($password) 
    5959  { 
    60     if ($callable = sfConfig::get('app_sf_guard_plugin_check_password_callable')) 
     60    try 
     61    { 
     62      $profile = $this->getProfile(); 
     63    } 
     64    catch (Exception $e) 
     65    { 
     66      $profile = null; 
     67    } 
     68 
     69    if (!is_null($profile) && method_exists($profile, 'checkPassword')) 
     70    { 
     71      return $profile->checkPassword($this->getUsername(), $password, $this); 
     72    } 
     73    else if ($callable = sfConfig::get('app_sf_guard_plugin_check_password_callable')) 
    6174    { 
    6275      return call_user_func_array($callable, array($this->getUsername(), $password, $this)); 
  • plugins/sfGuardPlugin/branches/1.2/lib/task/sfGuardCreateAdminTask.class.php

    r8637 r12075  
    6262    } 
    6363 
     64    $user->setIsSuperAdmin(true); 
     65    $user->save(); 
     66 
    6467    $this->logSection('guard', sprintf('Promote user %s as a super administrator', $arguments['username'])); 
    6568  } 
  • plugins/sfGuardPlugin/branches/1.2/lib/user/sfGuardSecurityUser.class.php

    r9999 r12075  
    1818class sfGuardSecurityUser extends sfBasicSecurityUser 
    1919{ 
    20   private $user = null; 
     20  protected 
     21    $user = null; 
     22 
     23  public function initialize(sfEventDispatcher $dispatcher, sfStorage $storage, $options = array()) 
     24  { 
     25    parent::initialize($dispatcher, $storage, $options); 
     26 
     27    if (!$this->isAuthenticated()) 
     28    { 
     29      // remove user if timeout 
     30      $this->getAttributeHolder()->removeNamespace('sfGuardSecurityUser'); 
     31      $this->user = null; 
     32    } 
     33  } 
    2134 
    2235  public function getReferer($default) 
     
    2538    $this->getAttributeHolder()->remove('referer'); 
    2639 
    27     return $referer
     40    return $referer ? $referer : $default
    2841  } 
    2942 
    3043  public function setReferer($referer) 
    3144  { 
    32     if (!$this->hasAttribute('referer')) 
    33     { 
    34       $this->setAttribute('referer', $referer); 
    35     } 
     45    $this->setAttribute('referer', $referer); 
    3646  } 
    3747 
  • plugins/sfGuardPlugin/branches/1.2/lib/validator/sfGuardValidatorUser.class.php

    r7904 r12075  
    2222    $this->addOption('username_field', 'username'); 
    2323    $this->addOption('password_field', 'password'); 
     24    $this->addOption('rememeber_checkbox', 'remember'); 
    2425    $this->addOption('throw_global_error', false); 
    2526 
     
    3132    $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : ''; 
    3233    $password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : ''; 
     34    $remember = isset($values[$this->getOption('rememeber_checkbox')]) ? $values[$this->getOption('rememeber_checkbox')] : ''; 
    3335 
    3436    // user exists? 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php

    r8892 r12075  
    2626    } 
    2727 
    28     $this->form = new sfGuardFormSignin(); 
     28    $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin'); 
     29    $this->form = new $class(); 
    2930 
    3031    if ($request->isMethod('post')) 
     
    3435      { 
    3536        $values = $this->form->getValues(); 
    36         $this->getUser()->signin($values['user']); 
     37        $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false); 
    3738 
    38         $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer($request->getReferer())); 
     39        // always redirect to a URL set in app.yml 
     40        // or to the referer 
     41        // or to the homepage 
     42        $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer('@homepage')); 
    3943 
    40         return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage'); 
     44        return $this->redirect($signinUrl); 
    4145      } 
    4246    } 
     
    5155      } 
    5256 
    53       $user->setReferer($request->getReferer()); 
     57      // if we have been forwarded, then the referer is the current URL 
     58      // if not, this is the referer of the current request 
     59      $user->setReferer($this->getContext()->getActionStack()->getSize() > 1 ? $request->getUri() : $request->getReferer()); 
    5460 
    5561      $module = sfConfig::get('sf_login_module'); 
     
    6773    $this->getUser()->signOut(); 
    6874 
    69     $signout_url = sfConfig::get('app_sf_guard_plugin_success_signout_url', $request->getReferer()); 
     75    $signoutUrl = sfConfig::get('app_sf_guard_plugin_success_signout_url', $request->getReferer()); 
    7076 
    71     $this->redirect('' != $signout_url ? $signout_url : '@homepage'); 
     77    $this->redirect('' != $signoutUrl ? $signoutUrl : '@homepage'); 
    7278  } 
    7379 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/config/generator.yml

    r9999 r12075  
    1111      title:   User list 
    1212      display: [ =username, created_at, last_login ] 
    13       filters: [ username
     13      filters: [ username, _groups
    1414 
    1515    edit: 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/lib/BasesfGuardUserActions.class.php

    r7634 r12075  
    3232    return true; 
    3333  } 
     34 
     35  protected function addFiltersCriteria($c) 
     36  { 
     37    // Tom Boutell (tom@punkave.com): implement filtering for groups. If  
     38    // any groups are checked, display only users who are in one or more  
     39    // of the checked groups. Also, take steps to prevent the base class 
     40    // implementation from attempting to incorrectly filter for groups. 
     41 
     42    if (isset($this->filters['groups']))  
     43    { 
     44      $groups = $this->filters['groups']; 
     45      if (count($groups))  
     46      { 
     47        $c->addJoin(sfGuardUserPeer::ID, sfGuardUserGroupPeer::USER_ID); 
     48        $orClause = false; 
     49        foreach ($groups as $group) 
     50        { 
     51          $crit = $c->getNewCriterion(sfGuardUserGroupPeer::GROUP_ID, $group); 
     52          if (!$orClause) { 
     53            $orClause = $crit; 
     54          } else { 
     55            $orClause->addOr($crit); 
     56          } 
     57        } 
     58        $c->add($orClause); 
     59      } 
     60    } 
     61    // Prevent the base class implementation from setting up criteria 
     62    // for groups that can't actually work (there is 
     63    // no such thing as sfGuardUserPeer::GROUPS). TODO: although 
     64    // PHP 5.2.x doesn't seem to mind compiling (not executing) 
     65    // references to nonexistent constants, we should define a GROUPS 
     66    // constant in sfGuardUserPeer anyway, just to be futureproof. 
     67 
     68    // Hide the groups filter from the base class implementation 
     69    if (isset($this->filters['groups_is_empty']))  
     70    { 
     71      $groupsIsEmpty = $this->filters['groups_is_empty']; 
     72      unset($this->filters['groups_is_empty']); 
     73    } 
     74    if (isset($this->filters['groups']))  
     75    { 
     76      $groups = $this->filters['groups']; 
     77      unset($this->filters['groups']); 
     78    } 
     79 
     80    // Call the base class implementation to get the other filters 
     81    $result = parent::addFiltersCriteria($c); 
     82 
     83    // Restore the groups filter 
     84    if (isset($groupsIsEmpty))  
     85    { 
     86      $this->filters['groups_is_empty'] = $groupsIsEmpty;    
     87    } 
     88    if (isset($groups))  
     89    { 
     90      $this->filters['groups'] = $groups; 
     91    } 
     92  } 
     93 
    3494} 
  • plugins/sfGuardPlugin/branches/1.2/package.xml

    r9999 r12075  
    2727  <user>fzaninotto</user> 
    2828  <email>francois.zaninotto@symfony-project.com</email> 
    29   <active>yes</active> 
     29  <active>no</active> 
    3030 </developer> 
    31  <date>2008-05-26</date> 
     31 <date>2008-10-08</date> 
    3232 <version> 
    33    <release>2.1.0</release> 
     33   <release>3.0.0</release> 
    3434   <api>1.1.0</api> 
    3535 </version> 
     
    112112         <file role="data" name="sfGuardCreateAdminTask.class.php" /> 
    113113         <file role="data" name="sfGuardCreateUserTask.class.php" /> 
     114         <file role="data" name="sfGuardAddPermissionTask.class.php" /> 
     115         <file role="data" name="sfGuardAddGroupTask.class.php" /> 
    114116       </dir> 
    115117 
     
    146148         <file role="data" name="templates/_password.php" /> 
    147149         <file role="data" name="templates/_password_bis.php" /> 
     150         <file role="data" name="templates/_groups.php" /> 
    148151         <file role="data" name="validate/edit.yml" /> 
    149152       </dir> 
     
    173176 </phprelease> 
    174177 
    175  <changelog> 
    176  </changelog> 
     178  <changelog> 
     179    <release> 
     180      <version> 
     181        <release>3.0.0</release> 
     182        <api>1.1.0</api> 
     183      </version> 
     184      <stability> 
     185       <release>stable</release> 
     186       <api>stable</api> 
     187      </stability> 
     188      <license uri="http://www.symfony-project.com/license">MIT license</license> 
     189      <date>2008-10-08</date> 
     190      <license>MIT</license> 
     191      <notes> 
     192        * noel: backported changes from 1.1 
     193      </notes> 
     194    </release> 
     195  </changelog> 
    177196</package>