Version: current

# Class Member

The member class which represents the users of the system

  Object
  ViewableData implements IteratorAggregate
  DataObject implements DataObjectInterface, i18nEntityProvider
  Member

Package: sapphire\security
Located at sapphire/security/Member.php

## Methods summary

`public` | # `populateDefaults( )` Ensure the locale is set to something sensible by default. Ensure the locale is set to something sensible by default. #### Overrides `DataObject::populateDefaults`
`public` | # `requireDefaultRecords( )` Add default records to database. This function is called whenever the database is built, after the database tables have all been created. Overload this to add default records when the database is built, but make sure you call parent::requireDefaultRecords(). Add default records to database. This function is called whenever the database is built, after the database tables have all been created. Overload this to add default records when the database is built, but make sure you call parent::requireDefaultRecords(). #### Uses ``DataObjectDecorator::requireDefaultRecords()`` #### Overrides `DataObject::requireDefaultRecords`
`public static` | # `set_login_marker_cookie( mixed $cookieName )` If this is called, then a session cookie will be set to "1" whenever a user logs in. This lets 3rd party tools, such as apache's mod_rewrite, detect whether a user is logged in or not and alter behaviour accordingly. If this is called, then a session cookie will be set to "1" whenever a user logs in. This lets 3rd party tools, such as apache's mod_rewrite, detect whether a user is logged in or not and alter behaviour accordingly. One known use of this is to bypass static caching for logged in users. This is done by putting this into _config.php
    Member::set_login_marker_cookie("SS_LOGGED_IN");
And then adding this condition to each of the rewrite rules that make use of the static cache.
    RewriteCond %{HTTP_COOKIE} !SS_LOGGED_IN=1
