SYNOPSIS

  use RT::User;

DESCRIPTION

METHODS

Create { PARAMHASH }

SetPrivileged BOOL

If passed a true value, makes this user a member of the "Privileged" PseudoGroup. Otherwise, makes this user a member of the "Unprivileged" pseudogroup.

Returns a standard RT tuple of (val, msg);

Privileged

Returns true if this user is privileged. Returns undef otherwise.

Load

Load a user object from the database. Takes a single argument. If the argument is numerical, load by the column 'id'. Otherwise, load by the "Name" column which is the user's textual username.

LoadByEmail

Tries to load this user object from the database by the user's email address.

LoadOrCreateByEmail ADDRESS

Attempts to find a user who has the provided email address. If that fails, creates an unprivileged user with the provided email address. and loads them.

Returns a tuple of the user's id and a status message. 0 will be returned in place of the user's id in case of failure.

ValidateEmailAddress ADDRESS

Returns true if the email address entered is not in use by another user or is undef or ''. Returns false if it's in use.

CanonicalizeEmailAddress ADDRESS

# CanonicalizeEmailAddress converts email addresses into canonical form. # it takes one email address in and returns the proper canonical # form. You can dump whatever your proper local config is in here

SetRandomPassword

Takes no arguments. Returns a status code and a new password or an error message. If the status is 1, the second value returned is the new password. If the status is anything else, the new value returned is the error code.

ResetPassword

Returns status, [ERROR or new password]. Resets this user\'s password to a randomly generated pronouncable password and emails them, using a global template called "RT_PasswordChange", which can be overridden with global templates "RT_PasswordChange_Privileged" or "RT_PasswordChange_NonPrivileged" for privileged and Non-privileged users respectively.

GenerateRandomPassword MIN_LEN and MAX_LEN

Returns a random password between MIN_LEN and MAX_LEN characters long.

SetPassword

Takes a string. Checks the string's length and sets this user's password to that string.

_GeneratePassword PASSWORD

returns an MD5 hash of the password passed in, in base64 encoding.

IsPassword

Returns true if the passed in value is this user's password. Returns undef otherwise.

Sub SetDisabled

Toggles the user's disabled flag. If this flag is set, all password checks for this user will fail. All ACL checks for this user will fail. The user will appear in no user listings.

PrincipalObj

Returns the principal object for this user. returns an empty RT::Principal if there's no principal object matching this user. The response is cached. PrincipalObj should never ever change.

PrincipalId

Returns this user's PrincipalId

HasGroupRight

Takes a paramhash which can contain these items: GroupObj => RT::Group or Group => integer Right => 'Right'

Returns 1 if this user has the right specified in the paramhash for the Group passed in.

Returns undef if they don't.

Rights testing

sub HasRight

Shim around PrincipalObj->HasRight. See RT::Principal

CurrentUserCanModify RIGHT

If the user has rights for this object, either because he has 'AdminUsers' or (if he\'s trying to edit himself and the right isn\'t an admin right) 'ModifySelf', return 1. otherwise, return undef.

CurrentUserHasRight Takes a single argument. returns 1 if $Self->CurrentUser has the requested right. returns undef otherwise

_Value

Takes the name of a table column. Returns its value as a string, if the user passes an ACL check