sfDoctrineUserPlugin
About
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.
- sfGuardUser
- Multiple Groups
- Multiple permissions
- username
- password
- sfUserUser
- Multiple Email Addresses
- Multiple Addresses
- Multiple Phone Numbers
- Multiple Instant Messaging Accounts
- Multiple Billing Records
Gives an admin page to edit all properties of a user on one page in a clean fashion
Dependencies
sfDoctrineGuardPlugin
Installation
For all options, execute the commands shown from the root of your project.
Single Export
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
Single Checkout
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
Automatic Checkout
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
Browse Source Code
sfDoctrineUserPlugin
To Use
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
Backend Modules
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 ]
Frontend Help
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'));
}
}
}
}