Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
PKPValidation Class Reference
Inheritance diagram for PKPValidation:
Validation

Static Public Member Functions

static canAdminister ($administeredUserId, $administratorUserId)
 
static checkCredentials ($username, $password)
 
static encryptCredentials ($username, $password, $encryption=false)
 
static generatePassword ($length=8)
 
static generatePasswordResetHash ($userId)
 
static isAuthorized ($roleId, $contextId=0)
 
static isLoggedIn ()
 
static isLoggedInAs ()
 
static isSiteAdmin ()
 
static & login ($username, $password, &$reason, $remember=false)
 
static logout ()
 
static redirectLogin ($message=null)
 
static & registerUserSession ($user, &$reason, $remember=false)
 
static suggestUsername ($firstName, $lastName)
 

Detailed Description

Class providing user validation/authentication operations.

Definition at line 16 of file PKPValidation.inc.php.

Member Function Documentation

static PKPValidation::canAdminister (   $administeredUserId,
  $administratorUserId 
)
static

Check whether a user is allowed to administer another user.

Parameters
$administeredUserIdint User ID of user to potentially administer
$administratorUserIdint User ID of user who wants to do the administrating
Returns
boolean True IFF the administration operation is permitted

Definition at line 328 of file PKPValidation.inc.php.

References DAORegistry\getDAO().

Referenced by UserGridHandler\disableUser(), UserGridHandler\editDisableUser(), UserGridHandler\editEmail(), UserGridHandler\editUser(), UserGridRow\initialize(), UserGridHandler\removeUser(), UserGridHandler\sendEmail(), LoginHandler\signInAsUser(), UserGridHandler\updateUser(), and UserGridHandler\updateUserRoles().

static PKPValidation::checkCredentials (   $username,
  $password 
)
static

Check if a user's credentials are valid.

Parameters
$usernamestring username
$passwordstring unencrypted password
Returns
boolean

Definition at line 171 of file PKPValidation.inc.php.

References encryptCredentials(), and DAORegistry\getDAO().

static PKPValidation::encryptCredentials (   $username,
  $password,
  $encryption = false 
)
static

Encrypt user passwords for database storage. The username is used as a unique salt to make dictionary attacks against a compromised database more difficult.

Parameters
$usernamestring username
$passwordstring unencrypted password
$encryptionstring optional encryption algorithm to use, defaulting to the value from the site configuration
Returns
string encrypted password

Definition at line 228 of file PKPValidation.inc.php.

References Config\getVar().

Referenced by checkCredentials(), LoginChangePasswordForm\execute(), CreateReviewerForm\execute(), login(), and PKPLoginHandler\resetPassword().

static PKPValidation::generatePassword (   $length = 8)
static

Generate a random password. Assumes the random number generator has already been seeded.

Parameters
$lengthint the length of the password to generate (default 8)
Returns
string

Definition at line 252 of file PKPValidation.inc.php.

Referenced by AccessKeyManager\createKey(), LoginChangePasswordForm\execute(), CreateReviewerForm\execute(), and PKPLoginHandler\resetPassword().

static PKPValidation::generatePasswordResetHash (   $userId)
static

Generate a hash value to use for confirmation to reset a password.

Parameters
$userIdint
Returns
string (boolean false if user is invalid)

Definition at line 268 of file PKPValidation.inc.php.

References DAORegistry\getDAO().

Referenced by ThankReviewerForm\initData(), ReviewReminderForm\initData(), PKPAuditorReminderForm\initData(), PKPLoginHandler\requestResetPassword(), and PKPLoginHandler\resetPassword().

static PKPValidation::isAuthorized (   $roleId,
  $contextId = 0 
)
static

Check if a user is authorized to access the specified role in the specified context.

Parameters
$roleIdint
$contextIdoptional (e.g., for global site admin role), the ID of the context
Returns
boolean

Definition at line 198 of file PKPValidation.inc.php.

References DAORegistry\getDAO(), and SessionManager\getManager().

Referenced by Validation\isPressManager(), Validation\isSeriesEditor(), and isSiteAdmin().

static PKPValidation::isLoggedIn ( )
static

Check if the user must change their password in order to log in.

Returns
boolean

Definition at line 294 of file PKPValidation.inc.php.

References SessionManager\getManager().

static PKPValidation::isLoggedInAs ( )
static

Check if the user is logged in as a different user.

Returns
boolean

Definition at line 306 of file PKPValidation.inc.php.

References SessionManager\getManager().

Referenced by UserGridRow\initialize(), and SubmissionLog\logEvent().

static PKPValidation::isSiteAdmin ( )
static

Shortcut for checking authorization as site admin.

Returns
boolean

Definition at line 318 of file PKPValidation.inc.php.

References isAuthorized().

Referenced by GenericPlugin\getManagementVerbs(), IndexHandler\index(), and LanguageGridRow\initialize().

static& PKPValidation::login (   $username,
  $password,
$reason,
  $remember = false 
)
static

Authenticate user credentials and mark the user as logged in in the current session.

Parameters
$usernamestring
$passwordstring unencrypted password
$reasonstring reference to string to receive the reason an account was disabled; null otherwise
$rememberboolean remember a user's session past the current browser session
Returns
User the User associated with the login credentials, or false if the credentials are invalid

Definition at line 26 of file PKPValidation.inc.php.

References HookRegistry\call(), encryptCredentials(), DAORegistry\getDAO(), Config\getVar(), and PluginRegistry\loadCategory().

Referenced by PKPLoginHandler\implicitAuthReturn(), RegistrationHandler\registerUser(), PKPLoginHandler\savePassword(), and PKPLoginHandler\signIn().

static PKPValidation::logout ( )
static

Mark the user as logged out in the current session.

Returns
boolean

Definition at line 130 of file PKPValidation.inc.php.

References DAORegistry\getDAO(), and SessionManager\getManager().

Referenced by PKPLoginHandler\signIn(), and PKPLoginHandler\signOut().

static PKPValidation::redirectLogin (   $message = null)
static

Redirect to the login page, appending the current URL as the source.

Parameters
$messagestring Optional name of locale key to add to login page

Definition at line 152 of file PKPValidation.inc.php.

References PKPRequest\redirect().

Referenced by PKPUserHandler\authorizationDenied().

static& PKPValidation::registerUserSession (   $user,
$reason,
  $remember = false 
)
static

Mark the user as logged in in the current session.

Parameters
$userUser user to register in the session
$reasonstring reference to string to receive the reason an account was disabled; null otherwise
$rememberboolean remember a user's session past the current browser session
Returns
mixed User or boolean the User associated with the login credentials, or false if the credentials are invalid

Definition at line 91 of file PKPValidation.inc.php.

References Core\getCurrentDate(), DAORegistry\getDAO(), SessionManager\getManager(), and Config\getVar().

static PKPValidation::suggestUsername (   $firstName,
  $lastName 
)
static

Suggest a username given the first and last names.

Returns
string

Definition at line 281 of file PKPValidation.inc.php.

References DAORegistry\getDAO(), String\regexp_replace(), String\strtolower(), and String\substr().

Referenced by UserGridHandler\suggestUsername().


The documentation for this class was generated from the following file: