NAME

Slash::Utility::Environment - SHORT DESCRIPTION for Slash


SYNOPSIS

        use Slash::Utility;
        # do not use this module directly


DESCRIPTION

LONG DESCRIPTION.


EXPORTED FUNCTIONS

getCurrentMenu([NAME])

Returns the menu for the resource requested.

Parameters
NAME
Name of the menu that you want to fetch. If not supplied, menu named after active script will be used (i.e., the ``users'' menu for ``users.pl'').

Return value
A reference to an array with the menu in it is returned.

getCurrentUser([MEMBER])

Returns the current authenicated user.

Parameters
MEMBER
A member from the users record to be returned.

Return value
A hash reference with the user information is returned unless VALUE is passed. If MEMBER is passed in then only its value will be returned.

setCurrentUser(MEMBER, VALUE)

Sets a value for the current user. It will not be permanently stored.

Parameters
MEMBER
The member to store VALUE in.

VALUE
VALUE to be stored in the current user hash.

Return value
The passed value.

setCurrentForm(MEMBER, VALUE)

Sets a value for the current user. It will not be permanently stored.

Parameters
MEMBER
The member to store VALUE in.

VALUE
VALUE to be stored in the current user hash.

Return value
The passed value.

createCurrentUser(USER)

Creates the current user.

Parameters
USER
USER to be inserted into current user.

Return value
Returns no value.

getCurrentForm([MEMBER])

Returns the current form.

Parameters
MEMBER
A member from the forms record to be returned.

Return value
A hash reference with the form information is returned unless VALUE is passed. If MEMBER is passed in then only its value will be returned.

createCurrentForm(FORM)

Creates the current form.

Parameters
FORM
FORM to be inserted into current form.

Return value
Returns no value.

getCurrentCookie([MEMBER])

Returns the current cookie.

Parameters
MEMBER
A member from the cookies record to be returned.

Return value
A hash reference with the cookie incookieation is returned unless VALUE is passed. If MEMBER is passed in then only its value will be returned.

createCurrentCookie(COOKIE)

Creates the current cookie.

Parameters
COOKIE
COOKIE to be inserted into current cookie.

Return value
Returns no value.

getCurrentStatic([MEMBER])

Returns the current static variables (or variable).

Parameters
MEMBER
A member from the static record to be returned.

Return value
A hash reference with the static information is returned unless MEMBER is passed. If MEMBER is passed in then only its value will be returned.

createCurrentStatic(HASH)

Creates the current static information for non Apache scripts.

Parameters
HASH
A hash that is to be used in scripts not running in Apache to simulate a script running under Apache.

Return value
Returns no value.

getCurrentAnonymousCoward([MEMBER])

Returns the current anonymous corward (or value from that object).

Parameters
MEMBER
A member from the AC redcord to be returned.

Return value
If MEMBER, then that value is returned; else, the hash containing all the AC info will be returned.

createCurrentAnonymousCoward(HASH)

Creates the current anonymous coward for non Apache scripts.

Parameters
HASH
A hash that is to be used in scripts not running in Apache to simulate a script running under Apache.

Return value
Returns no value.

getCurrentVirtualUser()

Returns the current virtual user that the site is running under.

Return value
The current virtual user that the site is running under.

createCurrentVirtualUser(VIRTUAL_USER)

Creates the current virtual user for non Apache scripts.

Parameters
VIRTUAL_USER
The current virtual user that is to be used in scripts not running in Apache to simulate a script running under Apache.

Return value
Returns no value.

getCurrentDB()

Returns the current Slash::DB object.

Return value
Returns the current Slash::DB object.

createCurrentDB(SLASHDB)

Creates the current DB object for scripts not running under Apache.

Parameters
SLASHDB
Pass in a Slash::DB object to be used for scripts not running in Apache.

Return value
Returns no value.

isAnon(UID)

Tests to see if the uid passed in is an anonymous coward.

Parameters
UID
Value UID.

Return value
Returns true if the UID is an anonymous coward, otherwise false.

getAnonId([FORMKEY])

Creates an anonymous ID that is used to set an AC cookie, with some random data (well, as random as random gets)

Parameters
FORMKEY
Return the same value as normal, but without prepending with a '-1-'. The normal case, with '-1-', is for easy identification of cookies. This case is for use with formkeys.

Return value
A random value based on alphanumeric characters

bakeUserCookie(UID, PASSWD)

Bakes (creates) a user cookie from its ingredients (UID, PASSWD).

Currently cookie is hexified: this should be changed, no need anymore, perhaps? -- pudge

Parameters
UID
User ID.

PASSWD
Password.

Return value
Created cookie.

eatUserCookie(COOKIE)

Digests (parses) a user cookie, returning it to its original ingredients (UID, password).

Currently cookie is hexified: this should be changed, no need anymore, perhaps? -- pudge

Parameters
COOKIE
Cookie to be parsed.

Return value
The UID and password encoded in the cookie.

setCookie(NAME, VALUE, SESSION)

Creates a cookie and places it into the outbound headers. Can be called multiple times to set multiple cookies.

Parameters
NAME
NAme of the cookie.

VALUE
Value to be placed in the cookie.

SESSION
Flag to determine if the cookie should be a session cookie.

Return value
No value is returned.

prepareUser(UID, FORM, URI [, COOKIES])

This is called to initialize the user. It is called from Slash::Apache::User::handler, and from createEnvironment (so it can set up a user in ``command line'' mode). See those two functions to see how to call this function in each kind of environment.

Parameters
UID
The UID of the user. Can be anonymous coward. Will be anonymous coward if uid is not defined.

FORM
The form data (which may be the same data returned by getCurrentForm).

URI
The URI of the page the user is on.

COOKIES
An Apache::Cookie object (not used in ``command line'' mode).

Return value
The prepared user data.

Side effects
Sets some cookies in Apache mode, sets currentPage (for templates) and bunches of other user datum.

filter_params(PARAMS)

This cleans up form data before it is used by the program.

Parameters
PARAMS
A hash of the parameters to clean up.

Return value
Hashref of cleaned-up data.

getObject(CLASS_NAME [, VIRTUAL_USER, ARGS])

Returns a object in CLASS_NAME, using the new() constructor. It passes VIRTUAL_USER and ARGS to it, and then caches it. If the object exists the second time through, it will just return, without reinitializing (even if different VIRTUAL_USER and ARGS are passed). That shouldn't be a problem, since you should only have one instance with one set of args required per Slash site.

Parameters
CLASS_NAME
A class name to use in creating a object.

VIRTUAL_USER
Optional; will default to main Virtual User for site if not supplied. Passed as second argument to the new() constructor (after class name).

ARGS
Any other arguments to be passed to the object's constructor.

Return value
An object.

errorLog()

Generates an error that either goes to Apache's error log or to STDERR. The error consists of the package and and filename the error was generated and the same information on the previous caller.

Return value
Returns 0;

writeLog(DATA)

Places optional data in the accesslog.

Parameters
DATA
Strings that are concatenated together to be used in the SLASH_LOG_DATA field.

Return value
No value is returned.

createEnvironment([VIRTUAL_USER])

Places data into the request records notes table. The two keys it uses are SLASH_LOG_OPERATION and SLASH_LOG_DATA.

Parameters
VIRTUAL_USER
Optional. You can pass in a virtual user that will be used instead of $ARGV[0].

Return value
No value is returned.


SEE ALSO

Slash(3), Slash::Utility(3).


VERSION

$Id: Environment.pm,v 1.1.2.25 2001/09/14 19:38:09 pudge Exp $