User

Package: Record

class User

extends Omeka_Record_AbstractRecord

implements Zend_Acl_Resource_Interface implements Zend_Acl_Role_Interface

A user and its metadata.

constant User::USERNAME_MIN_LENGTH

Minimum username length.

constant User::USERNAME_MAX_LENGTH

Maximum username length.

constant User::PASSWORD_MIN_LENGTH

Minimum password length.

constant User::INVALID_EMAIL_ERROR_MSG

Error message for an invalid email address.

constant User::CLAIMED_EMAIL_ERROR_MSG

Error message for an already-taken email address.

property User::$username

string

This User’s username.

property User::$password

string

The hashed password.

This field should never contain the plain-text password. Always use setPassword() to change the user password.

property User::$salt

string

The salt for the hashed password.

property User::$active

int

Whether this user is active and can log in.

property User::$role

string

This user’s role.

property User::$name

string

This user’s full or display name.

property User::$email

string

This user’s email address.

User::beforeSave($args)

Before-save hook.

Check the current user’s privileges to change user roles before saving.

Parameters:
  • $args

User::filterPostData($post)

Filter form POST input.

Transform usernames to lowercase alphanumeric.

Parameters:
  • $post (array) –

Returns:

array Cleaned POST data.

User::setPostData($post)

Set data from POST to the record.

Removes the ‘password’ and ‘salt’ entries, if passed.

Parameters:
  • $post

User::_validate()

Validate this User.

User::upgradeHashedPassword($username, $password)

Upgrade the hashed password.

Does nothing if the user/password is incorrect, or if same has been upgraded already.

Parameters:
  • $username (string) –

  • $password (string) –

Returns:

bool False if incorrect username/password given, otherwise true when password can be or has been upgraded.

User::getRoleId()

Get this User’s role.

Required by Zend_Acl_Role_Interface.

Returns:

string

User::getResourceId()

Get the Resource ID for the User model.

Required by Zend_Acl_Resource_Interface.

Returns:

string

User::generateSalt()

Generate a simple 16 character salt for the user.

User::setPassword($password)

Set a new password for the user.

Always use this method to set a password, do not directly set the password or salt properties.

Parameters:
  • $password (string) – Plain-text password.

User::hashPassword($password)

SHA-1 hash the given password with the current salt.

Parameters:
  • $password (string) – Plain-text password.

Returns:

string Salted and hashed password.