User

Summary
User
AuthorJaybill McCarthy
Licensehttp://communit.as/docs/license
See AlsoCts_Controller_Action_Abstract
Instance Methods
initInvoked automatically when an instance is created.
Actions
loginbounceAfter a user is logged in, they are redirected to this action.
cancelAllows a user to cancel their account.
indexDisplays a list of community members and a search form.
resetpasswordThis is step 2 of 2 in the process a user goes through to reset their password.
forgotpasswordThis is step 1 of 2 in the process a user goes through to reset their password.
postregisterThis action is called after a user has filled out the registration form and it has been processed.
profileDisplays the public profile of a user.
registerEither displays a registration form, or processes the registration form, depending on whether or not the Request is a GET or POST.
editEither displays an edit form to edit a given user, or processes the edit form, depending on whether or not the Request is a GET or POST.
deleteavatarAllows the currently authenticated user to delete their own avatar.
Private or Protected Methods
_getConfirmationUrlUsed in forgotpassword to generate a random secret code for the forgot password email.
_checkConfirmationUrlUsed in resetpassword to verify whether the email address and secret code match.

Author

Jaybill McCarthy

Instance Methods

init

function init()

Invoked automatically when an instance is created.  Initializes the current instance.  Also initializes the parent object (calls init() on the parent instance).

HTTP GET or POST Parameters

usernameThe username of the user upon which to act.  (optional)

Registry Values

full_name_lengthThe maximum number of characters allowed in a user’s full name.  Defaults to 50.
username_lengthThe maximum number of characters allowed in a username.  Default to 16.

Actions

loginbounce

function loginbounceAction()

After a user is logged in, they are redirected to this action.  It builds a URI with the supplied values and redirects the browser to that URI.

HTTP GET or POST Parameters

backtoTBD
usernameThe username of the person logging in.

cancel

function cancelAction()

Allows a user to cancel their account.  Either displays an input form or processes the input form depending on whether the HTTP Request is GET or POST.  After the cancellation form is processed, the browser is redirected to ‘/auth/logout’ (currently hardcoded).

HTTP POST Parameters (when processing)

deleteThis is a sort of boolean value whose possible values are ‘yes’ or anything else.  The user is only deleted if the value of del is ‘yes’.

Plugin Hooks

  • default_user_cancel_pre_delete (filter) - Occurs before a user removed from the system.
param delete_rowDo or do not delete the user’s row from the database.  Defaults to true (do delete the row).
param usernameThe username of the user to be deleted.  Defaults to the currently logged-in user.
  • default_user_cancel_post_delete (action) - Occurs after a user is removed from the system.

View Variables

pagetitleThe value to be displayed in the browser’s title bar.
userA user object for the user to be deleted.

index

function indexAction()

Displays a list of community members and a search form.

HTTP GET or POST Parameters

genderFor searching/filtering by gender.
max_ageFor searching/filtering by a maximum age selection.
min_ageFor searching/filtering by a minimum age selection.
pageThe index of the current page.
regionFor searching/filtering by region.
searchtermFor searching/filtering by keyword.  Database fields searched: username, full_name, and tags.
sortbyFor changing the sort order of search results.  Possible values: ‘updated’, ‘newest’, and ‘login’.  Default is ‘newest’.

Registry Values

users_per_pageThe number of users to show on each page.  Default is 30.

Plugin Hooks

  • default_user_index_users (filter) - Allows you to act upon the list of users before it is sent to the view.
param usersThe array of users to be displayed.
  • defaut_user_index_search (filter) - Allows you to act on the search criteria before searching
param whereclausesAn array of where clauses that will be passed to the search
param paramsa key/value array of search terms that came in on the request.

View Variables

