The mgiCreditBank Tag
Tag Behavior
The mgiCreditBank tag is used to manage on-line "credit" accounts.
Accounts are divided into groups that can be used for separate purposes
including fee-based articles, pictures or downloads and point-earning systems.
Tag Syntax
The mgiCreditBank tag has one required parameter and six optional parameters.
In addition, the mgiCreditBank tag has required and optional parameters
for specific modes. The tag form is:
<mgiCreditBank mode="Mode" amount="Integer" user="UserName"
group="GroupName" allowedURL="URL" deniedURL="URL"
unknownAccountURL="URL">
Required Parameters:
- mode="Mode" where "Mode" is the current
mode and functionality of mgiCreditBank. The modes are:
- "Admin" The Admin mode displays a web-based administrative
interface for mgiCreditBank that allows you to create, modify, and delete
credit bank groups, users, and credits. Each user name within a group must
be unique, although the same user name can be included in multiple groups.
The following is an example of the mgiCreditBank tag in Admin mode:
<mgiCreditBank mode="admin">
- "Increment" The Increment mode automatically and seamlessly
increases the credits in a user's account by the amount specified. The
user does not receive any automatic indication that their account has been
incremented. The amount, user and group
parameters are required with the Increment mode (see definitions
below under Optional Parameters). The following is an example of the mgiCreditBank
tag in Increment mode:
<mgiCreditBank mode="increment" amount="1"
user="UserName" group="GroupName">
- "DecrementAndRedirect" The DecrementAndRedirect mode
decrements the user's account by the amount specified (if enough credits
are available) and redirects the user to the URL specified in the allowedURL
parameter. If there are not enough credits available, the account is not
decremented and the user is redirected to the URL specified in the deniedURL
parameter. If the user name is not in the CreditBank, the user is redirected
to the URL specified in the unknownAccountURL parameter. The
amount, user, group, allowedURL, deniedURL
and unknownAccountURL parameters are required with the DecrementAndRedirect
mode (see definitions below under Optional Parameters). The following is
an example of the mgiCreditBank tag in DecrementAndRedirect mode:
<mgiCreditBank mode="DecrementAndRedirect"
amount="1" user="UserName" group="GroupName"
allowedURL="allowed.html" deniedURL="denied.html"
unknownAccountURL="unknown.html">
- "Decrement" The Decrement mode decrements a user's
account by the specified amount (if enough credits are available) and returns
(displays) the value "Yes". If enough credits are not available,
the user's account is not decremented and the value "No" is returned
(displayed). This mode was designed for use with other MGI tags such as
variables. The amount, user and group
parameters are required with the Decrement mode (see definitions
below under Optional Parameters). The following is an example of the mgiCreditBank
tag in Decrement mode:
<mgiCreditBank mode="decrement" amount="1"
name="UserName" group="GroupName">
- "Query" The Query mode displays the number of credits
currently in a user's account. If an account does not exist or if an error
is encountered, the value "0" is displayed. The
user and group parameters are required with the Query
mode (see definitions below under Optional Parameters). The following is
an example of the mgiCreditBank tag in Query mode:
<mgiCreditBank mode="query" user="UserName"
group="GroupName">
Optional Parameters:
- amount="Integer" where "Integer" is a whole
number between the values of 1 and 4,294,967,295.
- user="UserName" where "UserName" is the
name of the user in the specified group whose account will be incremented,
decremented or queried. User names are case-sensitive and must be unique
within each group.
- group="GroupName" where "GroupName" is the
name of the CreditBank group that contains the users whose account will
be incremented, decremented or queried.
- allowedURL="URL" where "URL" is the absolute
or relative path to the file where users are redirected when their account
is successfully decremented in the DecrementAndRedirect mode.
- deniedURL="URL" where "URL" is the absolute
or relative path to the file where users are redirected when an account
cannot be successfully in the DecrementAndRedirect mode.
- unknownAccountURL="URL" where "URL" is the
absolute or relative path to the file where users are redirected when a
user name does not exist in the DecrementAndRedirect mode.
Example Usage and Output
<mgiCreditBank mode="decrementAndRedirect"
amount="10" user={mgiFieldContent name="username"}
group="Subscribers" allowedURL="allowed.html"
deniedURL="notenoughcredits.html"
unknownAccountURL="unauthorized.html">
In this example, the user name is dynamically entered from a form submission
(posted argument) with an embedded mgiFieldContent tag. If the user name
exists and the user's account contains 10 or more credits, the account will
be debited and the user will be redirected to the page "allowed.html".
If the user's account exists, but does not contain at least 10 credits,
the user will be redirected to the page "notenoughcredits.html".
If the user's account does not exist in the "Subscribers" group,
the user will be redirected to the page "unauthorized.html".
Suggested Usage
- Subscriber-only picture-viewing site
- Subscriber-only news service
- Fee-Based Downloads
|