![]() |
|
sfDoctrineUserPlugin - 1.2.4Stephen Ostrow |
|
![]() |
3
users
Sign-in
to change your status |
Stephen Ostrow |
This plugin provides a starting point for anyone needing a quick full user in any application. It creates a user which has a sfGuardUser. This user then has the following properties.
| Name | Status | |
|---|---|---|
|
|
lead | moc.sngisedbewos <<ta>> wortsos |
The MIT License
Copyright (c) 2007-2008 Stephen Ostrow <sostrow@sowebdesigns.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
| Version | License | API | Released |
|---|---|---|---|
| 1.2.4stable | MIT license | 1.2.0stable | 06/03/2009 |
| 1.2.3beta | MIT license | 1.2.0beta | 04/03/2009 |
| 1.2.2stable | MIT license | 1.2.0stable | 22/02/2009 |
| 1.2.1stable | MIT license | 1.2.0stable | 22/02/2009 |
| 1.2.0beta | MIT license | 1.2.0beta | 09/02/2009 |
| Version | License | API | Released |
|---|---|---|---|
| 1.1.2beta | MIT | 1.1.0beta | 08/11/2008 |
| Version | License | API | Released |
|---|---|---|---|
| 1.0.1stable | MIT | 1.0.0stable | 09/11/2008 |
| 1.0.0stable | MIT | 1.0.0stable | 08/11/2008 |
Getting the correct symfony 1.1 dependency
Fixing a bug where when the sfGuardDoctrinePlugin was renamed to sfDoctrineGuardPlugin that the overriding of the sfGuardUser module did not work correctly. Making my own module for editing a guard user via ajax.
This is the initial plugin
This plugin provides a starting point for anyone needing a quick full user in any application. It creates a user which has a sfGuardUser. This user then has the following properties.
Gives an admin page to edit all properties of a user on one page in a clean fashion
For all options, execute the commands shown from the root of your project.
This means you'll get the files only and you'll not be able to update using subversion
svn export http://svn.symfony-project.com/plugins/sfDoctrineUserPlugin/branches/1.0 ./plugins/sfDoctrineUserPlugin
This means you'll get the files and will manually have to update using subversion
svn checkout http://svn.symfony-project.com/plugins/sfDoctrineUserPlugin/branches/1.0 ./plugins/sfDoctrineUserPlugin
If you are already using subversion for your project, and want to automatically include the latest version of this plugin on each svn update, the correct way to include the sfDoctrineUserPlugin repository is to define svn:externals. Go to your symfony project
svn propedit svn:externals plugins
in this file add a line containing
sfDoctrineUserPlugin http://svn.symfony-project.com/plugins/sfDoctrineUserPlugin/branches/1.0
Edit the applications myUser.class.php of any application you want to be able to access the extended users information
# /apps/%%APPLICATION%%/data/lib/myUser.class.php // Default line 3 class myUser extends sfBasicSecurityUser // New line 3 for user with sfDoctrineUserPlugin class myUser extends sfUserSecurityUser
The plugin comes with two fixture files for your use. In order to use them copy them from /sfDoctrineUserPlugin/data/fixtures/ to your projects fixture directory (/data/fixtures/). You should also remove the .sample extension from the file when copying it to your fixture directory.
The plugin contains a module for each object the model. Especially useful will be the modules for editing the object types such as sfUserAddressType which has the types of Address of the Address object may be. (ie. Home, Business, PO Box)
Update the settings.yml file of your backend application to enable the modules you would like to use
enabled_modules: [sfUserAddressType, sfUserCreditCardType, sfUserEmailAddressType, sfUserImAccountType, sfUserPhoneType, sfUserCountry, sfUserState, sfUserAddress, sfUserBilling, sfUserEmailAddress, sfUserImAccount, sfUserPhone, sfUserUser, sfUserAdvancedUser, sfUserSimpleUser ]
The plugin contains some forms which should be of help when using this plugin. One the forms, sfUserSimpleRegistrationForm gives you a form to use when registering a new user. It contains the User properties, the sfGuardUser properties, as well as one of each Object property for the user. To use it simply call it from your action
# /apps/frontend/registration/actions/actions.class.php class registrationActions extends sfActions { public function executeRegistration(sfWebRequest $request) { $this->form = new sfUserSimpleRegistrationForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('registration')); if ($this->form->isValid()) { $this->form->save(); ProjectConfiguration::getActive()->loadHelpers('Url'); $this->getUser()->setFlash('new_user_id', $this->form->getObject()->getId()); $this->redirect(url_for('@signup_thank_you')); } } } }
You could also extend this class if you did not want to ask the user for all the properties.. The example below does not have the need to ask for the instant messanging account
# /apps/frontend/registration/lib/form/myRegistrationForm.class.php class myRegistrationForm extends sfUserSimpleRegistrationForm { public function configure() { parent::configure(); unset($this['sf_user_im_account']); } } # /apps/frontend/registration/actions/actions.class.php class registrationActions extends sfActions { public function executeRegistration(sfWebRequest $request) { $this->form = new myRegistrationForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('registration')); if ($this->form->isValid()) { $this->form->save(); ProjectConfiguration::getActive()->loadHelpers('Url'); $this->getUser()->setFlash('new_user_id', $this->form->getObject()->getId()); $this->redirect(url_for('@signup_thank_you')); } } } }
By default the Doctrine Email Validator is more stict than the Symfony Email Validator. Therefore it is possible for an email to pass through the symfony email validator but throw an exception with the Doctrine Email Validator. If you would like to turn of mx record checking in the Doctrine Email Validator update you sfUserAddress class to look like the following
#/lib/model/doctrine/sfDoctrineUserPlugin/sfUserEmailAddress.class.php class sfUserEmailAddress extends PluginsfUserEmailAddress { public function setTableDefinition() { parent::setTableDefinition(); $this->hasColumn('address', 'string', 128, array('type' => 'string', 'length' => 128, 'email' => array('check_mx' => false))); } }
If you would like to add an additional field to sfUserUser it's as the above code. In the example below I add a gender field of type ENUM
#/lib/model/doctrine/sfDoctrineUserPlugin/sfUserUser.class.php class sfUserUser extends PluginsfUserUser { public function setTableDefinition() { parent::setTableDefinition(); $this->hasColumn('sex', 'enum', null, array('values' => array(0 => 'Male', 1 => 'Female'))); }
}
This is editing or creating a new user with the Simple User Module which just uses sfUserSimpleUserForm. It can be extended and used within your frontend application for registration very easily.

This is editing or creating a new user with the Advanced User Module which just uses sfUserAdminAdvancedUserForm which extends sfUserAdvancedUserForm. I've done this in order to display the plain text dates at the bottom which you probably wouldn't want in a frontend application.

