Allows users of a site protected by sfGuardPlugin to create new accounts, verifying them by email. Both account creation and password changes require email verification as a speed bump to slow down spammers.

sfApplyPlugin allows users to apply for accounts. Users are required to confirm their account applications via email. Users can also reset their passwords, which also requires email verification. sfApplyPlugin also provides a starting point for managing user profile settings such as the user's full name, which is requested to increase the chances that confirmation emails will not be filtered as spam. sfApplyPlugin requires sfGuardPlugin and Propel. The current version is appropriate for Symfony 1.0 and Propel, however a forthcoming release will support 1.2 and Doctrine.

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.

Changelog for release 0.5.3 - 06/12/2008

Other releases

Release 0.6.3 - 25/12/2008

Release 0.6.2 - 08/12/2008

Release 0.5.3 - 06/12/2008

sfApply plugin

Most public sites have similar needs where user registration is
concerned. In order to slow down spam a little bit and get a grip
on who's doing what, you want users to apply for accounts and
confirm them by clicking on a link in an email message.

Symfony's sfGuardPlugin does a fine job managing the accounts you
already have but doesn't provide a built-way for users to apply for and
create accounts. sfApply adds that capability.

sfApplyPlugin also implements a password reset feature that works
correctly and also requires users to confirm via email. This prevents a
user who has discovered a momentarily unattended PC from
taking over the account too easily.

Requirements

You need:

sfGuardPlugin

Propel

A Symfony 1.2-plus-Doctrine version of this plugin will
follow shortly.

Installation

Read the sfGuardPlugin documentation first! Set up that plugin before
continuing.

Note that sfApplyPlugin takes advantage of the "user profile"
functionality offered by sfGuardPlugin as a place to store
additional information. While sfGuardPlugin makes the name of the
profile class configurable, sfApplyPlugin simply uses the
default name (sfGuardUserProfile) for simplicity.

"But where do I put my own additional fields?" That's why I didn't
build sfGuardUserProfile's schema directly into the plugin. Just
add your additional fields after the full name field.

"Shouldn't there be yet another profile class for my stuff?" In theory,
that might be nice. In practice, before you know it you'll be joining
28 tables every time someone accesses the page. Paste this one
snippet of code just once instead.

You will also want to add the following routes to your config/routing.yml.
The URLs are just suggestions, you can change them if you don't like them.
Note that this plugin provides a working solution for users who have
forgotten their passwords. Mapping the sf_guard_password route to
sfApply/reset-request allows the "forgot your password?" link in
the default sfGuardPlugin login form to work.

If you have enabled the built-in routes in sfGuardPlugin,
then overriding sf_guard_password here might not work. You can
fix that by copying sfGuardPlugin/modules/sfGuardAuth/templates/loginSuccess.php
to your application and editing the "forgot your password?" link to
point to sfApply/resetRequest instead.

Activate the sfApply module in your application's
settings.yml file:

enabled_modules: [default, sfGuardAuth, sfApply]

Note that you also need the sfGuardAuth module to enable logins.

Now you can easily add a button to your pages sending users to
sfApply/apply to request accounts:

echo button_to("Create Account", "sfApply/apply");

You will almost certainly also want to copy
sfGuardPlugin's modules/sfGuardAuth/templates/signinSuccess.php to
your own application's modules folder and add a "Create Account"
link to it, so that users understand they can make accounts
of their own at what would otherwise be the most frustrating point
in your application.

Customizing Emails

sfApply sends out email messages inviting users to verify their
accounts or reset their passwords. You can customize these by
copying modules/sfApply/templates/sendValidateNew.php and
modules/sfApply/templates/sendValidateReset.php from the plugin to
your application and editing them. The default emails aren't
that bad; they do contain the name of your site. But you really ought
to customize these so that users get a warm, fuzzy, personal sense that the
messages are not spam.

If you want to send HTML emails, you should create separate
plaintext versions named sendValidateNew.altbody.php and
sendValidateReset.altbody.php for plain text. When Symfony sees these,
it will automatically expect HTML in sendValdiateNew.php and
sendValidateReset.php.

This approach to email is not supported in Symfony 1.2. I'll be
looking at alternate solutions for 1.2.

Extending sfApply

"But I need the user's birthdate!" Of course you do. Every application
needs something extra. Here's how to go about it:

Add your extra fields to sfGuardUserProfile in your
schema.yml.

Create a modules/sfApply/templates folder in your application.

Copy my applySuccess.php and settingsSuccess.php files over.

Add the form fields you need for your additional information
to those templates.

Copy sfApplyPlugin/modules/sfApply/actions/actions.class.php to
your own modules/sfApply/actions folder. Notice that this class is
initially empty. That's because it inherits its default
behavior from
sfApplyPlugin/modules/sfApply/lib/BasesfApplyActions.class.php.

Extend the populateProfileSettings method to save
additional information to the profile when an account
is first created:

Extend updateProfileSettings in exactly the same way. The
difference is that updateProfileSettings is called when the
user edits their settings later, while populateProfileSettings
is called only the first time. If your needs in both situations
are similar, I suggest that you keep the shared code in a private method
that you call from both.

Optionally override validateApply and validateSettings as well.
Again, be sure to call the parent class versions before
returning and return false if the parent class version
returns false.