Index  Up  <<  >>  


User Database functions

The user database features are implemented as a series of functions attached to the userdb tag. The functions are:

login
Active parameters: username, password, crypt, pass_field, ignore_case

Log in to Minivend. By default, the username is contained in the form variable mv_username and the password in mv_password. If the login is successful, the session value username ([data session username]) will be set to the user name.

This will recall the values of all non-special fields in the user database and place them in their corresponding user form variables.

The CookieLogin directive (catalog.cfg) allows users to save their username/password in a cookie. Expiration time is set by SaveExpire, renewed every time they log in. To cause the cookie to be generated originally, the form variable mv_cookie_password or mv_cookie_username must be set in the login form. The former causes both username and password to be saved, the latter just the username.

logout
Log out of Minivend. No additional parameters are needed.

new_account
Active parameters: username, password, verify, assign_username, username_mask, ignore_case

Create a new account. It requires the username, password, and verify parameters, which are by default contained in the form variables mv_username, mv_password, mv_verify respectively.

If you set the assign_username parameter, then UserDB will assign a sequential username. The counter parameter can be used to set the filename (must be absolute), or you can accept the default of CATALOG_DIR/etc/username.counter. The first username will be ``U0001'' if the counter doesn't exist already.

The ignore_case parameter forces the username and password to lower case in the database, in effect rendering the username and password case-insensitive.

If you set username_mask to a valid Perl regular expression (without the surrounding / /) then any username containing a matching string will not be allowed for use. For example, to screen out order numbers from being used by a random user:

    [userdb function=new_account
            username_mask="^[A-Z]*[0-9]"
            ]

The CookieLogin directive (catalog.cfg) allows users to save their username/password in a cookie. Expiration time is set by SaveExpire, renewed every time they log in. To cause the cookie to be generated originally, the form variable mv_cookie_password or mv_cookie_username must be set in the login form. The former causes both username and password to be saved, the latter just the username.

If you want to automatically create an account for every order, you can do in the OrderReport file:

    [userdb function=new_account
            username="[value mv_order_number]"
            password="[value zip]"
            verify="[value zip]"
            database="orders"
            ]

This would be coupled with a login form that asked for order number and zip code; thereupon allowing you to display the contents of a transaction database with (presumably updated) order status information or a shipping company tracking number.

change_pass
Active parameters: username, password, verify, oldpass

Change the password on the currently logged-in account. It requires the username, password, verify, and oldpass parameters, which are by default contained in the form variables mv_username, mv_password, mv_verify, mv_password_old respectively.

set_shipping
Active parameters: nickname, shipping, ship_field

Place an entry in the shipping Address book. Example:

    [userdb function=set_shipping nickname=Dad]

See Address Book below.

get_shipping
Active parameters: nickname, shipping, ship_field

Recall an entry from the shipping Address book. Example:

    [userdb function=get_shipping nickname=Dad]

See Address Book below.

get_shipping_names
Active parameters: ship_field

Gets the names of shipping address book entries and places them in the variable address_book. By default, it does not return the values; if you wish them to be returned you can set the parameter show to 1, as in:

    [set name=shipping_nicknames
         interpolate=1]
      [userdb function=get_shipping_names show=1]
    [/set]

set_billing
Active parameters: nickname, billing, bill_field

Place an entry in the billing accounts book. Example:

    [userdb function=set_billing nickname=discover]

See Accounts Book below.

get_billing
Active parameters: nickname, billing, bill_field

Recall an entry from the billing accounts book. Example:

    [userdb function=get_billing nickname=visa]

See Accounts Book below.

save
Saves all non-special form values that have columns in the user database.

set_cart
Save the contents of a shopping cart.

    [userdb function=set_cart nickname=christmas]

See Carts below.

get_cart
Active parameters: nickname, carts_field, target

Recall a saved shopping cart.

    [userdb function=get_cart nickname=mom_birthday]

Setting target saves to a different shopping cart than the default main cart. The carts_field controls the database field used for storage.

set_acl
Active parameters: location, acl_field, delete

Set a simple acl. Example:

    [userdb function=set_acl location=cartcfg/editcart]

This allows the current user to access the page ``cartcfg/editcart'' if it is access-protected.

To delete access, do:

    [userdb function=set_acl location=cartcfg/editcart delete=1]

To display the setting at the same time as setting use the show attribute:

    [userdb function=set_acl location=cartcf/editcart show=1]

check_acl
Active parameters: location, acl_field

Checks the simple access control listing for a location, returning 1 if allowed and the empty string if not allowed.

    [if type=explicit
        compare="[userdb
                    function=check_acl
                    location=cartcfg/editcart]"
    ]
    [page cartcfg/editcart]Edit your cart configuration[/page]
    [/if]

set_file_acl, set_db_acl
Active parameters: location, mode, db_acl_field, file_acl_field, delete

Sets a complex access control value. Takes the form:

    [userdb function=set_file_acl
            mode=rw
            location=products/inventory.txt]

where mode is any value you wish to check for with check_file_acl. As with the simple ACL, you can use delete=1 to delete the location entirely.

check_file_acl, check_db_acl
Active parameters: location, mode, db_acl_field, file_acl_field

Checks a complex access control value and returns a true/false (1/0) value. Takes the form:

    [userdb function=check_db_acl
            mode=w
            location=inventory]

where mode is any value you wish to check for with check_file_acl. It will return true if the mode string is contained within the entry for that location. Example:

    [if type=explicit
        compare="[userdb
                    function=check_db_acl
                    mode=w
                    location=inventory]"
    ]
    [userdb function=set_acl location=cartcfg/edit_inventory]
    [page cartcfg/edit_inventory]You may edit the inventory database[/page]
    [else]
    [userdb function=set_acl location=cartcfg/edit_inventory delete=1]
    Sorry, you can't edit inventory.
    [/if]


Index  Up  <<  >>