Application Configuration
In File: application/byhand/Application Configuration.html Andromeda allows configuration settings to be made at the application, instance and user levels, as well as in code. The configuration options cover many different areas of an application. A Note About applib.phpAll programmatic overrides of framework behavior are done by creating routines in the file "applib.php", which should be placed in your application's "application" directory. The file "applib.php" can also contain any general purpose functions or classes that you wish to have universally available to your entire application. Executing Code at the Beginning of a RequestAny code that you place at the top of applib.php, which is not wrapped in a function or class, will execute at the beginning of any web request. This code runs in global scope. When the code executes, the framework is already loaded, but you should assume you do not know anything yet about the user or the page request. Code placed here should be designed to run unconditionally no matter who is logged in or what page they are going to. Controlling LoginsNormally logins are handled in the background by Andromeda. If you wish to excercise additional restrictions in code, or execute additional code when a user logins, you can create the function "app_login_process" inside of applib.php. The function is only called after the user's user_id and password have been verified, but before their session is reset and their menu is built.
function app_login_process($uid,$pwd,$admin,$groups) {
# $uid and $pwd are the user's
# supplied values for user_id and password
# the $admin variable is true if the user
# is a "root" user
# Groups is a comma-separated list of groups,
# which for bizarre historical reasons has each
# individual value surrounded by single quotes
# return true to allow the login, false to reject
if( $someRandomCondition) {
return false;
}
else {
return true;
}
}
Actions After Database ConnectionIf you wish to perform some action immediately after the user has connected to the database, put a function "app_after_db_connect()" into androlib. It takes no parameters, and no return value is expected. Any code that runs in this function will have an open database connection, and you can use functions like "inGroup('groupname')" to get information on what groups the user is in. Specifying a Default PageYou can control what page a user is sent to if they have not specified a page. This normally happens on their first site hit and immediately after they log in. Put a function "app_noPage()" into "applib.php". This function expects no parameter and returns no value. When this function executes, you have an open database connection and full knowledge about the user.
# Typical example that picks a public website for
# anonymous users and logged-in customers, and
# goes to the menu page for insiders.
function app_noPage() {
# This assumes you have defined a
# group named "customers"
if(!LoggedIn() || inGroup('customers')) {
# ...and we assume you've created
# a page called "splashpage" that
# is in file "splahspage.php"
# that contains a class "splashpage"
gpSet('gp_page','splashpage');
}
else {
# Send insider users to the default
# Extended desktop menu
gpSet('x4Page','menu');
}
}
Specifying A TemplateIf your application has no public website, you do not need to specify a template. The framework will pick 'pixel2' if you have an Extended Desktop application, and it will pick 'rt_pixel' if you do not. If you are using the Extended Desktop pixel2 template for insiders, but public visitors are using a template like "glitzy_public", then you can create a function "app_template()" in "applib.php" that returns the name of the template to use:
# Typical example that picks a public website for
# anonymous users and logged-in customers, and
# goes to Extended Desktop for insiders
function app_template() {
# This assumes you have defined a
# group named "customers"
if(!LoggedIn() || inGroup('customers')) {
return 'glitzy_public';
}
else {
return 'pixel2';
}
}
Specifying Extended Desktop ModeYou can specify in your dd.yaml file that you want your application to always go into Extended Desktop mode after users have logged in. Put this line into your dd.yaml file:
content configapp:
columns: [ x4menu ]
update:
- [ 'Y' ]
Note that this flag is only meaningful for business applications that use the default Andromeda templates (either rt_pixel or pixel2). It has no bearing on your public-facing templates. Review of Page Requesting HandlingThe following chart shows the steps in which a request is handled by Andromeda, including those points where it calls out to optional programs in your "applib.php" file.
In File: application/byhand/Application Configuration.html Generated by robophp.php on Wed, 24 Dec 2008 12:21:28 -0500 |