agesAn array of ages (integers) from 13 to 70 (currently hardcoded).
countriesAn array of countries pulled from the database.
gendersAn array of key-value pairs consisting of a formal and informal names (currently hardcoded) for each gender and an ‘any’ option.
pagetitleThe HTML page title.
paramsAll params in the param arrays for filters get turned into view variables automatically.
regionsAn array of regions, typically consisting of continents (currently hardcoded).
signsAn array of astrological star signs generated with Cts_Common::GetSignArray.
usersAn array of users to display as a list of links.

resetpassword

function resetpasswordAction()

This is step 2 of 2 in the process a user goes through to reset their password.  Either displays an input form, or processes the form.  The only way to get to this page should be from a link in an automatically-generated email sent to the user (done in the forgotpassword action).  The _checkConfirmationUrl method is used to check if the incoming email address and secret code comprise a valid password reset request.  If there is an active authenticated session, the browser is redirected to ‘/user/edit’ (currently hardcoded).  Upon successfully resetting the password, the browser is redirected to ‘/user/postregister’ (currently hardcoded).

URL Parameters (when coming from the email)

codeThe randomly generated secret code contained in the email.
emailThe email address of the user trying to reset their password.

HTTP POST Parameters (for resetting the password)

codeThe randomly generated secret code contained in the email.
confirmThe new password a second time.
ctaspasswordThe new password.
emailThe email address of the user trying to reset their password.

View Variables

$codeThe randomly generated secret code contained in the email.
$emailThe email address of the user trying to reset their password.

See Also

forgotpassword

function forgotpasswordAction()

This is step 1 of 2 in the process a user goes through to reset their password.  Either displays an input form, or processes the form, depending on whether the HTTP Request is GET or POST.  Uses _getConfirmationUrl to build a return URL for the email complete with a random secret code.  If there is an active authenticated session, the browser is redirected to the logged-in user’s profile (currently hardcoded).

HTTP POST Parameters

usernameThe username of the user trying to reset their password.
emailThe email address of the user trying to reset their password.

View Variables

$emailThe user’s email address.  Only sent to the view if there are errors.
$errorsAn array of error messages.  Only sent to the view if there are errors.
$pagetitleThe HTML title for the page.
$showFormA boolean to determine whether to show the input form or not.
$successA string containing a message to display upon success (currently hardcoded).
$usernameThe user’s username.  Only sent to the view if there are errors.

See Also

postregister

function postregisterAction()

This action is called after a user has filled out the registration form and it has been processed.  It’s useful for changing the redirect action or tweaking session values.

Plugin Hooks

  • default_index_postregister_redirect (filter) - Allows you to change the URI to which the browser is redirected after a user registers.  The default is ‘/user/edit’.
param redirect_urlThe desired redirect URL.
param sessionThe session object for the currently authenticated user session.

profile

function profileAction()

Displays the public profile of a user.  Uses the _user local variable set up in init.  If the username is invalid, the browser is redirected to ‘/auth/missing’ (currently hardcoded).

Plugin Hooks

  • default_user_profile (filter) - Allows you to affect the user object before displaying it.  This is usually used for adding attributes to a user.
param userThe user object for the specified user
param requestThe current HTTP Request (as a Zend_Request).

View Variables

$paramsAll params in the param arrays for filters get turned into view variables automatically.

See Also

register

function registerAction()

Either displays a registration form, or processes the registration form, depending on whether or not the Request is a GET or POST.  If there is an active authenticated session, the browser is redirected to the authenticated user’s profile (currently hardcoded).  After a successful registration, the browser is redirected to ‘/user/postregister’ (currently hardcoded).

HTTP POST Parameters

usernameThe desired username of the registering user.
emailThe email address of the registering user.
passwordThe desired password of the registering user.
confirmThe confirmation of the desired password of the registering user.
Birthday_DayThe day of the registering user’s birth date.
Birthday_MonthThe month of the registering user’s birth date.
Birthday_YearThe year of the registering user’s birth date.

Plugin Hooks

  • default_user_register (filter) - Allows you to affect the user object before it is committed to the database.