#### Parameters $cookieName $cookieName string The name of the cookie to set.
`public `ValidationResult`` | # `checkPassword( string $password )` Check if the passed password matches the stored one (if the member is not locked out). Check if the passed password matches the stored one (if the member is not locked out). #### Parameters $password string $password #### Returns ``ValidationResult`` ValidationResult
`public `ValidationResult`` | # `canLogIn( )` Returns a valid `ValidationResult` if this member can currently log in, or an invalid one with error messages to display if the member is locked out. Returns a valid `ValidationResult` if this member can currently log in, or an invalid one with error messages to display if the member is locked out. You can hook into this with a "canLogIn" method on an attached extension. #### Returns ``ValidationResult`` ValidationResult
`public` | # `isLockedOut( )` Returns true if this user is locked out Returns true if this user is locked out
`public static` | # `session_regenerate_id( )` Regenerate the session_id. This wrapper is here to make it easier to disable calls to session_regenerate_id(), should you need to. They have caused problems in certain quirky problems (such as using the Windmill 0.3.6 proxy). Regenerate the session_id. This wrapper is here to make it easier to disable calls to session_regenerate_id(), should you need to. They have caused problems in certain quirky problems (such as using the Windmill 0.3.6 proxy).
`public static string` | # `get_unique_identifier_field( )` Get the field used for uniquely identifying a member in the database. `Member::$unique_identifier_field` Get the field used for uniquely identifying a member in the database. `Member::$unique_identifier_field` #### Returns `string` string
`public static` | # `set_unique_identifier_field( mixed $field )` Set the field used for uniquely identifying a member in the database. `Member::$unique_identifier_field` Set the field used for uniquely identifying a member in the database. `Member::$unique_identifier_field` #### Parameters $field $field The field name to set as the unique field
`public static` | # `set_password_validator( mixed $pv )` Set a `PasswordValidator` object to use to validate member's passwords. Set a `PasswordValidator` object to use to validate member's passwords.
`public static` | # `password_validator( )` Returns the current `PasswordValidator` Returns the current `PasswordValidator`
`public static` | # `set_password_expiry( mixed $days )` Set the number of days that a password should be valid for. Set to null (the default) to have passwords never expire. Set the number of days that a password should be valid for. Set to null (the default) to have passwords never expire.
`public static` | # `lock_out_after_incorrect_logins( mixed $numLogins )` Configure the security system to lock users out after this many incorrect logins Configure the security system to lock users out after this many incorrect logins
`public` | # `isPasswordExpired( )`
`public` | # `logIn( boolean $remember = false )` Logs this member in Logs this member in #### Parameters $remember bool $remember If set to TRUE, the member will be logged in automatically the next time.
`public static boolean` | # `logged_in_session_exists( )` Check if the member ID logged in session actually has a database record of the same ID. If there is no logged in user, FALSE is returned anyway. Check if the member ID logged in session actually has a database record of the same ID. If there is no logged in user, FALSE is returned anyway. #### Returns `boolean` TRUE record found FALSE no record found
`public static` | # `autoLogin( )` Log the user in if the "remember login" cookie is set Log the user in if the "remember login" cookie is set The remember login token will be changed on every successful auto-login.
`public` | # `logOut( )` Logs this member out. Logs this member out.
`public` | # `generateAutologinHash( integer $lifetime = 2 )` Generate an auto login hash Generate an auto login hash This creates an auto login hash that can be used to reset the password. #### Parameters $lifetime int $lifetime The lifetime of the auto login hash in days (by default 2 days)
`public static` | # `member_from_autologinhash( boolean $RAW_hash, mixed $login = false )` Return the member for the auto login hash Return the member for the auto login hash #### Parameters $RAW_hash bool $login Should the member be logged in? $login
`public` | # `sendInfo( string $type = 'signup', array $data = null )` Send signup, change password or forgot password informations to an user Send signup, change password or forgot password informations to an user #### Parameters $type string $type Information type to send ("signup", "changePassword" or "forgotPassword") $data array $data Additional data to pass to the email (can be used in the template)
`public `FieldSet`` | # `getMemberFormFields( boolean $newUser = false )` Returns the fields for the member form - used in the registration/profile module. It should return fields that are editable by the admin and the logged-in user. Returns the fields for the member form - used in the registration/profile module. It should return fields that are editable by the admin and the logged-in user. #### Parameters $newUser bool $newUser - new user flag (for registration) #### Returns ``FieldSet`` Returns a `FieldSet` containing the fields for the member form.
`public` | # `getValidator( )`
`public static boolean|`Member`` | # `currentUser( )` Returns the current logged in user Returns the current logged in user #### Returns `boolean|`Member`` Returns the member object of the current logged in user or FALSE.
`public static integer` | # `currentUserID( )` Get the ID of the current logged in user Get the ID of the current logged in user #### Returns `integer` Returns the ID of the current logged in user or 0.
`public static` | # `create_new_password( )`
`public` | # `onBeforeWrite( )` Event handler called before writing to the database. Event handler called before writing to the database. #### Overrides `DataObject::onBeforeWrite`
`public` | # `onAfterWrite( )` Event handler called after writing to the database. You can overload this to act upon changes made to the data after it is written. $this->changed will have a record database. Don't forget to call parent::onAfterWrite(), though! Event handler called after writing to the database. You can overload this to act upon changes made to the data after it is written. $this->changed will have a record database. Don't forget to call parent::onAfterWrite(), though! #### Uses ``DataObjectDecorator::onAfterWrite()`` #### Overrides `DataObject::onAfterWrite`
`public boolean` | # `inGroups( array|`DataObjectSet` $groups, boolean $strict = false )` Check if the member is in one of the given groups. Check if the member is in one of the given groups. #### Parameters $groups array|DataObjectSet $groups Collection of `Group` DataObjects to check $strict boolean $strict Only determine direct group membership if set to true (Default: false) #### Returns `boolean` Returns TRUE if the member is in one of the given groups, otherwise FALSE.
`public boolean` | # `inGroup( integer|`Group`|string $group, boolean $strict = false )` Check if the member is in the given group or any parent groups. Check if the member is in the given group or any parent groups. #### Parameters $group int|Group|string $group Group instance, Group Code or ID $strict boolean $strict Only determine direct group membership if set to TRUE (Default: FALSE) #### Returns `boolean` Returns TRUE if the member is in the given group, otherwise FALSE.
`public Returns` | # `isAdmin( )` Returns true if this user is an administrator. Administrators have access to everything. Returns true if this user is an administrator. Administrators have access to everything. #### Deprecated Use Permission::check('ADMIN') instead #### Returns `Returns` TRUE if this user is an administrator.
`public String` | # `EditProfileLink( )` Edit Profile Link Edit Profile Link #### Returns `String` String
`public static` | # `set_title_columns( Array $columns, String $sep = ' ' )` #### Parameters $columns Array $columns Column names on the Member record to show in `Member::getTitle()`. $sep String $sep Separator
`public string` | # `getTitle( )` Get the complete name of the member, by default in the format "<Surname>, <FirstName>". Falls back to showing either field on its own. Get the complete name of the member, by default in the format "<Surname>, <FirstName>". Falls back to showing either field on its own. You can overload this getter with set_title_format() and set_title_sql(). #### Returns `string` Returns the first- and surname of the member. If the ID of the member is equal 0, only the surname is returned. #### Overrides `DataObject::getTitle`
`public static String` | # `get_title_sql( String $tableName = 'Member' )` Return a SQL CONCAT() fragment suitable for a SELECT statement. Useful for custom queries which assume a certain member title format. Return a SQL CONCAT() fragment suitable for a SELECT statement. Useful for custom queries which assume a certain member title format. #### Parameters $tableName String $tableName #### Returns `String` SQL
`public string` | # `getName( )` Get the complete name of the member Get the complete name of the member #### Returns `string` Returns the first- and surname of the member.
`public` | # `setName( string $name )` Set first- and surname Set first- and surname This method assumes that the last part of the name is the surname, e.g. A B C will result in firstname A B and surname C #### Parameters $name string $name The name
`public` | # `splitName( string $name )` Alias for `Member::setName()` Alias for `Member::setName()` #### Parameters $name string $name The name #### See ``Member::setName()``
`public `Member_GroupSet`` | # `Groups( )` Get a "many-to-many" map that holds for all members their group memberships Get a "many-to-many" map that holds for all members their group memberships #### Returns ``Member_GroupSet`` Returns a map holding for all members their group memberships.
`public `SQLMap`` | # `map( string $filter = "", string $sort = "", string $blank = "" )` Get member SQLMap Get member SQLMap #### Parameters $filter string $filter Filter for the SQL statement (WHERE clause) $sort string $sort Sorting function (ORDER clause) $blank string $blank Shift a blank member in the items #### Returns ``SQLMap`` Returns an SQLMap that returns all Member data.
`public static `SQLMap`` | # `mapInGroups( mixed $groups = null )` Get a member SQLMap of members in specific groups Get a member SQLMap of members in specific groups #### Parameters $groups mixed $groups Optional groups to include in the map. If NULL is passed, all groups are returned, i.e. `Member::map()` will be called. #### Returns ``SQLMap`` Returns an SQLMap that returns all Member data. #### See ``Member::map()``
`public static `SQLMap`` | # `mapInCMSGroups( array $groups = null )` Get a map of all members in the groups given that have CMS permissions Get a map of all members in the groups given that have CMS permissions If no groups are passed, all groups with CMS permissions will be used. #### Parameters $groups array $groups Groups to consider or NULL to use all groups with CMS permissions. #### Returns ``SQLMap`` Returns a map of all members in the groups given that have CMS permissions.
`public array` | # `memberNotInGroups( array $groupList, array $memberGroups = null )` Get the groups in which the member is NOT in Get the groups in which the member is NOT in When passed an array of groups, and a component set of groups, this function will return the array of groups the member is NOT in. #### Parameters $groupList array $groupList An array of group code names. $memberGroups array $memberGroups A component set of groups (if set to NULL, $this->groups() will be used) #### Returns `array` Groups in which the member is NOT in.
`public `FieldSet`` | # `getCMSFields( )` Return a `FieldSet` of fields that would appropriate for editing this member. Return a `FieldSet` of fields that would appropriate for editing this member. #### Returns ``FieldSet`` Return a FieldSet of fields that would appropriate for editing this member. #### Overrides `DataObject::getCMSFields`
`public array|string` | # `fieldLabels( boolean $includerelations = true )` #### Parameters $includerelations boolean $includerelations a boolean value to indicate if the labels returned include relation fields #### Returns `array|string` Array of all element labels if no argument given, otherwise the label of the field #### Overrides `DataObject::fieldLabels`
`public boolean` | # `canView( `Member` $member = null )` Users can view their own record. Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions. This is likely to be customized for social sites etc. with a looser permission model. Users can view their own record. Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions. This is likely to be customized for social sites etc. with a looser permission model. #### Parameters $member Member $member #### Returns `boolean` boolean #### Overrides `DataObject::canView`
`public boolean` | # `canEdit( `Member` $member = null )` Users can edit their own record. Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions Users can edit their own record. Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions #### Parameters $member Member $member #### Returns `boolean` boolean #### Overrides `DataObject::canEdit`
`public boolean` | # `canDelete( `Member` $member = null )` Users can edit their own record. Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions Users can edit their own record. Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions #### Parameters $member Member $member #### Returns `boolean` boolean #### Overrides `DataObject::canDelete`
`public A` | # `validate( )` Validate this member object. Validate this member object. #### Returns `A` `ValidationResult` object #### Overrides `DataObject::validate`
`public` | # `changePassword( String $password )` Change password. This will cause rehashing according to the `PasswordEncryption` property. Change password. This will cause rehashing according to the `PasswordEncryption` property. #### Parameters $password String $password Cleartext password
`public` | # `registerFailedLogin( )` Tell this member that someone made a failed attempt at logging in as them. This can be used to lock the user out temporarily if too many failed attempts are made. Tell this member that someone made a failed attempt at logging in as them. This can be used to lock the user out temporarily if too many failed attempts are made.
`public string` | # `getHtmlEditorConfigForCMS( )` Get the HtmlEditorConfig for this user to be used in the CMS. This is set by the group. If multiple configurations are set, the one with the highest priority wins. Get the HtmlEditorConfig for this user to be used in the CMS. This is set by the group. If multiple configurations are set, the one with the highest priority wins. #### Returns `string` string

