Development

Changeset 12896

You must first sign up to be able to contribute.

Changeset 12896

Show
Ignore:
Timestamp:
11/10/08 20:02:34 (5 years ago)
Author:
fabien
Message:

[sfGuardPlugin] [1.2] updated admin generator

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfGuardPlugin/branches/1.2/config/config.php

    r7636 r12896  
    55  $this->dispatcher->connect('routing.load_configuration', array('sfGuardRouting', 'listenToRoutingLoadConfigurationEvent')); 
    66} 
     7 
     8foreach (array('sfGuardUser', 'sfGuardGroup', 'sfGuardPermission') as $module) 
     9{ 
     10  if (in_array($module, sfConfig::get('sf_enabled_modules'))) 
     11  { 
     12    $this->dispatcher->connect('routing.load_configuration', array('sfGuardRouting', 'addRouteForAdmin'.str_replace('sfGuard', '', $module))); 
     13  } 
     14} 
  • plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardGroupForm.class.php

    r7745 r12896  
    1212  public function configure() 
    1313  { 
     14    unset($this['sf_guard_user_group_list']); 
     15 
     16    $this->widgetSchema['sf_guard_group_permission_list']->setLabel('Permissions'); 
    1417  } 
    1518} 
  • plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardPermissionForm.class.php

    r7745 r12896  
    1212  public function configure() 
    1313  { 
     14    unset($this['sf_guard_user_permission_list']); 
     15 
     16    $this->widgetSchema['sf_guard_group_permission_list']->setLabel('Groups'); 
    1417  } 
    1518} 
  • plugins/sfGuardPlugin/branches/1.2/lib/form/sfGuardUserForm.class.php

    r12075 r12896  
    88 * @version    SVN: $Id$ 
    99 */ 
    10 class sfGuardUserForm extends BasesfGuardUserForm 
     10class sfGuardUserForm extends BasesfGuardUserAdminForm 
    1111{ 
    1212  protected 
     
    2525      $this['sf_guard_user_permission_list'] 
    2626    ); 
    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     } 
    12027  } 
    12128} 
  • plugins/sfGuardPlugin/branches/1.2/lib/sfGuardRouting.class.php

    r12071 r12896  
    3232    $r->prependRoute('sf_guard_password', new sfRoute('/request_password', array('module' => 'sfGuardAuth', 'action' => 'password'))); 
    3333  } 
     34 
     35  static public function addRouteForAdminUser(sfEvent $event) 
     36  { 
     37    $event->getSubject()->prependRoute('sf_guard_user', new sfPropelRouteCollection(array( 
     38      'name'                => 'sf_guard_user', 
     39      'model'               => 'sfGuardUser', 
     40      'module'              => 'sfGuardUser', 
     41      'prefix_path'         => 'sf_guard_user', 
     42      'with_wilcard_routes' => true, 
     43      'requirements'        => array(), 
     44    ))); 
     45  } 
     46 
     47  static public function addRouteForAdminGroup(sfEvent $event) 
     48  { 
     49    $event->getSubject()->prependRoute('sf_guard_group', new sfPropelRouteCollection(array( 
     50      'name'                => 'sf_guard_group', 
     51      'model'               => 'sfGuardGroup', 
     52      'module'              => 'sfGuardGroup', 
     53      'prefix_path'         => 'sf_guard_group', 
     54      'with_wilcard_routes' => true, 
     55      'requirements'        => array(), 
     56    ))); 
     57  } 
     58 
     59  static public function addRouteForAdminPermission(sfEvent $event) 
     60  { 
     61    $event->getSubject()->prependRoute('sf_guard_permission', new sfPropelRouteCollection(array( 
     62      'name'                => 'sf_guard_permission', 
     63      'model'               => 'sfGuardPermission', 
     64      'module'              => 'sfGuardPermission', 
     65      'prefix_path'         => 'sf_guard_permission', 
     66      'with_wilcard_routes' => true, 
     67      'requirements'        => array(), 
     68    ))); 
     69  } 
    3470} 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardGroup/actions/actions.class.php

    r7634 r12896  
    11<?php 
    22 
    3 /* 
    4  * This file is part of the symfony package. 
    5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  * 
    7  * For the full copyright and license information, please view the LICENSE 
    8  * file that was distributed with this source code. 
    9  */ 
     3require_once dirname(__FILE__).'/../lib/sfGuardGroupGeneratorConfiguration.class.php'; 
     4require_once dirname(__FILE__).'/../lib/sfGuardGroupGeneratorHelper.class.php'; 
    105 
    116/** 
    12  * Group management
     7 * sfGuardGroup actions
    138 * 
    14  * @package    symfony 
    15  * @subpackage plugin 
    16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     9 * @package    sfGuardPlugin 
     10 * @subpackage sfGuardGroup 
     11 * @author     Fabien Potencier 
    1712 * @version    SVN: $Id$ 
    1813 */ 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardGroup/config/generator.yml

    r7634 r12896  
    11generator: 
    2   class:              sfPropelAdminGenerator 
     2  class: sfPropelGenerator 
    33  param: 
    4     model_class:      sfGuardGroup 
    5     theme:            default 
     4    model_class:           sfGuardGroup 
     5    theme:                 admin 
     6    non_verbose_templates: true 
     7    with_show:             false 
     8    singular:              ~ 
     9    plural:                ~ 
     10    route_prefix:          sf_guard_group 
     11    with_propel_route:     1 
    612 
    7     list
    8       title: Group list 
    9       display:        [=name, description] 
     13    config
     14      list: 
     15        title: Group list 
    1016 
    11     edit: 
    12       title:        Edit "%%name%%" group 
    13       fields: 
    14         permissions:  { type: admin_double_list, params: through_class=sfGuardGroupPermission } 
    15       display:        [ name, description, permissions ] 
     17      edit: 
     18        title: Editing Group "%%name%%" 
     19 
     20      new: 
     21        title: New Group 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardPermission/actions/actions.class.php

    r7634 r12896  
    11<?php 
    22 
    3 /* 
    4 * This file is part of the symfony package. 
    5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6 
    7 * For the full copyright and license information, please view the LICENSE 
    8 * file that was distributed with this source code. 
    9 */ 
     3require_once dirname(__FILE__).'/../lib/sfGuardPermissionGeneratorConfiguration.class.php'; 
     4require_once dirname(__FILE__).'/../lib/sfGuardPermissionGeneratorHelper.class.php'; 
    105 
    116/** 
    12 * Permission management
    13 
    14 * @package    symfony 
    15 * @subpackage plugi
    16 * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
    17 * @version    SVN: $Id$ 
    18 */ 
     7 * sfGuardPermission actions
     8
     9 * @package    sfGuardPlugin 
     10 * @subpackage sfGuardPermissio
     11 * @author     Fabien Potencier 
     12 * @version    SVN: $Id$ 
     13 */ 
    1914class sfGuardPermissionActions extends autosfGuardPermissionActions 
    2015{ 
    21   protected function updatesfGuardPermissionFromRequest() 
    22   { 
    23     $sf_guard_permission = $this->getRequestParameter('sf_guard_permission'); 
    24  
    25     if (isset($sf_guard_permission['name'])) 
    26     { 
    27       $this->sf_guard_permission->setName($sf_guard_permission['name']); 
    28     } 
    29     if (isset($sf_guard_permission['description'])) 
    30     { 
    31       $this->sf_guard_permission->setDescription($sf_guard_permission['description']); 
    32     } 
    33     if (!empty($sf_guard_permission['module_name'])) 
    34     { 
    35       $this->sf_guard_permission->setModuleName($sf_guard_permission['module_name']); 
    36     } 
    37     if (!empty($sf_guard_permission['action_name'])) 
    38     { 
    39       $this->sf_guard_permission->setActionName($sf_guard_permission['action_name']); 
    40     } 
    41   } 
    4216} 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardPermission/config/generator.yml

    r7634 r12896  
    11generator: 
    2   class:              sfPropelAdminGenerator 
     2  class: sfPropelGenerator 
    33  param: 
    4     model_class:      sfGuardPermission 
    5     theme:            default 
     4    model_class:           sfGuardPermission 
     5    theme:                 admin 
     6    non_verbose_templates: true 
     7    with_show:             false 
     8    singular:              ~ 
     9    plural:                ~ 
     10    route_prefix:          sf_guard_permission 
     11    with_propel_route:     1 
    612 
    7     list
    8       title:          Permission list 
    9       display:        [=name, description] 
     13    config
     14      list: 
     15        title: Permission list 
    1016 
    11     edit: 
    12       title:          Edit "%%name%%" permission 
     17      edit: 
     18        title: Editing Permission "%%name%%" 
     19 
     20      new: 
     21        title: New Permission 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/actions/actions.class.php

    r7634 r12896  
    11<?php 
    22 
    3 /* 
    4  * This file is part of the symfony package. 
    5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  * 
    7  * For the full copyright and license information, please view the LICENSE 
    8  * file that was distributed with this source code. 
    9  */ 
    10  
    11 require_once(dirname(__FILE__).'/../lib/BasesfGuardUserActions.class.php'); 
     3require_once dirname(__FILE__).'/../lib/sfGuardUserGeneratorConfiguration.class.php'; 
     4require_once dirname(__FILE__).'/../lib/sfGuardUserGeneratorHelper.class.php'; 
    125 
    136/** 
    14  * User management
     7 * sfGuardUser actions
    158 * 
    16  * @package    symfony 
    17  * @subpackage plugin 
    18  * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
     9 * @package    sfGuardPlugin 
     10 * @subpackage sfGuardUser 
     11 * @author     Fabien Potencier 
    1912 * @version    SVN: $Id$ 
    2013 */ 
    21 class sfGuardUserActions extends BasesfGuardUserActions 
     14class sfGuardUserActions extends autoSfGuardUserActions 
    2215{ 
    2316} 
  • plugins/sfGuardPlugin/branches/1.2/modules/sfGuardUser/config/generator.yml

    r12075 r12896  
    11generator: 
    2   class:              sfPropelAdminGenerator 
     2  class: sfPropelGenerator 
    33  param: 
    4     model_class:      sfGuardUser 
    5     theme:            default 
     4    model_class:           sfGuardUser 
     5    theme:                 admin 
     6    non_verbose_templates: true 
     7    with_show:             false 
     8    singular:              ~ 
     9    plural:                ~ 
     10    route_prefix:          sf_guard_user 
     11    with_propel_route:     1 
    612 
    7     fields: 
    8       password_bis: { name: "Password (again)" } 
     13    config: 
     14      fields: 
     15        password_again: { label: "Password (again)" } 
    916 
    10     list: 
    11       title:   User list 
    12       display: [ =username, created_at, last_login ] 
    13       filters: [ username, _groups ] 
     17      list: 
     18        title:   User list 
     19        display: [=username, created_at, last_login] 
    1420 
    15     edit: 
    16       title: Edit "%%username%%" user 
    17       fields: 
    18         password: 
    19         password_bis: 
    20         groups:       { name: Groups/Roles, type: admin_double_list, params: through_class=sfGuardUserGroup } 
    21         permissions:  { name: permissions, type: admin_check_list, params: through_class=sfGuardUserPermission } 
    22         last_login:   { type: plain } 
    23       display: 
    24         "NONE":                   [ username, _password, _password_bis ] 
    25         "Information":            [ last_login ] 
    26         "Permissions and groups": [ is_active, groups, permissions ] 
     21      form: 
     22        class: sfGuardUserAdminForm 
     23        display: 
     24          "NONE":                   [username, password, password_again] 
     25          "Permissions and groups": [is_active, is_super_admin, sf_guard_user_group_list, sf_guard_user_permission_list] 
     26 
     27      edit: 
     28        title: Editing User "%%username%%" 
     29 
     30      new: 
     31        title: New User