param requestThe current HTTP Request (as a Zend_Request).
param userThe user object for the registering user.
param errorsAn array of errors that will be displayed if not empty.
  • default_user_register_post_register (action) - Allows you to perform custom processing after a successful registration has occurred and before the browser is redirected.
param usernameThe username of the just-registered user.

View Variables

$errorsAn array of errors.  Only sent if errors are present.
$pagetitleThe HTML page title.
$userA user object for a successfully registered user.

edit

function editAction()

Either displays an edit form to edit a given user, or processes the edit form, depending on whether or not the Request is a GET or POST.  If the username passed in does not match the currently authenticated user, the browser is redirected to ‘/auth/missing’ (currently hardcoded).

Plugin Hooks

  • default_user_edit_pre_render (filter) - For a GET Request, this enables you to affect the user object before the initial form is displayed.
param userThe user object for the username in the GET Request parameters.
param requestThe entire Request object.
param sessionThe entire Session object.
  • default_user_edit_pre_save (filter) - Enables you to affect the user object before it is committed to the database.
param requestThe current HTTP Request (as a Zend_Request).
param userThe user object for the user being edited.
param errorsAn array of errors that will be displayed if not empty.
  • default_user_edit_post_save (action) - Enables you to perform an action after the user has been committed to the database.
param usernameThe username of the user being edited.

View Variables

$countriesAn array of countries pulled from the database.
$end_yearTBD
$gendersAn array of genders.
$paramsAll params in the param arrays for filters get turned into view variables automatically.

deleteavatar

function deleteavatarAction()

Allows the currently authenticated user to delete their own avatar.  If the username passed as a parameter doesn’t match the currently authenticated user, the browser is redirected to ‘/auth/missing’ (currently hardcoded).  After deleting the avatar image file, the user’s image cache is cleared so the image does not persist.  Whether successful or not, the browser is redirected to the referring page.

Private or Protected Methods

_getConfirmationUrl

protected function _getConfirmationUrl($email,  
$url =  "/user/resetpassword/email/")

Used in forgotpassword to generate a random secret code for the forgot password email.  MD5 encryption is used.

Arguments

$emailThe email address for which to create a secret validation code.
$urlThe URL to link to from the email.

Registry Values

saltA secret number used to aid in encryption and decryption.  Default is a randomly generated number.
site_urlThe URL of the website.  Default is ‘http://localhost’.

Returns

A string containing just the newly generated secret code.

_checkConfirmationUrl

protected function _checkConfirmationUrl($email,
$code)

Used in resetpassword to verify whether the email address and secret code match.  MD5 decryption is used.

Arguments

$emailThe email address to validate.
$codeThe secret code to validate.

Registry Values

saltA secret number used to aid in encryption and decryption.

Returns

A boolean (true or false).

function init()
Invoked automatically when an instance is created.
function loginbounceAction()
After a user is logged in, they are redirected to this action.
function cancelAction()
Allows a user to cancel their account.
function indexAction()
Displays a list of community members and a search form.
function resetpasswordAction()
This is step 2 of 2 in the process a user goes through to reset their password.
function forgotpasswordAction()
This is step 1 of 2 in the process a user goes through to reset their password.
function postregisterAction()
This action is called after a user has filled out the registration form and it has been processed.
function profileAction()
Displays the public profile of a user.
function registerAction()
Either displays a registration form, or processes the registration form, depending on whether or not the Request is a GET or POST.
function editAction()
Either displays an edit form to edit a given user, or processes the edit form, depending on whether or not the Request is a GET or POST.
function deleteavatarAction()
Allows the currently authenticated user to delete their own avatar.
protected function _getConfirmationUrl($email,  
$url =  "/user/resetpassword/email/")
Used in forgotpassword to generate a random secret code for the forgot password email.
protected function _checkConfirmationUrl($email,
$code)
Used in resetpassword to verify whether the email address and secret code match.
Close