### Methods inherited from DataObject

`Aggregate()`, `RelationshipAggregate()`, `__construct()`, `baseTable()`, `belongs_to()`, `buildDataObjectSet()`, `buildSQL()`, `can()`, `canCreate()`, `castedUpdate()`, `composite_fields()`, `context_obj()`, `customDatabaseFields()`, `custom_database_fields()`, `data()`, `databaseFields()`, `databaseIndexes()`, `database_extensions()`, `database_fields()`, `db()`, `dbObject()`, `debug()`, `defaultSearchFilters()`, `defineMethods()`, `delete()`, `delete_by_id()`, `destroy()`, `disableCMSFieldsExtensions()`, `disable_subclass_access()`, `duplicate()`, `enableCMSFieldsExtensions()`, `enable_subclass_access()`, `exists()`, `extendedSQL()`, `fieldLabel()`, `flushCache()`, `flush_and_destroy_cache()`, `forceChange()`, `get()`, `getAllFields()`, `getCMSActions()`, `getChangedFields()`, `getClassAncestry()`, `getComponent()`, `getComponents()`, `getComponentsQuery()`, `getDefaultSearchContext()`, `getField()`, `getFrontEndFields()`, `getManyManyComponents()`, `getManyManyComponentsQuery()`, `getManyManyFilter()`, `getManyManyJoin()`, `getRemoteJoinField()`, `getReverseAssociation()`, `get_by_id()`, `get_one()`, `get_validation_enabled()`, `hasDatabaseField()`, `hasField()`, `hasOwnTableDatabaseField()`, `hasValue()`, `has_many()`, `has_one()`, `has_own_table()`, `i18n_plural_name()`, `i18n_singular_name()`, `inheritedDatabaseFields()`, `instance_get()`, `instance_get_one()`, `isChanged()`, `isEmpty()`, `isInDB()`, `is_composite_field()`, `many_many()`, `many_many_extraFields()`, `merge()`, `newClassInstance()`, `onAfterDelete()`, `onBeforeDelete()`, `plural_name()`, `provideI18nEntities()`, `relObject()`, `requireTable()`, `reset()`, `scaffoldFormFields()`, `scaffoldSearchFields()`, `searchableFields()`, `setCastedField()`, `setClassName()`, `setComponent()`, `setField()`, `set_context_obj()`, `set_validation_enabled()`, `singular_name()`, `summaryFields()`, `toMap()`, `update()`, `write()`, `writeComponents()`, `writeWithoutVersion()`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentMember()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `escapeTypeForField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`public static array` | $db | # Database field definitions. This is a map from field names to field type. The field type should be a class that extends . Database field definitions. This is a map from field names to field type. The field type should be a class that extends .
`public static array` | $belongs_many_many | # The inverse side of a many-many relationship. This is a map from component name to data type. The inverse side of a many-many relationship. This is a map from component name to data type.
`public static array` | $has_one | # One-to-zero relationship defintion. This is a map of component name to data type. In order to turn this into a true one-to-one relationship you can add a `DataObject::$belongs_to` relationship on the child class. One-to-zero relationship defintion. This is a map of component name to data type. In order to turn this into a true one-to-one relationship you can add a `DataObject::$belongs_to` relationship on the child class. Note that you cannot have a has_one and belongs_to relationship with the same name.
`public static array` | $has_many | # This defines a one-to-many relationship. It is a map of component name to the remote data class. This defines a one-to-many relationship. It is a map of component name to the remote data class. This relationship type does not actually create a data structure itself - you need to define a matching $has_one relationship on the child class. Also, if the $has_one relationship on the child class has multiple links to this class you can use the syntax "ClassName.HasOneRelationshipName" in the remote data class definition to show which foreign key to use.
`public static array` | $many_many | # many-many relationship definitions. This is a map from component name to data type. many-many relationship definitions. This is a map from component name to data type.
`public static array` | $many_many_extraFields | # Extra fields to include on the connecting many-many table. This is a map from field name to field type. Extra fields to include on the connecting many-many table. This is a map from field name to field type. Example code:
    public static $many_many_extraFields = array(
            'Members' => array(
                    'Role' => 'Varchar(100)'
            )
    );
`public static string` | $default_sort | # The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided. The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided.
`public static array` | $indexes | # If a field is in this array, then create a database index on that field. This is a map from fieldname to index type. See SS_Database->requireIndex() and custom subclasses for details on the array notation. If a field is in this array, then create a database index on that field. This is a map from fieldname to index type. See SS_Database->requireIndex() and custom subclasses for details on the array notation.
`public static boolean` | $notify_password_change | #
`public static array` | $searchable_fields | # All searchable database columns in this object, currently queried with a "column LIKE '%keywords%' statement. All searchable database columns in this object, currently queried with a "column LIKE '%keywords%' statement.
`public static array` | $summary_fields | # Provides a default list of fields to be used by a 'summary' view of this object. Provides a default list of fields to be used by a 'summary' view of this object.
`public static Array` | $title_format | # See `Member::set_title_columns()` See `Member::set_title_columns()`
`protected static string` | $unique_identifier_field | # The unique field used to identify this member. By default, it's "Email", but another common field could be Username. The unique field used to identify this member. By default, it's "Email", but another common field could be Username.
`protected static mixed` | $password_validator | # `PasswordValidator` object for validating user's password `PasswordValidator` object for validating user's password
`protected static mixed` | $password_expiry_days | # The number of days that a password should be valid for. By default, this is null, which means that passwords never expire The number of days that a password should be valid for. By default, this is null, which means that passwords never expire
`protected static mixed` | $lock_out_after_incorrect_logins | #
`protected static mixed` | $login_marker_cookie | # If this is set, then a session cookie with the given name will be set on log-in, and cleared on logout. If this is set, then a session cookie with the given name will be set on log-in, and cleared on logout.

### Properties inherited from DataObject

`$allowed_actions`, `$ancestry`, `$api_access`, `$belongs_to`, `$brokenOnDelete`, `$brokenOnWrite`, `$cache_get_one`, `$cache_has_own_table`, `$cache_has_own_table_field`, `$casting`, `$componentCache`, `$components`, `$create_table_options`, `$default_records`, `$defaults`, `$destroyed`, `$field_labels`, `$original`, `$plural_name`, `$record`, `$singular_name`

### Properties inherited from ViewableData

`$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -