Changeset 12075
- Timestamp:
- 10/08/08 18:15:03 (5 years ago)
- Files:
-
- plugins/sfGuardPlugin/branches/1.2/README (modified) (20 diffs)
- plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardFormSignin.class.php (modified) (2 diffs)
- plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardUserForm.class.php (modified) (1 diff)
- plugins/sfGuardPlugin/branches/1.2/lib/model/plugin/PluginsfGuardGroupPeer.php (modified) (1 diff)
- plugins/sfGuardPlugin/branches/1.2/lib/model/plugin/PluginsfGuardUser.php (modified) (1 diff)
- plugins/sfGuardPlugin/branches/1.2/lib/task/sfGuardAddGroupTask.class.php (copied) (copied from plugins/sfGuardPlugin/branches/1.1/lib/task/sfGuardAddGroupTask.class.php)
- plugins/sfGuardPlugin/branches/1.2/lib/task/sfGuardAddPermissionTask.class.php (copied) (copied from plugins/sfGuardPlugin/branches/1.1/lib/task/sfGuardAddPermissionTask.class.php)
- plugins/sfGuardPlugin/branches/1.2/lib/task/sfGuardCreateAdminTask.class.php (modified) (1 diff)
- plugins/sfGuardPlugin/branches/1.2/lib/user/sfGuardSecurityUser.class.php (modified) (2 diffs)
- plugins/sfGuardPlugin/branches/1.2/lib/validator/sfGuardValidatorUser.class.php (modified) (2 diffs)
- plugins/sfGuardPlugin/branches/1.2/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php (modified) (4 diffs)
- plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/config/generator.yml (modified) (1 diff)
- plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/lib/BasesfGuardUserActions.class.php (modified) (1 diff)
- plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/templates/_groups.php (copied) (copied from plugins/sfGuardPlugin/branches/1.1/modules/sfGuardUser/templates/_groups.php)
- plugins/sfGuardPlugin/branches/1.2/package.xml (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfGuardPlugin/branches/1.2/README
r9999 r12075 1 = sfGuard plugin (for symfony 1.1) = 1 sfGuard plugin 2 ============== 2 3 3 4 The `sfGuardPlugin` is a symfony plugin that provides authentication and … … 8 9 a configurable plugin. 9 10 10 == Installation == 11 Installation 12 ------------ 11 13 12 14 * Install the plugin 13 15 14 {{{ 15 symfony plugin:install sfGuardPlugin 16 }}} 16 $ symfony plugin:install sfGuardPlugin 17 17 18 18 * Rebuild your model 19 19 20 {{{ 21 symfony propel:build-model 22 symfony propel:build-sql 23 }}} 20 $ symfony propel:build-model 21 $ symfony propel:build-sql 24 22 25 23 * Update you database tables by starting from scratch (it will delete all 26 24 the existing tables, then re-create them): 27 25 28 {{{ 29 symfony propel:insert-sql 30 }}} 26 $ symfony propel:insert-sql 31 27 32 28 or you can just create the new tables by using the generated SQL … … 35 31 * Load default fixtures (optional - it creates a superadmin user) 36 32 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 43 37 44 38 * Enable one or more modules in your `settings.yml` (optional) … … 46 40 * For your frontend application: sfGuardAuth 47 41 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] 53 46 54 47 * Clear you cache 55 48 56 {{{ 57 symfony cc 58 }}} 49 $ symfony cc 59 50 60 51 * Optionally enable the "Remember Me" filter in `filters.yml` 61 52 62 {{{63 security:64 class: sfGuardBasicSecurityFilter65 }}} 66 67 === Secure your application === 53 [yml] 54 security: 55 class: sfGuardBasicSecurityFilter 56 57 Secure your application 58 ----------------------- 68 59 69 60 To secure a symfony application: … … 71 62 * Enable the module `sfGuardAuth` in `settings.yml` 72 63 73 {{{ 74 all: 75 .settings: 76 enabled_modules: [..., sfGuardAuth] 77 }}} 64 [yml] 65 all: 66 .settings: 67 enabled_modules: [..., sfGuardAuth] 78 68 79 69 * Change the default login and secure modules in `settings.yml` 80 70 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 88 77 89 78 * Change the parent class in `myUser.class.php` 90 79 91 {{{ 92 class myUser extends sfGuardSecurityUser 93 { 94 } 95 }}} 80 [php] 81 class myUser extends sfGuardSecurityUser 82 { 83 } 96 84 97 85 * Optionally add the following routing rules to `routing.yml` 98 86 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 } 112 99 113 100 You can customize the `url` parameter of each route. … … 118 105 in the `app.yml` configuration file: 119 106 120 {{{ 121 all: 122 sf_guard_plugin: 123 routes_register: false 124 }}} 107 [yml] 108 all: 109 sf_guard_plugin: 110 routes_register: false 125 111 126 112 * Secure some modules or your entire application in `security.yml` 127 113 128 {{{ 129 default: 130 is_secure: on 131 }}} 114 [yml] 115 default: 116 is_secure: on 132 117 133 118 * You're done. Now, if you try to access a secure page, you will be redirected … … 136 121 username and `admin` as password. 137 122 138 == Manage your users, permissions and groups == 123 Manage your users, permissions and groups 124 ----------------------------------------- 139 125 140 126 To be able to manage your users, permissions and groups, `sfGuardPlugin` comes … … 144 130 * Enable the modules in `settings.yml` 145 131 146 {{{ 147 all: 148 .settings: 149 enabled_modules: [..., sfGuardGroup, sfGuardPermission, sfGuardUser] 150 }}} 132 [yml] 133 all: 134 .settings: 135 enabled_modules: [..., sfGuardGroup, sfGuardPermission, sfGuardUser] 151 136 152 137 * Access the modules with the default route: 153 138 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 141 Customize sfGuardAuth module templates 142 -------------------------------------- 159 143 160 144 By default, `sfGuardAuth` module comes with 2 very simple templates: … … 173 157 * symfony now renders your template instead of the default one 174 158 175 == Customize `sfGuardAuth` module actions == 159 Customize `sfGuardAuth` module actions 160 -------------------------------------- 176 161 177 162 If you want to customize or add methods to the sfGuardAuth: … … 183 168 as it can't be autoloaded by symfony) 184 169 185 {{{186 <?php187 188 require_once(sfConfig::get('sf_plugins_dir').'/sfGuardPlugin/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php');189 190 class sfGuardAuthActions extends BasesfGuardAuthActions191 {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 --------------------------- 200 185 201 186 This class inherits from the `sfBasicSecurityUser` class from symfony and is … … 214 199 For example, to get the current username: 215 200 216 {{{201 [php] 217 202 $this->getUser()->getGuardUser()->getUsername() 218 203 219 204 // or via the proxy method 220 205 $this->getUser()->getUsername() 221 }}} 222 223 == Super administrator flag == 206 207 Super administrator flag 208 ------------------------ 224 209 225 210 `sfGuardPlugin` has a notion of super administrator. A user that is a super … … 229 214 directly in the database or use the pake task: 230 215 231 {{{ 232 symfony promote-super-admin admin 233 }}} 234 235 == Validators == 216 $ symfony promote-super-admin admin 217 218 Validators 219 ---------- 236 220 237 221 `sfGuardPlugin` comes with a validator that you can use in your modules: … … 241 225 password and automatically signin the user. 242 226 243 == Customize the `sfGuardUser` model == 227 Customize the `sfGuardUser` model 228 --------------------------------- 244 229 245 230 The `sfGuardUser` model is quite simple. There is no `email` or `first_name` … … 251 236 Here is a simple example of a `sfGuardProfile` class that you can add to `schema.yml`: 252 237 253 {{{238 [yml] 254 239 sf_guard_user_profile: 255 240 _attributes: { phpName: sfGuardUserProfile } … … 259 244 last_name: varchar(20) 260 245 birthday: date 261 }}}262 246 263 247 You can now access the user profile via the user object: 264 248 265 {{{249 [php] 266 250 $this->getUser()->getGuardUser()->getProfile()->getFirstName() 267 251 268 252 // or via the proxy method 269 253 $this->getUser()->getProfile()->getFirstName() 270 }}}271 254 272 255 The `getProfile()` method gets the associated user profile object or creates a … … 278 261 `app.yml`: 279 262 280 {{{263 [yml] 281 264 all: 282 265 sf_guard_plugin: 283 266 profile_class: sfGuardUserProfile 284 267 profile_field_name: user_id 285 }}} 286 287 == Check the user password with an external method == 268 269 Check the user password with an external method 270 ----------------------------------------------- 288 271 289 272 If you don't want to store the password in the database because you already … … 292 275 function) in `app.yml`: 293 276 294 {{{277 [yml] 295 278 all: 296 279 sf_guard_plugin: 297 280 check_password_callable: [MyLDAPClass, checkPassword] 298 }}}299 281 300 282 When symfony will call the `$this->getUser()->checkPassword()` method, it will … … 303 285 or false. Here is a template for such a function: 304 286 305 {{{287 [php] 306 288 function checkLDAPPassword($username, $password) 307 289 { … … 316 298 } 317 299 } 318 }}} 319 320 == Change the algorithm used to store passwords == 300 301 Change the algorithm used to store passwords 302 -------------------------------------------- 321 303 322 304 By default, passwords are stored as a `sha1()` hash. But you can change this 323 305 with any callable in `app.yml`: 324 306 325 {{{307 [yml] 326 308 all: 327 309 sf_guard_plugin: 328 310 algorithm_callable: [MyCryptoClass, MyCryptoMethod] 329 }}}330 311 331 312 or 332 313 333 {{{314 [yml] 334 315 all: 335 316 sf_guard_plugin: 336 317 algorithm_callable: md5 337 }}}338 318 339 319 As the algorithm is stored for each user, you can change your mind later 340 320 without the need to regenerate all passwords for the current users. 341 321 342 == Change the name or expiration period of the "Remember Me" cookie == 322 Change the name or expiration period of the "Remember Me" cookie 323 ---------------------------------------------------------------- 343 324 344 325 By default, the "Remember Me" feature creates a cookie named `sfRemember` 345 326 that will last 15 days. You can change this behavior in `app.yml`: 346 327 347 {{{328 [yml] 348 329 all: 349 330 sf_guard_plugin: 350 331 remember_key_expiration_age: 2592000 # 30 days in seconds 351 332 remember_cookie_name: myAppRememberMe 352 }}} 353 354 355 == Customize `sfGuardAuth` redirect handling == 333 334 Customize `sfGuardAuth` redirect handling 335 ----------------------------------------- 356 336 357 337 If you want to redirect the user to his profile after a success login or … … 360 340 You can change the redirect values in `app.yml`: 361 341 362 {{{342 [yml] 363 343 all: 364 344 sf_guard_plugin: 365 345 success_signin_url: @my_route?param=value # the plugin use the referer as default 366 346 success_signout_url: module/action # the plugin use the referer as default 367 }}} 368 369 == TODO == 347 348 Configure the signin form 349 ------------------------- 350 351 You 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 358 TODO 359 ---- 370 360 371 361 * finish the `getPassword` method 372 362 * 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 tasks387 388 === 2.0.0 ===389 390 * fabien: initial release based on the symfony 1.0 codeplugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardFormSignin.class.php
r7745 r12075 8 8 'username' => new sfWidgetFormInput(), 9 9 'password' => new sfWidgetFormInput(array('type' => 'password')), 10 'remember' => new sfWidgetFormInputCheckbox(), 10 11 )); 11 12 … … 13 14 'username' => new sfValidatorString(), 14 15 'password' => new sfValidatorString(), 16 'remember' => new sfValidatorBoolean(), 15 17 )); 16 18 plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardUserForm.class.php
r7745 r12075 10 10 class sfGuardUserForm extends BasesfGuardUserForm 11 11 { 12 protected 13 $pkName = null; 14 12 15 public function configure() 13 16 { 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 } 14 120 } 15 121 } plugins/sfGuardPlugin/branches/1.2/lib/model/plugin/PluginsfGuardGroupPeer.php
r7634 r12075 25 25 return self::doSelectOne($c); 26 26 } 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'; 27 38 } plugins/sfGuardPlugin/branches/1.2/lib/model/plugin/PluginsfGuardUser.php
r11426 r12075 58 58 public function checkPassword($password) 59 59 { 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')) 61 74 { 62 75 return call_user_func_array($callable, array($this->getUsername(), $password, $this)); plugins/sfGuardPlugin/branches/1.2/lib/task/sfGuardCreateAdminTask.class.php
r8637 r12075 62 62 } 63 63 64 $user->setIsSuperAdmin(true); 65 $user->save(); 66 64 67 $this->logSection('guard', sprintf('Promote user %s as a super administrator', $arguments['username'])); 65 68 } plugins/sfGuardPlugin/branches/1.2/lib/user/sfGuardSecurityUser.class.php
r9999 r12075 18 18 class sfGuardSecurityUser extends sfBasicSecurityUser 19 19 { 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 } 21 34 22 35 public function getReferer($default) … … 25 38 $this->getAttributeHolder()->remove('referer'); 26 39 27 return $referer ;40 return $referer ? $referer : $default; 28 41 } 29 42 30 43 public function setReferer($referer) 31 44 { 32 if (!$this->hasAttribute('referer')) 33 { 34 $this->setAttribute('referer', $referer); 35 } 45 $this->setAttribute('referer', $referer); 36 46 } 37 47 plugins/sfGuardPlugin/branches/1.2/lib/validator/sfGuardValidatorUser.class.php
r7904 r12075 22 22 $this->addOption('username_field', 'username'); 23 23 $this->addOption('password_field', 'password'); 24 $this->addOption('rememeber_checkbox', 'remember'); 24 25 $this->addOption('throw_global_error', false); 25 26 … … 31 32 $username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : ''; 32 33 $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')] : ''; 33 35 34 36 // user exists? plugins/sfGuardPlugin/branches/1.2/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php
r8892 r12075 26 26 } 27 27 28 $this->form = new sfGuardFormSignin(); 28 $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin'); 29 $this->form = new $class(); 29 30 30 31 if ($request->isMethod('post')) … … 34 35 { 35 36 $values = $this->form->getValues(); 36 $this->getUser()->signin($values['user'] );37 $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false); 37 38 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')); 39 43 40 return $this->redirect( '' != $signinUrl ? $signinUrl : '@homepage');44 return $this->redirect($signinUrl); 41 45 } 42 46 } … … 51 55 } 52 56 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()); 54 60 55 61 $module = sfConfig::get('sf_login_module'); … … 67 73 $this->getUser()->signOut(); 68 74 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()); 70 76 71 $this->redirect('' != $signout _url ? $signout_url : '@homepage');77 $this->redirect('' != $signoutUrl ? $signoutUrl : '@homepage'); 72 78 } 73 79 plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/config/generator.yml
r9999 r12075 11 11 title: User list 12 12 display: [ =username, created_at, last_login ] 13 filters: [ username ]13 filters: [ username, _groups ] 14 14 15 15 edit: plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/lib/BasesfGuardUserActions.class.php
r7634 r12075 32 32 return true; 33 33 } 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 34 94 } plugins/sfGuardPlugin/branches/1.2/package.xml
r9999 r12075 27 27 <user>fzaninotto</user> 28 28 <email>francois.zaninotto@symfony-project.com</email> 29 <active> yes</active>29 <active>no</active> 30 30 </developer> 31 <date>2008- 05-26</date>31 <date>2008-10-08</date> 32 32 <version> 33 <release> 2.1.0</release>33 <release>3.0.0</release> 34 34 <api>1.1.0</api> 35 35 </version> … … 112 112 <file role="data" name="sfGuardCreateAdminTask.class.php" /> 113 113 <file role="data" name="sfGuardCreateUserTask.class.php" /> 114 <file role="data" name="sfGuardAddPermissionTask.class.php" /> 115 <file role="data" name="sfGuardAddGroupTask.class.php" /> 114 116 </dir> 115 117 … … 146 148 <file role="data" name="templates/_password.php" /> 147 149 <file role="data" name="templates/_password_bis.php" /> 150 <file role="data" name="templates/_groups.php" /> 148 151 <file role="data" name="validate/edit.yml" /> 149 152 </dir> … … 173 176 </phprelease> 174 177 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> 177 196 </package>