ApTest Manager documentation: API: Account

Account

NAME

Account - manage accounts

AUTHOR

Shane P. McCarron <shane@aptest.com>

COPYRIGHT

Copyright 2001-2006 Applied Testing and Technology, Inc. All Rights Reserved.

SYNOPSIS

use Account;

# open up the account database for writing
my $acct = new Account(1);

# set user information
$acct->userInfo($username, { userData } );

# save the user information
$acct->save();

# get the list of users
@list = $acct->userList();

The Account object allows creation, updating, and management of user accounts. See the UserInfo object for tools to authenticate users and manage access control.

DATA STRUCTURE

lock
a handle to the lock that is set for the object
writeable
a boolean that indicates whether the session is open read/write
usingDBM
a boolean to indicate if the file is from a DBM source
users->
userName
a hash of information about each user defined in the suite {userName}->{email, fullname, phoneNumber, password, logintime, accesstime}
acl
a hash access control list for the features and test suites {acl}->{account, execute, browse, edit, manage}. Also sub-hashes for test suites in {acl}->{suiteName}
report
a hash containing report preferences, including a sub-hash containing report customizations on a per test suite/per report basis
{report}->{pref1, pref2},
{report}->{custom}->{suiteName}->{pref1, pref2}

METHODS

new - open up the account file

$acct = new Account(read/write [, timeout]);

Creates a new account object.

read/write - boolean set to True if the existing session needs to be writeable. Defaults to readOnly.

timeout - the number of seconds to wait for a lock. Defaults to 60 seconds.

returns a reference to the Account object.

path - get the path to the account database

returns a path to the account database file

print - print the contents of the account list

$acct->print();
$acct->print(user);

returns the string-ified version of the entire session, or just the contents of test testNum, if specified.

hasExpired - accessor to see if the license has expired

$exp = $acct->hasExpired;

Returns 1 if the license has been recorded as expired, and 0 if it has not.

maxLoggedInWhen - tell when the high water mark was hit

Returns the time when the high water mark in terms of logged in users was hit, or the current time if no high water mark is defined.

maxLoggedIn - tell how many users at the high water mark

Returns the maximum number of users ever logged in, or 0 if no high water mark is defined.

sessClear - clear an individual session custom setting

$setting = $acct->sessClear(user, sid, name ) ;

clears out the setting from the session data structure.

Returns nothing.

sessSet - set/get an individual session custom setting

$setting = $acct->sessSet(user, sid, name [, value] );

returns the individual setting, or undef if it is not defined. If a value is provided, it updates the setting data structure with the new setting for "name".

setting - set/get an individual custom setting

$setting = $acct->setting(user, name [, value] );

returns the individual setting, or undef if it is not defined. If a value is provided, it updates the setting data structure with the new setting for "name".

fullname - return the fullname for a username

$fullname = $acct->fullname(userId) ;

userId - an id of a user in the database

Returns the fullname for the user, or the userId if there is no fullname.

clear - delete a setting from a user

$setRef = $acct->clear(user, setting) ;

Removes the setting from the user, if the user has one at all.

Returns nothing.

lastChange - get/set the last major change time

$last = $acct->lastChange ( [time() ] );

A major change is defined as one that changes the list of users and/or the list of users that have access to specific test suites.

Returns the last time. If the optional parameter is supplied, sets the last change time to then.

settings - set/get the user's custom settings

$setRef = $userInfo->settings( user [, settings ] );

returns a reference to the settings hash within the user's data structure, or replaces the settings hash with an updated version and marks the data structure as dirty.

sessionList - return a list of sessions

@list = $acct->sessionList( [ sortDir [, $uname ] ] );

returns a list of all sessions, or sessions for only a specific user.

each list item is a reference to a hash containing:

remove - remove a user from the database

$acct->remove(user);

Returns 1 on success.

numUsers - accessor for the number of users

$acct->numUsers();

returns the number of users in the database.

save - save the Accout DB

Flushes the database to disk

buildUserHash - force a rebuild of the hash

$acct->buildUserHash() ;

Rebuilds the internal userhash structure. Returns nothing.

renameSuite - handle a suite rename

$acct->renameSuite(oldname, newname);

Will traverse the database and update settings to reference the new suite name.

userHash - return a hash of users by shortname

%hash = $acct->userHash();

returns a hash whose keys are the short names, and values are the fullnames of each user. The list is based upon an internal cache that is maintained by the object itself.

userList - return a complete list of users

$acct->userList();

returns a sorted array of the names of the defined users.

userList(Suite [, perm])

Returns a sorted array that includes only the users with access to suite Suite.

userInfo - accessor for user account attributes

$acct->userInfo(username);
$acct->userInfo(username, dataHash);

username is the user account data

dataHash is a hash of fields for the user. If you "undef" a field, then its contents will be removed.

Defined attributes for a user include:

fullname
the full name of the user.
email
the email address of the user.
groups
the comma-separated list of "groups" in which this user is a member.
phoneNumber
the phone number of the user.
password
the password for the user.
logintime
the time the user logged in.
accesstime
the time the user last accessed the system.

returns the handle to the userInfo hash.

zonePicker - present menus for picking a timezone

$output = $acct->zonePicker(formName, varname, current);

formName is the name for this form on the page.

varname is the name of the HTML form variable to use.

current is the current setting.

Returns the HTML to generate the timezone picker selection elements.

Copyright © 2000-2006 Applied Testing and Technology, Inc. All rights reserved.