Member
class Member extends DataObject implements TemplateGlobalProvider
The member class which represents the users of the system
Constants
CHANGE_NONE |
Represents a field that hasn't changed (before === after, thus before == after) |
CHANGE_STRICT |
Represents a field that has changed type, although not the loosely defined value. (before !== after && before == after) E.g. change 1 to true or "true" to true, but not true to 0. Value changes are by nature also considered strict changes. |
CHANGE_VALUE |
Represents a field that has changed the loosely defined value (before != after, thus, before !== after)) E.g. change false to true, but not false to 0 |
Config options
notify_password_change | boolean | ||
log_last_visited | bool | Flag whether or not member visits should be logged (count only) | |
log_num_visits | bool | Flag whether we should count number of visits | |
summary_fields | array | ||
casting | array | ||
hidden_fields | array | Internal-use only fields | |
title_format | Array | ||
unique_identifier_field | string | The unique field used to identify this member. | |
password_validator | |||
password_expiry_days | |||
lock_out_after_incorrect_logins | Int | ||
lock_out_delay_mins | integer | ||
login_marker_cookie | String | ||
session_regenerate_id | boolean | Indicates that when a {@link Member} logs in, Member:session_regenerate_id() should be called as a security precaution. | |
temp_id_lifetime | int | Default lifetime of temporary ids. |
Properties
string | $class | from SS_Object | |
boolean | $destroyed | True if this DataObject has been destroyed. | from DataObject |
static | $cache_has_own_table | Static caches used by relevant functions. | from DataObject |
static | $allowed_actions | Provides a list of allowed methods that can be called via RESTful api. | from DataObject |
string | $FirstName | ||
string | $Surname | ||
string | |||
string | $Password | ||
string | $RememberLoginToken | ||
string | $TempIDHash | ||
string | $TempIDExpired | ||
int | $NumVisit | @deprecated 4.0 | |
string | $LastVisited | @deprecated 4.0 | |
string | $AutoLoginHash | ||
string | $AutoLoginExpired | ||
string | $PasswordEncryption | ||
string | $Salt | ||
string | $PasswordExpiry | ||
string | $LockedOutUntil | ||
string | $Locale | ||
int | $FailedLoginCount | ||
string | $DateFormat | ||
string | $TimeFormat |
Methods
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Create an object from a string representation. It treats it as a PHP constructor without the 'new' keyword. It also manages to construct the object without the use of eval().
Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().
Similar to {@link Object::create()}, except that classes are only overloaded if you set the $strong parameter to TRUE when using {@link Object::useCustomClass()}
This class allows you to overload classes with other classes when they are constructed using the factory method {@link Object::create()}
If a class has been overloaded, get the class name it has been overloaded with - otherwise return the class name
Get the value of a static property of a class, even in that property is declared protected (but not private), without any inheritance, merging or parent lookup if it doesn't exist on the given class.
Return TRUE if a class has a specified extension.
Add an extension to a specific class.
No description
Construct a new DataObject.
Attemps to locate and call a method dynamically added to a class at runtime if a default cannot be located
Return the names of all the methods available on this object
Check if this class is an instance of a specific class, or has that class as one of its parents
Calls a method if available on both this object and all applied {@link Extensions}, and then attempts to merge all results into an array
Run the given function on all of this object's extensions. Note that this method originally returned void, so if you wanted to return results, you're hosed
Get an extension instance attached to this object by name.
Returns TRUE if this object instance has a specific extension applied in {@link $extension_instances}. Extension instances are initialized at constructor time, meaning if you use {@link add_extension()} afterwards, the added extension will just be added to new instances of the extended class. Use the static method {@link has_extension()} to check if a class (not an instance) has a specific extension.
Get all extension instances for this specific object instance.
Cache the results of an instance method in this object to a file, or if it is already cache return the cached results
Clears the cache for the given cacheToFile call
Converts a field spec into an object creator. For example: "Int" becomes "new Int($fieldName);" and "Varchar(50)" becomes "new Varchar($fieldName, 50);".
Convert a field schema (e.g. "Varchar(50)") into a casting object creator array that contains both a className and castingHelper constructor code. See {@link castingObjectCreator} for more information about the constructor.
Check if a field exists on this object or its failover.
Get the value of a property/field on this object. This will check if a method called get{$property} exists, then check if a field is available using {@link ViewableData::getField()}, then fall back on a failover object.
Set a property/field on this object. This will check for the existence of a method called set{$property}, then use the {@link ViewableData::setField()} method.
Set a failover object to attempt to get data from if it is not present on this object.
Returns true if the given field exists in a database column on any of
the objects tables and optionally look up a dynamic getter with
get
Set the value of the field Called by {@link __set()} and any setFieldName() methods you might create.
Method to facilitate deprecation of underscore-prefixed methods automatically being cached.
Merge some arbitrary data in with this object. This method returns a {@link ViewableData_Customised} instance with references to both this and the new custom data.
Get the class a field on this object would be casted to, as well as the casting helper for casting a field to an object (see {@link ViewableData::castingHelper()} for information on casting helpers).
Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field on this object.
Get the class name a field on this object will be casted to
Return the string-format type for the given field.
Save the casting cache for this object (including data from any failovers) into a variable
Render this object into the template, and get the result as a string. You can pass one of the following as the $template parameter: - a template name (e.g. Page) - an array of possible template names - the first valid one will be used - an SSViewer instance
Get the value of a field on this object, automatically inserting the value into any available casting objects that have been specified.
A simple wrapper around {@link ViewableData::obj()} that automatically caches the result so it can be used again without re-running the method.
Returns true if the given method/parameter has a value (Uses the DBField::hasValue if the parameter is a database field)
Get the string value of a field on this object that has been suitable escaped to be inserted directly into a template.
Return the value of the field without any escaping being applied.
Return the value of a field in an SQL-safe format.
Return the value of a field in a JavaScript-save format.
Return the value of a field escaped suitable to be inserted into an XML node attribute.
Return a single-item iterator so you can iterate over the fields of a single record.
When rendering some objects it is necessary to iterate over the object being rendered, to do this, you need access to itself.
Return the directory if the current active theme (relative to the site root).
Get part of the current classes ancestry to be used as a CSS class.
Return debug information about this object that can be rendered into a template
Set whether DataObjects should be validated before they are written.
Clear all cached classname specs. It's necessary to clear all cached subclassed names for any classes if a new class manifest is generated.
Determines the specification for the ClassName field for the given class
Return the complete map of fields on this object, including "Created", "LastEdited" and "ClassName".
Get all database columns explicitly defined on a class in {@link DataObject::$db} and {@link DataObject::$has_one}. Resolves instances of {@link CompositeDBField} into the actual database fields, rather than the name of the field which might not equate a database column.
Returns the field class if the given db field on the class is a composite field.
Returns a list of all the composite if the given db field on the class is a composite field.
Set the ClassName attribute. {@link $class} is also updated.
Create a new instance of a different class from this object's record.
Returns TRUE if all values (other than "ID") are considered empty (by weak boolean comparison).
Get the translated user friendly singular name of this DataObject same as singular_name() but runs it through the translating function
Get the user friendly plural name of this DataObject If the name is not defined (by renaming $plural_name in the subclass), this returns a pluralised version of the class name.
Get the translated user friendly plural name of this DataObject Same as plural_name but runs it through the translation function Translation string is in the form: $this->class.PLURALNAME Example: Page.PLURALNAME
Get the complete name of the member, by default in the format "
Returns the associated database record - in this case, the object itself.
Update a number of fields on this object, given a map of the desired changes.
Pass changes as a map, and try to get automatic casting for these fields.
Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty.
Ensure the locale is set to something sensible by default.
Writes all changes to this object to the database.
Write the cached components to the database. Cached components could refer to two different instances of the same record.
Delete the record with the given ID.
Return a component object from a one to one relationship, as a DataObject.
Returns a one-to-many relation as a HasManyList
No description
Find the foreign class of a relation on this DataObject, regardless of the relation type.
Tries to find the database key on another object that is used to store a relationship to this class. If no join field can be found it defaults to 'ParentID'.
Returns a many-to-many component, as a ManyManyList.
Return the class of a one-to-one component. If $component is null, return all of the one-to-one components and their classes. If the selected has_one is a polymorphic field then 'DataObject' will be returned for the type.
Return data for a specific has_one component.
Returns the class of a remote belongs_to relationship. If no component is specified a map of all components and their class name will be returned.
Return data for a specific belongs_to component.
Return all of the database fields defined in self::$db and all the parent classes.
Gets the class of a one-to-many relationship. If no $component is specified then an array of all the one-to-many relationships and their classes will be returned.
Return data for a specific has_many component.
Return the many-to-many extra fields specification.
Return the many-to-many extra fields specification for a specific component.
Return information about a many-to-many component.
Return information about a specific many_many component. Returns a numeric array of:
array(
This returns an array (if it exists) describing the database extensions that are required, or false if none
Generates a SearchContext to be used for building and processing a generic search form for properties on this object.
Determine which properties on the DataObject are searchable, and map them to their default {@link FormField} representations. Used for scaffolding a searchform for {@link ModelAdmin}.
Scaffold a simple edit form for all properties on this dataobject, based on default {@link FormField} mapping in {@link DBField::scaffoldFormField()}.
Return a {@link FieldList} of fields that would appropriate for editing this member.
need to be overload by solid dataobject, so that the customised actions of that dataobject, including that dataobject's extensions customised actions could be added to the EditForm.
Used for simple frontend forms without relation editing or {@link TabSet} behaviour. Uses {@link scaffoldFormFields()} by default. To customize, either overload this method in your subclass, or extend it by {@link DataExtension->updateFrontEndFields()}.
Return the fields that have changed.
Uses {@link getChangedFields()} to determine if fields have been changed since loading them from the database.
Set the value of the field, using a casting object.
Returns true if the given field exists as a database column
Returns the field type of the given field, if it belongs to this class, and not a parent.
Returns the field type of the given field, if it belongs to this class, and not a parent.
Returns true if given class has its own table. Uses the rules for whether the table should exist rather than actually looking in the database.
Returns true if the member is allowed to do the given action.
Process tri-state responses from permission-alterting extensions. The extensions are expected to return one of three values:
Return the DBField object that represents the given field.
Traverses to a DBField referenced by relationships between data objects.
Traverses to a field referenced by relationships between data objects, returning the value The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName)
Temporary hack to return an association name, based on class, to get around the mangle of having to deal with reverse lookup of relationships to determine autogenerated foreign keys.
Return all objects matching the filter sub-classes are automatically selected and included
Return the first item matching the given query.
Flush the cached results for all relations (has_one, has_many, many_many) Also clears any cached aggregate data.
Flush the get_one global cache and destroy associated objects.
Return the given element, searching by ID
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().
Returns fields bu traversing the class heirachy in a bottom-up direction.
Get the default searchable fields for this object, as defined in the $searchable_fields list. If searchable fields are not defined on the data object, uses a default selection of summary fields.
No description
Get a human-readable label for a single field, see {@link fieldLabels()} for more details.
Defines a default list of filters for the search context.
Temporarily disable subclass access in data object qeur
Collect all static properties on the object which contain natural language, and need to be translated.
Get the default admin record if it exists, or creates it otherwise if enabled
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.
Check if the passed password matches the stored one (if the member is not locked out).
Check if this user is the currently configured default admin
Returns a valid {@link ValidationResult} if this member can currently log in, or an invalid one with error messages to display if the member is locked out.
Returns true if this user is locked out
Regenerate the session_id.
Get the field used for uniquely identifying a member in the database. {see Member::$unique_identifier_field}
Set the field used for uniquely identifying a member in the database. {see Member::$unique_identifier_field}
Set a {@link PasswordValidator} object to use to validate member's passwords.
Returns the current {@link PasswordValidator}
Configure the security system to lock users out after this many incorrect logins
No description
Logs this member in
Trigger regeneration of TempID.
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.
Log the user in if the "remember login" cookie is set
Logs this member out.
Utility for generating secure password hashes for this member.
Generate an auto login token which can be used to reset the password, at the same time hashing it and storing in the database.
Check the token against the member.
Return the member for the auto login hash
Find a member record with the given TempIDHash value
Returns the fields for the member form - used in the registration/profile module.
Builds "Change / Create Password" field for this member
Returns the {@link RequiredFields} instance for the Member object. This Validator is used when saving a {@link CMSProfileController} or added to any form responsible for saving a users data.
Returns the current logged in user
Get the ID of the current logged in user
No description
Event handler called before writing to the database.
No description
No description
Filter out admin groups to avoid privilege escalation, If any admin groups are requested, deny the whole save operation.
List of group IDs this user is disallowed from
Adds the member to a group. This will create the group if the given group code does not return a valid group object.
Removes a member from a group.
No description
Return a SQL CONCAT() fragment suitable for a SELECT statement.
Get the complete name of the member
Set first- and surname
Alias for {@link setName}
Override the default getter for DateFormat so the default format for the user's locale is used if the user has not defined their own.
Override the default getter for TimeFormat so the default format for the user's locale is used if the user has not defined their own.
Get a "many-to-many" map that holds for all members their group memberships, including any parent groups where membership is implied.
No description
Get a member SQLMap of members in specific groups
Get a map of all members in the groups given that have CMS permissions
Get the groups in which the member is NOT in
Validate this member object.
Change password. This will cause rehashing according to
the PasswordEncryption
property.
Tell this member that someone made a failed attempt at logging in as them.
Tell this member that a successful login has been made
Get the HtmlEditorConfig for this user to be used in the CMS.
Called by SSViewer to get a list of global variables to expose to the template, the static method to call on this class to get the value for those variables, and the class to use for casting the returned value for use in a template
Details
in SS_Object at line 60
static Config_ForClass|null
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .
....).
in SS_Object at line 132
static SS_Object
create()
An implementation of the factory method, allows you to create an instance of a class
This method first for strong class overloads (singletons & DB interaction), then custom class overloads. If an overload is found, an instance of this is returned rather than the original class. To overload a class, use {@link Object::useCustomClass()}
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();
in SS_Object at line 155
static SS_Object
singleton()
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
in SS_Object at line 190
static
create_from_string($classSpec, $firstArg = null)
Create an object from a string representation. It treats it as a PHP constructor without the 'new' keyword. It also manages to construct the object without the use of eval().
Construction itself is done with Object::create(), so that Object::useCustomClass() calls are respected.
Object::create_from_string("Versioned('Stage','Live')")
will return the result of
Versioned::create('Stage', 'Live);
It is designed for simple, clonable objects. The first time this method is called for a given string it is cached, and clones of that object are returned.
If you pass the $firstArg argument, this will be prepended to the constructor arguments. It's impossible to pass null as the firstArg argument.
Object::create_from_string("Varchar(50)", "MyField")
will return the result of
Vachar::create('MyField', '50');
Arguments are always strings, although this is a quirk of the current implementation rather than something that can be relied upon.
in SS_Object at line 215
static
parse_class_spec($classSpec)
Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().
Returns a 2-elemnent array, with classname and arguments
in SS_Object at line 341
static SS_Object
strong_create()
Similar to {@link Object::create()}, except that classes are only overloaded if you set the $strong parameter to TRUE when using {@link Object::useCustomClass()}
in SS_Object at line 361
static
useCustomClass(string $oldClass, string $newClass, bool $strong = false)
This class allows you to overload classes with other classes when they are constructed using the factory method {@link Object::create()}
in SS_Object at line 375
static string
getCustomClass(string $class)
If a class has been overloaded, get the class name it has been overloaded with - otherwise return the class name
in SS_Object at line 396
static any
static_lookup($class, $name, null $default = null)
Get the value of a static property of a class, even in that property is declared protected (but not private), without any inheritance, merging or parent lookup if it doesn't exist on the given class.
in SS_Object at line 436
static
get_static($class, $name, $uncached = false)
deprecated
deprecated
in SS_Object at line 444
static
set_static($class, $name, $value)
deprecated
deprecated
in SS_Object at line 452
static
uninherited_static($class, $name, $uncached = false)
deprecated
deprecated
in SS_Object at line 460
static
combined_static($class, $name, $ceiling = false)
deprecated
deprecated
in SS_Object at line 470
static
addStaticVars($class, $properties, $replace = false)
deprecated
deprecated
in SS_Object at line 478
static
add_static_var($class, $name, $value, $replace = false)
deprecated
deprecated
in SS_Object at line 494
static
has_extension(string $classOrExtension, string $requiredExtension = null, boolean $strict = false)
Return TRUE if a class has a specified extension.
This supports backwards-compatible format (static Object::has_extension($requiredExtension)) and new format ($object->has_extension($class, $requiredExtension))
in SS_Object at line 536
static
add_extension(string $classOrExtension, string $extension = null)
Add an extension to a specific class.
The preferred method for adding extensions is through YAML config, since it avoids autoloading the class, and is easier to override in more specific configurations.
As an alternative, extensions can be added to a specific class directly in the {@link Object::$extensions} array. See {@link SiteTree::$extensions} for examples. Keep in mind that the extension will only be applied to new instances, not existing ones (including all instances created through {@link singleton()}).
in SS_Object at line 594
static
remove_extension(string $extension)
Remove an extension from a class.
Keep in mind that this won't revert any datamodel additions of the extension at runtime, unless its used before the schema building kicks in (in your _config.php). Doesn't remove the extension from any {@link Object} instances which are already created, but will have an effect on new extensions. Clears any previously created singletons through {@link singleton()} to avoid side-effects from stale extension information.
in SS_Object at line 633
static array
get_extensions(string $class, bool $includeArgumentString = false)
in SS_Object at line 655
static
get_extra_config_sources($class = null)
in DataObject at line 434
__construct($record = null, $isSingleton = false, $model = null)
Construct a new DataObject.
in SS_Object at line 725
mixed
__call(string $method, array $arguments)
Attemps to locate and call a method dynamically added to a class at runtime if a default cannot be located
You can add extra methods to a class using {@link Extensions}, {@link Object::createMethod()} or {@link Object::addWrapperMethod()}
in SS_Object at line 792
bool
hasMethod(string $method)
Return TRUE if a method exists on this object
This should be used rather than PHP's inbuild method_exists() as it takes into account methods added via extensions
in SS_Object at line 802
array
allMethodNames(bool $custom = false)
Return the names of all the methods available on this object
in SS_Object at line 963
stat($name, $uncached = false)
in SS_Object at line 970
set_stat($name, $value)
in SS_Object at line 977
uninherited($name)
in DataObject at line 730
bool
exists()
Returns true if this object "exists", i.e., has a sensible value.
The default behaviour for a DataObject is to return true if the object exists in the database, you can override this in subclasses.
in SS_Object at line 998
string
parentClass()
in SS_Object at line 1008
bool
is_a(string $class)
Check if this class is an instance of a specific class, or has that class as one of its parents
in SS_Object at line 1015
string
__toString()
in SS_Object at line 1030
mixed
invokeWithExtensions(string $method, mixed $argument = null)
Calls a method if available on both this object and all applied {@link Extensions}, and then attempts to merge all results into an array
in SS_Object at line 1058
array
extend(string $method, mixed $a1 = null, mixed $a2 = null, mixed $a3 = null, mixed $a4 = null, mixed $a5 = null, mixed $a6 = null, mixed $a7 = null)
Run the given function on all of this object's extensions. Note that this method originally returned void, so if you wanted to return results, you're hosed
Currently returns an array, with an index resulting every time the function is called. Only adds returns if they're not NULL, to avoid bogus results from methods just defined on the parent extension. This is important for permission-checks through extend, as they use min() to determine if any of the returns is FALSE. As min() doesn't do type checking, an included NULL return would fail the permission checks.
The extension methods are defined during {@link __construct()} in {@link defineMethods()}.
in SS_Object at line 1097
Extension
getExtensionInstance(string $extension)
Get an extension instance attached to this object by name.
in SS_Object at line 1115
bool
hasExtension(string $extension)
Returns TRUE if this object instance has a specific extension applied in {@link $extension_instances}. Extension instances are initialized at constructor time, meaning if you use {@link add_extension()} afterwards, the added extension will just be added to new instances of the extended class. Use the static method {@link has_extension()} to check if a class (not an instance) has a specific extension.
Caution: Don't use singleton(
in SS_Object at line 1126
array
getExtensionInstances()
Get all extension instances for this specific object instance.
See {@link get_extensions()} to get all applied extension classes for this class (not the instance).
in SS_Object at line 1142
mixed
cacheToFile(string $method, int $lifetime = 3600, string $ID = false, array $arguments = array())
Cache the results of an instance method in this object to a file, or if it is already cache return the cached results
in SS_Object at line 1171
clearCache($method, $ID = false, $arguments = array())
Clears the cache for the given cacheToFile call
in ViewableData at line 72
static string
castingObjectCreator(string $fieldSchema)
Converts a field spec into an object creator. For example: "Int" becomes "new Int($fieldName);" and "Varchar(50)" becomes "new Varchar($fieldName, 50);".
in ViewableData at line 83
static array
castingObjectCreatorPair(string $fieldSchema)
Convert a field schema (e.g. "Varchar(50)") into a casting object creator array that contains both a className and castingHelper constructor code. See {@link castingObjectCreator} for more information about the constructor.
in ViewableData at line 95
bool
__isset(string $property)
Check if a field exists on this object or its failover.
in ViewableData at line 117
mixed
__get(string $property)
Get the value of a property/field on this object. This will check if a method called get{$property} exists, then check if a field is available using {@link ViewableData::getField()}, then fall back on a failover object.
in ViewableData at line 138
__set(string $property, mixed $value)
Set a property/field on this object. This will check for the existence of a method called set{$property}, then use the {@link ViewableData::setField()} method.
in ViewableData at line 151
setFailover(ViewableData $failover)
Set a failover object to attempt to get data from if it is not present on this object.
in ViewableData at line 166
ViewableData|null
getFailover()
Get the current failover object if set
in DataObject at line 2778
bool
hasField(string $field)
Returns true if the given field exists in a database column on any of
the objects tables and optionally look up a dynamic getter with
get
in DataObject at line 2456
mixed
getField(string $field)
Gets the value of a field.
Called by {@link __get()} and any getFieldName() methods you might create.
in DataObject at line 2663
setField(string $fieldName, mixed $val)
Set the value of the field Called by {@link __set()} and any setFieldName() methods you might create.
in DataObject at line 683
defineMethods()
Adds methods from the extensions.
Called by Object::__construct() once per class.
in ViewableData at line 236
unknown
deprecatedCachedCall($method, $args = null, $identifier = null)
Method to facilitate deprecation of underscore-prefixed methods automatically being cached.
in ViewableData at line 255
ViewableData_Customised
customise(array|ViewableData $data)
Merge some arbitrary data in with this object. This method returns a {@link ViewableData_Customised} instance with references to both this and the new custom data.
Note that any fields you specify will take precedence over the fields on this object.
in ViewableData at line 272
ViewableData
getCustomisedObj()
in ViewableData at line 279
setCustomisedObj(ViewableData $object)
in ViewableData at line 296
array
castingHelperPair(string $field)
Get the class a field on this object would be casted to, as well as the casting helper for casting a field to an object (see {@link ViewableData::castingHelper()} for information on casting helpers).
The returned array contains two keys: - className: the class the field would be casted to (e.g. "Varchar") - castingHelper: the casting helper for casting the field (e.g. "return new Varchar($fieldName)")
in DataObject at line 2751
string
castingHelper(string $field)
Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field on this object.
in ViewableData at line 331
string
castingClass(string $field)
Get the class name a field on this object will be casted to
in ViewableData at line 346
string
escapeTypeForField(string $field)
Return the string-format type for the given field.
in ViewableData at line 357
buildCastingCache(reference $cache)
Save the casting cache for this object (including data from any failovers) into a variable
in ViewableData at line 394
HTMLText
renderWith(string|array|SSViewer $template, array $customFields = null)
Render this object into the template, and get the result as a string. You can pass one of the following as the $template parameter: - a template name (e.g. Page) - an array of possible template names - the first valid one will be used - an SSViewer instance
in ViewableData at line 456
obj(string $fieldName, array $arguments = null, bool $forceReturnedObject = true, bool $cache = false, string $cacheName = null)
Get the value of a field on this object, automatically inserting the value into any available casting objects that have been specified.
in ViewableData at line 503
cachedCall(string $field, array $arguments = null, string $identifier = null)
A simple wrapper around {@link ViewableData::obj()} that automatically caches the result so it can be used again without re-running the method.
in DataObject at line 4167
bool
hasValue(string $field, array $arguments = null, bool $cache = true)
Returns true if the given method/parameter has a value (Uses the DBField::hasValue if the parameter is a database field)
in ViewableData at line 538
XML_val($field, $arguments = null, $cache = false)
Get the string value of a field on this object that has been suitable escaped to be inserted directly into a template.
in ViewableData at line 546
RAW_val($field, $arguments = null, $cache = true)
Return the value of the field without any escaping being applied.
in ViewableData at line 553
SQL_val($field, $arguments = null, $cache = true)
Return the value of a field in an SQL-safe format.
in ViewableData at line 560
JS_val($field, $arguments = null, $cache = true)
Return the value of a field in a JavaScript-save format.
in ViewableData at line 567
ATT_val($field, $arguments = null, $cache = true)
Return the value of a field escaped suitable to be inserted into an XML node attribute.
in ViewableData at line 579
array
getXMLValues($fields)
Get an array of XML-escaped values by field name
in ViewableData at line 599
ArrayIterator
getIterator()
Return a single-item iterator so you can iterate over the fields of a single record.
This is useful so you can use a single record inside a <% control %> block in a template - and then use to access individual fields on this object.
in ViewableData at line 611
ViewableData
Me()
When rendering some objects it is necessary to iterate over the object being rendered, to do this, you need access to itself.
in ViewableData at line 627
string
ThemeDir(string $subtheme = false)
Return the directory if the current active theme (relative to the site root).
This method is useful for things such as accessing theme images from your template without hardcoding the theme
page - e.g. .
This method should only be used when a theme is currently active. However, it will fall over to the current project directory.
in ViewableData at line 648
string
CSSClasses(string $stopAtClass = 'ViewableData')
Get part of the current classes ancestry to be used as a CSS class.
This method returns an escaped string of CSS classes representing the current classes ancestry until it hits a stop point - e.g. "Page DataObject ViewableData".
in ViewableData at line 671
ViewableData_Debugger
Debug()
Return debug information about this object that can be rendered into a template
in DataObject at line 211
static bool
get_validation_enabled()
deprecated
deprecated 3.2 Use the "DataObject.validation_enabled" config setting instead
Returns when validation on DataObjects is enabled.
in DataObject at line 227
static
set_validation_enabled($enable)
deprecated
deprecated 3.2 Use the "DataObject.validation_enabled" config setting instead
Set whether DataObjects should be validated before they are written.
Caution: Validation can contain safeguards against invalid/malicious data, and check permission levels (e.g. on {@link Group}). Therefore it is recommended to only disable validation for very specific use cases.
in DataObject at line 241
static
clear_classname_spec_cache()
Clear all cached classname specs. It's necessary to clear all cached subclassed names for any classes if a new class manifest is generated.
in DataObject at line 254
static string
get_classname_spec(string $class, boolean $queryDB = true)
Determines the specification for the ClassName field for the given class
in DataObject at line 281
static array
database_fields(string $class, boolean $queryDB = true)
Return the complete map of fields on this object, including "Created", "LastEdited" and "ClassName".
See {@link custom_database_fields()} for a getter that excludes these "base fields".
in DataObject at line 310
static array
custom_database_fields(string $class)
Get all database columns explicitly defined on a class in {@link DataObject::$db} and {@link DataObject::$has_one}. Resolves instances of {@link CompositeDBField} into the actual database fields, rather than the name of the field which might not equate a database column.
Does not include "base fields" like "ID", "ClassName", "Created", "LastEdited", see {@link database_fields()}.
in DataObject at line 363
static string
is_composite_field(string $class, string $name, boolean $aggregated = true)
Returns the field class if the given db field on the class is a composite field.
Will check all applicable ancestor classes and aggregate results.
in DataObject at line 389
static
composite_fields($class, $aggregated = true)
Returns a list of all the composite if the given db field on the class is a composite field.
Will check all applicable ancestor classes and aggregate results.
in DataObject at line 510
DataObject
setDataModel(DataModel $model)
Set the DataModel
in DataObject at line 519
destroy()
Destroy all of this objects dependant objects and local caches.
You'll need to call this to get the memory of an object that has components or extensions freed.
in DataObject at line 533
DataObject
duplicate($doWrite = true)
Create a duplicate of this node.
Note: now also duplicates relations.
in DataObject at line 614
getObsoleteClassName()
in DataObject at line 619
getClassName()
in DataObject at line 635
DataObject
setClassName(string $className)
Set the ClassName attribute. {@link $class} is also updated.
Warning: This will produce an inconsistent record, as the object instance will not automatically switch to the new subclass. Please use {@link newClassInstance()} for this purpose, or destroy and reinstanciate the record.
in DataObject at line 660
DataObject
newClassInstance(string $newClassName)
Create a new instance of a different class from this object's record.
This is useful when dynamically changing the type of an instance. Specifically, it ensures that the instance of the class is a match for the className of the record. Don't set the {@link DataObject->class} or {@link DataObject->ClassName} property manually before calling this method, as it will confuse change detection.
If the new class is different to the original class, defaults are populated again because this will only occur automatically on instantiation of a DataObject if there is no record, or the record has no ID. In this case, we do have an ID but we still need to repopulate the defaults.
in DataObject at line 743
boolean
isEmpty()
Returns TRUE if all values (other than "ID") are considered empty (by weak boolean comparison).
Only checks for fields listed in {@link custom_database_fields()}
in DataObject at line 765
string
singular_name()
Get the user friendly singular name of this DataObject.
If the name is not defined (by redefining $singular_name in the subclass), this returns the class name.
in DataObject at line 784
string
i18n_singular_name()
Get the translated user friendly singular name of this DataObject same as singular_name() but runs it through the translating function
Translating string is in the form: $this->class.SINGULARNAME Example: Page.SINGULARNAME
in DataObject at line 795
string
plural_name()
Get the user friendly plural name of this DataObject If the name is not defined (by renaming $plural_name in the subclass), this returns a pluralised version of the class name.
in DataObject at line 818
string
i18n_plural_name()
Get the translated user friendly plural name of this DataObject Same as plural_name but runs it through the translation function Translation string is in the form: $this->class.PLURALNAME Example: Page.PLURALNAME
at line 1182
string
getTitle()
Get the complete name of the member, by default in the format "
Falls back to showing either field on its own.
You can overload this getter with {@link set_title_format()} and {@link set_title_sql()}.
in DataObject at line 854
DataObject
data()
Returns the associated database record - in this case, the object itself.
This is included so that you can call $dataOrController->data() and get a DataObject all the time.
in DataObject at line 863
array
toMap()
Convert this object to a map.
in DataObject at line 876
array
getQueriedDatabaseFields()
Return all currently fetched database fields.
This function is similar to toMap() but doesn't trigger the lazy-loading of all unfetched fields. Obviously, this makes it a lot faster.
in DataObject at line 892
DataObject
update(array $data)
Update a number of fields on this object, given a map of the desired changes.
The field names can be simple names, or you can use a dot syntax to access $has_one relations. For example, array("Author.FirstName" => "Jim") will set $this->Author()->FirstName to "Jim".
update() doesn't write the main object, but if you use the dot syntax, it will write() the related objects that it alters.
in DataObject at line 949
DataObject
castedUpdate(array $data)
Pass changes as a map, and try to get automatic casting for these fields.
Doesn't write to the database. To write the data, use the write() method.
in DataObject at line 977
Boolean
merge($rightObj, $priority = 'right', $includeRelations = true, $overwriteWithEmpty = false)
Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty.
has_one-relations are just transferred with priority 'right'. has_many and many_many-relations are added regardless of priority.
Caution: has_many/many_many relations are moved rather than duplicated, meaning they are not connected to the merged object any longer. Caution: Just saves updated has_many/many_many relations to the database, doesn't write the updated object itself (just writes the object-properties). Caution: Does not delete the merged object. Caution: Does now overwrite Created date on the original object.
in DataObject at line 1054
$this
forceChange()
Forces the record to think that all its data has changed.
Doesn't write to the database. Only sets fields as changed if they are not already marked as changed.
in DataObject at line 1101
ValidationResult
doValidate()
Public accessor for {see DataObject::validate()}
at line 249
DataObject
populateDefaults()
Ensure the locale is set to something sensible by default.
in DataObject at line 1401
write(boolean $showDebug = false, boolean $forceInsert = false, boolean $forceWrite = false, boolean $writeComponents = false)
Writes all changes to this object to the database.
- It will insert a record whenever ID isn't set, otherwise update.
- All relevant tables will be updated.
- $this->onBeforeWrite() gets called beforehand.
- Extensions such as Versioned will ammend the database-write to ensure that a version is saved.
in DataObject at line 1450
writeRelations()
Writes cached relation lists to the database, if possible
in DataObject at line 1469
DataObject
writeComponents($recursive = false)
Write the cached components to the database. Cached components could refer to two different instances of the same record.
in DataObject at line 1484
delete()
Delete this data object.
$this->onBeforeDelete() gets called. Note that in Versioned objects, both Stage and Live will be deleted.
in DataObject at line 1519
static
delete_by_id(string $className, int $id)
Delete the record with the given ID.
in DataObject at line 1536
array
getClassAncestry()
Get the class ancestry, including the current class name.
The ancestry will be returned as an array of class names, where the 0th element will be the class that inherits directly from DataObject, and the last element will be the current class.
in DataObject at line 1555
DataObject
getComponent(string $componentName)
Return a component object from a one to one relationship, as a DataObject.
If no component is available, an 'empty component' will be returned for non-polymorphic relations, or for polymorphic relations with a class set.
in DataObject at line 1624
HasManyList
getComponents(string $componentName, string|null $filter = null, string|null|array $sort = null, string $join = null, string|null|array $limit = null)
Returns a one-to-many relation as a HasManyList
in DataObject at line 1674
getComponentsQuery($componentName, $filter = "", $sort = "", $join = "", $limit = "")
deprecated
deprecated
in DataObject at line 1685
string
getRelationClass($relationName)
Find the foreign class of a relation on this DataObject, regardless of the relation type.
in DataObject at line 1723
string
getRemoteJoinField(string $component, string $type = 'has_many', boolean $polymorphic = false)
Tries to find the database key on another object that is used to store a relationship to this class. If no join field can be found it defaults to 'ParentID'.
If the remote field is polymorphic then $polymorphic is set to true, and the return value is in the form 'Relation' instead of 'RelationID', referencing the composite DBField.
in DataObject at line 1799
ManyManyList
getManyManyComponents($componentName, $filter = null, $sort = null, $join = null, $limit = null)
Returns a many-to-many component, as a ManyManyList.
in DataObject at line 1845
array|null
has_one(string $component = null)
deprecated
deprecated 4.0 Method has been replaced by hasOne() and hasOneComponent()
in DataObject at line 1863
string|array
hasOne(string $component = null)
Return the class of a one-to-one component. If $component is null, return all of the one-to-one components and their classes. If the selected has_one is a polymorphic field then 'DataObject' will be returned for the type.
in DataObject at line 1881
string|null
hasOneComponent(string $component)
Return data for a specific has_one component.
in DataObject at line 1895
array|null
belongs_to(string $component = null, bool $classOnly = true)
deprecated
deprecated 4.0 Method has been replaced by belongsTo() and belongsToComponent()
in DataObject at line 1914
string|array
belongsTo(string $component = null, bool $classOnly = true)
Returns the class of a remote belongs_to relationship. If no component is specified a map of all components and their class name will be returned.
in DataObject at line 1939
string|false
belongsToComponent(string $component, bool $classOnly = true)
Return data for a specific belongs_to component.
in DataObject at line 1958
array
db(string $fieldName = null)
Return all of the database fields defined in self::$db and all the parent classes.
Doesn't include any fields specified by self::$has_one. Use $this->hasOne() to get these fields
in DataObject at line 1996
array|null
has_many(string $component = null, bool $classOnly = true)
deprecated
deprecated 4.0 Method has been replaced by hasMany() and hasManyComponent()
in DataObject at line 2015
string|array|false
hasMany(string $component = null, bool $classOnly = true)
Gets the class of a one-to-many relationship. If no $component is specified then an array of all the one-to-many relationships and their classes will be returned.
in DataObject at line 2040
string|false
hasManyComponent(string $component, bool $classOnly = true)
Return data for a specific has_many component.
in DataObject at line 2058
array
many_many_extraFields(string $component = null)
deprecated
deprecated 4.0 Method has been replaced by manyManyExtraFields() and manyManyExtraFieldsForComponent()
in DataObject at line 2077
array|null
manyManyExtraFields(string $component = null)
Return the many-to-many extra fields specification.
If you don't specify a component name, it returns all extra fields for all components available.
in DataObject at line 2096
array|null
manyManyExtraFieldsForComponent(string $component)
Return the many-to-many extra fields specification for a specific component.
in DataObject at line 2142
array|null
many_many(string $component = null)
deprecated
deprecated 4.0 Method has been renamed to manyMany()
in DataObject at line 2161
array|null
manyMany(string $component = null)
Return information about a many-to-many component.
The return value is an array of (parentclass, childclass). If $component is null, then all many-many components are returned.
in DataObject at line 2190
array|null
manyManyComponent(string $component)
Return information about a specific many_many component. Returns a numeric array of:
array(
in DataObject at line 2253
array
database_extensions($class)
This returns an array (if it exists) describing the database extensions that are required, or false if none
This is experimental, and is currently only a Postgres-specific enhancement.
in DataObject at line 2268
SearchContext
getDefaultSearchContext()
Generates a SearchContext to be used for building and processing a generic search form for properties on this object.
in DataObject at line 2291
FieldList
scaffoldSearchFields(array $_params = null)
Determine which properties on the DataObject are searchable, and map them to their default {@link FormField} representations. Used for scaffolding a searchform for {@link ModelAdmin}.
Some additional logic is included for switching field labels, based on how generic or specific the field type is.
Used by {@link SearchContext}.
in DataObject at line 2349
FieldList
scaffoldFormFields(array $_params = null)
Scaffold a simple edit form for all properties on this dataobject, based on default {@link FormField} mapping in {@link DBField::scaffoldFormField()}.
Field labels/titles will be auto generated from {@link DataObject::fieldLabels()}.
at line 1449
FieldList
getCMSFields()
Return a {@link FieldList} of fields that would appropriate for editing this member.
in DataObject at line 2423
an
getCMSActions()
need to be overload by solid dataobject, so that the customised actions of that dataobject, including that dataobject's extensions customised actions could be added to the EditForm.
in DataObject at line 2441
FieldList
getFrontEndFields(array $params = null)
Used for simple frontend forms without relation editing or {@link TabSet} behaviour. Uses {@link scaffoldFormFields()} by default. To customize, either overload this method in your subclass, or extend it by {@link DataExtension->updateFrontEndFields()}.
in DataObject at line 2590
array
getChangedFields(boolean $databaseFieldsOnly = false, int $changeLevel = self::CHANGE_STRICT)
Return the fields that have changed.
The change level affects what the functions defines as "changed": - Level CHANGE_STRICT (integer 1) will return strict changes, even !== ones. - Level CHANGE_VALUE (integer 2) is more lenient, it will only return real data changes, for example a change from 0 to null would not be included.
Example return:
array(
'Title' = array('before' => 'Home', 'after' => 'Home-Changed', 'level' => DataObject::CHANGE_VALUE)
)
in DataObject at line 2643
boolean
isChanged(string $fieldName = null, int $changeLevel = self::CHANGE_STRICT)
Uses {@link getChangedFields()} to determine if fields have been changed since loading them from the database.
in DataObject at line 2733
setCastedField($fieldName, $val)
Set the value of the field, using a casting object.
This is useful when you aren't sure that a date is in SQL format, for example. setCastedField() can also be used, by forms, to set related data. For example, uploaded images can be saved into the Image table.
in DataObject at line 2794
boolean
hasDatabaseField(string $field)
Returns true if the given field exists as a database column
in DataObject at line 2807
string
hasOwnTableDatabaseField(string $field)
Returns the field type of the given field, if it belongs to this class, and not a parent.
Note that the field type will not include constructor arguments in round brackets, only the classname.
in DataObject at line 2819
static string
has_own_table_database_field(string $class, string $field)
Returns the field type of the given field, if it belongs to this class, and not a parent.
Note that the field type will not include constructor arguments in round brackets, only the classname.
in DataObject at line 2840
static bool
has_own_table(string $dataClass)
Returns true if given class has its own table. Uses the rules for whether the table should exist rather than actually looking in the database.
in DataObject at line 2866
boolean
can(string $perm, Member $member = null)
Returns true if the member is allowed to do the given action.
See {@link extendedCan()} for a more versatile tri-state permission control.
in DataObject at line 2946
boolean|null
extendedCan(String $methodName, Member|int $member)
Process tri-state responses from permission-alterting extensions. The extensions are expected to return one of three values:
- false: Disallow this permission, regardless of what other extensions say
- true: Allow this permission, as long as no other extensions return false
- NULL: Don't affect the outcome
This method itself returns a tri-state value, and is designed to be used like this:
$extended = $this->extendedCan('canDoSomething', $member);
if($extended !== null) return $extended;
else return $normalValue;
at line 1599
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.
at line 1626
boolean
canEdit(Member $member = null)
Users can edit their own record.
Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions
at line 1653
boolean
canDelete(Member $member = null)
Users can edit their own record.
Otherwise they'll need ADMIN or CMS_ACCESS_SecurityAdmin permissions
in DataObject at line 3000
boolean
canCreate(Member $member = null)
in DataObject at line 3013
string
debug()
Debugging used by Debug::show()
in DataObject at line 3032
DBField
dbObject(string $fieldName)
Return the DBField object that represents the given field.
This works similarly to obj() with 2 key differences: - it still returns an object even when the field has no value. - it only matches fields and not methods - it matches foreign keys generated by has_one relationships, eg, "ParentID"
in DataObject at line 3078
mixed
relObject(string $fieldPath)
Traverses to a DBField referenced by relationships between data objects.
The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName).
in DataObject at line 3116
string
relField($fieldName)
Traverses to a field referenced by relationships between data objects, returning the value The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName)
in DataObject at line 3161
String
getReverseAssociation($className)
Temporary hack to return an association name, based on class, to get around the mangle of having to deal with reverse lookup of relationships to determine autogenerated foreign keys.
in DataObject at line 3195
static DataList
get(string $callerClass = null, string|array $filter = "", string|array $sort = "", string $join = "", string|array $limit = null, string $containerClass = 'DataList')
Return all objects matching the filter sub-classes are automatically selected and included
in DataObject at line 3237
Aggregate($class = null)
deprecated
deprecated
in DataObject at line 3258
RelationshipAggregate($relationship)
deprecated
deprecated
in DataObject at line 3276
static DataObject
get_one(string $callerClass, string|array $filter = "", boolean $cache = true, string $orderby = "")
Return the first item matching the given query.
All calls to get_one() are cached.
in DataObject at line 3311
DataObject
flushCache(boolean $persistent = true)
Flush the cached results for all relations (has_one, has_many, many_many) Also clears any cached aggregate data.
in DataObject at line 3333
static
flush_and_destroy_cache()
Flush the get_one global cache and destroy associated objects.
in DataObject at line 3345
static
reset()
Reset all global caches associated with DataObject.
in DataObject at line 3366
static DataObject
get_by_id(string $callerClass, int $id, boolean $cache = true)
Return the given element, searching by ID
in DataObject at line 3387
baseTable()
Get the name of the base table for this object
in DataObject at line 3403
array
getSourceQueryParams()
in DataObject at line 3411
setSourceQueryParams(array $array)
in DataObject at line 3419
setSourceQueryParam($key, $value)
in DataObject at line 3427
Mixed
getSourceQueryParam($key)
in DataObject at line 3439
databaseIndexes()
Return the database indexes on this table.
This array is indexed by the name of the field with the index, and the value is the type of index.
in DataObject at line 3521
requireTable()
Check the database schema and update it as necessary.
at line 254
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().
in DataObject at line 3640
inheritedDatabaseFields()
Returns fields bu traversing the class heirachy in a bottom-up direction.
Needed to avoid getCMSFields being empty when customDatabaseFields overlooks the inheritance chain of the $db array, where a child data object has no $db array, but still needs to know the properties of its parent. This should be merged into databaseFields or customDatabaseFields.
in DataObject at line 3659
array
searchableFields()
Get the default searchable fields for this object, as defined in the $searchable_fields list. If searchable fields are not defined on the data object, uses a default selection of summary fields.
at line 1573
array|string
fieldLabels(boolean $includerelations = true)
in DataObject at line 3802
string
fieldLabel(string $name)
Get a human-readable label for a single field, see {@link fieldLabels()} for more details.
in DataObject at line 3814
array
summaryFields()
Get the default summary fields for this object.
in DataObject at line 3864
array
defaultSearchFilters()
Defines a default list of filters for the search context.
If a filter class mapping is defined on the data object, it is constructed here. Otherwise, the default filter specified in {@link DBField} is used.
in DataObject at line 3889
boolean
isInDB()
in DataObject at line 3901
static
disable_subclass_access()
Temporarily disable subclass access in data object qeur
in DataObject at line 3904
static
enable_subclass_access()
in DataObject at line 4139
array
provideI18nEntities()
Collect all static properties on the object which contain natural language, and need to be translated.
The full entity name is composed from the class name and a custom identifier.
at line 241
static
set_session_regenerate_id($bool)
deprecated
deprecated 4.0 Use the "Member.session_regenerate_id" config setting instead
at line 265
static Member
default_admin()
Get the default admin record if it exists, or creates it otherwise if enabled
at line 319
static
set_login_marker_cookie($cookieName)
deprecated
deprecated 4.0 Use the "Member.login_marker_cookie" config setting instead
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
at line 330
ValidationResult
checkPassword(string $password)
Check if the passed password matches the stored one (if the member is not locked out).
at line 365
bool
isDefaultAdmin()
Check if this user is the currently configured default admin
at line 378
ValidationResult
canLogIn()
Returns a valid {@link 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.
at line 400
isLockedOut()
Returns true if this user is locked out
at line 447
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).
at line 468
static string
get_unique_identifier_field()
deprecated
deprecated 4.0 Use the "Member.unique_identifier_field" config setting instead
Get the field used for uniquely identifying a member in the database. {see Member::$unique_identifier_field}
at line 480
static
set_unique_identifier_field($field)
deprecated
deprecated 4.0 Use the "Member.unique_identifier_field" config setting instead
Set the field used for uniquely identifying a member in the database. {see Member::$unique_identifier_field}
at line 488
static
set_password_validator($pv)
Set a {@link PasswordValidator} object to use to validate member's passwords.
at line 495
static
password_validator()
Returns the current {@link PasswordValidator}
at line 505
static
set_password_expiry($days)
deprecated
deprecated 4.0 Use the "Member.password_expiry_days" config setting instead
Set the number of days that a password should be valid for.
Set to null (the default) to have passwords never expire.
at line 515
static
lock_out_after_incorrect_logins($numLogins)
deprecated
deprecated 4.0 Use the "Member.lock_out_after_incorrect_logins" config setting instead
Configure the security system to lock users out after this many incorrect logins
at line 521
isPasswordExpired()
at line 531
logIn(bool $remember = false)
Logs this member in
at line 574
addVisit()
deprecated
deprecated 4.0
at line 590
regenerateTempID()
Trigger regeneration of TempID.
This should be performed any time the user presents their normal identification (normally Email) and is successfully authenticated.
at line 606
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.
at line 622
static
autoLogin()
Log the user in if the "remember login" cookie is set
The remember login token will be changed on every successful auto-login.
at line 675
logOut()
Logs this member out.
at line 701
encryptWithUserSettings($string)
Utility for generating secure password hashes for this member.
at line 726
generateAutologinTokenAndStoreHash(int $lifetime = 2)
Generate an auto login token which can be used to reset the password, at the same time hashing it and storing in the database.
at line 750
validateAutoLoginToken(string $autologinToken)
Check the token against the member.
at line 765
static Member
member_from_autologinhash(string $hash, bool $login = false)
Return the member for the auto login hash
at line 784
static Member
member_from_tempid(string $tempid)
Find a member record with the given TempIDHash value
at line 803
FieldList
getMemberFormFields()
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.
at line 828
ConfirmedPasswordField
getMemberPasswordField()
Builds "Change / Create Password" field for this member
at line 863
Member_Validator
getValidator()
Returns the {@link RequiredFields} instance for the Member object. This Validator is used when saving a {@link CMSProfileController} or added to any form responsible for saving a users data.
To customize the required fields, add a {@link DataExtension} to member
calling the updateValidator()
method.
at line 877
static Member|null
currentUser()
Returns the current logged in user
at line 890
static int
currentUserID()
Get the ID of the current logged in user
at line 909
static
create_new_password()
at line 934
onBeforeWrite()
Event handler called before writing to the database.
at line 1017
onAfterWrite()
at line 1027
onAfterDelete()
at line 1054
boolean
onChangeGroups(Array $ids)
Filter out admin groups to avoid privilege escalation, If any admin groups are requested, deny the whole save operation.
at line 1065
int[]
disallowedGroups()
List of group IDs this user is disallowed from
at line 1083
bool
inGroups(array|SS_List $groups, boolean $strict = false)
Check if the member is in one of the given groups.
at line 1099
bool
inGroup(int|Group|string $group, boolean $strict = false)
Check if the member is in the given group or any parent groups.
at line 1129
addToGroupByCode(string $groupcode, string $title = "")
Adds the member to a group. This will create the group if the given group code does not return a valid group object.
at line 1153
removeFromGroupByCode(string $groupcode)
Removes a member from a group.
at line 1165
static
set_title_columns(Array $columns, String $sep = ' ')
at line 1213
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.
at line 1236
string
getName()
Get the complete name of the member
at line 1249
setName(string $name)
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
at line 1262
splitName(string $name)
Alias for {@link setName}
at line 1273
string
getDateFormat()
Override the default getter for DateFormat so the default format for the user's locale is used if the user has not defined their own.
at line 1288
string
getTimeFormat()
Override the default getter for TimeFormat so the default format for the user's locale is used if the user has not defined their own.
at line 1307
Member_Groupset
Groups()
Get a "many-to-many" map that holds for all members their group memberships, including any parent groups where membership is implied.
Use {@link DirectGroups()} to only retrieve the group relations without inheritance.
at line 1319
ManyManyList
DirectGroups()
at line 1332
static SQLMap
map_in_groups(mixed $groups = null)
Get a member SQLMap of members in specific groups
If no $groups is passed, all members will be returned
at line 1371
static SS_Map
mapInCMSGroups(array $groups = null)
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.
at line 1428
array
memberNotInGroups(array $groupList, array $memberGroups = null)
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.
at line 1677
validate()
Validate this member object.
at line 1701
changePassword(String $password)
Change password. This will cause rehashing according to
the PasswordEncryption
property.
at line 1717
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.
at line 1735
registerSuccessfulLogin()
Tell this member that a successful login has been made
at line 1751
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.
at line 1770
static array
get_template_global_variables()
Called by SSViewer to get a list of global variables to expose to the template, the static method to call on this class to get the value for those variables, and the class to use for casting the returned value for use in a template
If the method to call is not included for a particular template variable, a method named the same as the template variable will be called
If the casting class is not specified for a particular template variable, ViewableData::$default_cast is used
The first letter of the template variable is case-insensitive. However the method name is always case sensitive.