UserInfo |
![]() |
UserInfo - class representing user account information
Shane P. McCarron <shane@aptest.com>
Copyright 2001-2006 Applied Testing and Technology, Inc. All Rights Reserved.
use UserInfo;
# create a new object from a username
my $info = new UserInfo($username);
# create a new object from a hash (sessionID)
my $info = newFromHash UserInfo($userhash);
# validate a user
$res = $info->authenticate($password);
# check access
$res = $info->access($suite, $feature);
# get/set report preferences
$prefs = $info->reportPref($suite, $report);
# get/set execution preferences
$prefs = $info->execPrefs($suite, $report);
The UserInfo object acts as a repository for access control information associated with a specific user.
$userInfo = new UserInfo([username [, accountHash]]);
Creates a new UserInfo object, optionally populating it with data about the user from the account database.
returns a reference to the UserInfo object. If the user is not defined, returns undef.
$userInfo = UserInfo->newFakeUser();
Returns a reference to a UserInfo object.
$userInfo = UserInfo->newFromHash(hash [, activity, request, readonly] );
Hash is an identifier returned by the userHash method above.
Activity is an optional string that reflects what the user is doing.
Request is an optional reference to an Apache Request object, and will be used to update the user's cookie.
Readonly is a boolean flag that forces the Account database to be opened in readonly mode, rather than the default read/write mode. If the Account database is only open in read mode, newFromHash won't update activities or re-insert an expired session.
Returns a reference to a userInfo object.
$userInfo->setCookie(sid, mason);
sid is an authentication token.
mason is a reference to an mason component object
Sets the cookie in the header for this request.
$userInfo->atime(activity);
Ensures that the access time is up to date.
Returns 1 if we do, 0 if we do not.
$userInfo->loadUser() ;
Updates the object's internal data with the current data from the database.
$userInfo->Lock() ;
Aquires an account database in write mode if necessary, then sets the lock on it. Designed to perform a transaction. Do an Unlock to release the database.
$count = $userInfo->loggedIn();
Returns the current number of logged in users. See Account for more information.
$status = $userInfo->login( [ sid, activity, request ] );
sid - a session ID to reuse (for re-login of an established session)
activity - an optional indication of what the user is doing.
request - an optional reference to an Apache request object. If supplied, it will be used to update the cookie.
Sets the user's login time, generates a cookie, and stores that cookie in the user database. Requires write access to the user database.
Returns 1 if it succeeded, 0 if it failed.
$status = $userInfo->logout();
Removes the associated login record from the user database.
Returns 1 if it succeeded, 0 if it failed.
returns 9999 if it is set to unlimited returns the value from the USERS field of the license file.
$exp = $userInfo->expires() ;
$exp = $userInfo->supExpires();
$userInfo->access(suite, feature, suiteMode, closed);
suite is the test suite
feature is the feature to which access is needed. The list of currently defined features includes:
account - account management
suiteMode is the type of access to the suite. If not defined, the ACL must just not say "no".
closed is a boolean - do we care if ATM is closed or not right now? Default is true.
returns true if access is granted.
$aclRef = $userInfo->acl;
returns a reference to the ACL hash within the user data structure. If there is no ACL for a user, it returns undef.
Releases the optional account database, if it is attached.
$setting = $userInfo->sessSet(name [, value]) ;
name is the name of the session setting to use.
value is an optional value parameter to store in the setting.
returns the individual setting, or undef if it is not defined.
$setting = $userInfo->setting(name, subName [, value] ) ;
name is the name of a setting or setting collection.
subName is the name of a sub-setting in a collection (e.g., a suite name) ;
value is a value to store in the setting or subsetting.
returns the individual setting, or undef if it is not defined.
$setRef = $userInfo->settings;
returns a reference to the settings hash within the user's data structure
$ok = $userInfo->authenticate(password);
Returns true if the password is correct for the user.
$addr = $userInfo->email() ;
$pass = $userInfo->password() ;
$enc = $userInfo->encrypted() ;
$userInfo->print();
returns the string-ified version of the entire userinfo data structure.
$sid = $userInfo->sid() ;
%levels = $userInfo->alist();
returns a hash of test suite access level IDs and values
@list = $userInfo->anames();
returns a list of test suite access level names
@tips = $userInfo->atips();
returns a list of test suite access level tips
$level = $userInfo->alevel(suite) ;
suite is the name of a test suite.
Returns the access level for suite for this user.
@list = $userInfo->flist();
returns a list of feature names.
@features = $userInfo->fnames() ;
Returns a list of features descriptions.
$name = $userInfo->fullname();
$tz = $userInfo->lastLogin() ;
$tz = $userInfo->timezone() ;
$userInfo->Unlock();
Unlocks the associated account database. If it was acquired via a previous call to Lock, also releases the database. Tracks the depth of the Locks to ensure that only the last Unlock call actually releases the data file.
$rows = $userInfo->rowsPerPage() ;
$version = $userInfo->checkForUpdates() ;
($version, $error) = $userInfo->checkForUpdates() ;
Returns nothing, or the name of a newer version if one is available. In an array context, will also return any error message if there was one.
$string = $userInfo->checkVersion();
Returns a message about any new version(s) available, and undef if there is nothing to report.
$msg = $userInfo->shouldNotify();
Returns any message that should be send to people with the updates trigger.
Copyright © 2000-2006 Applied Testing and Technology, Inc. All rights reserved.