Information Technology

Adding to an Application

Once aLogin2 is setup you need to modify the web application to use it.  Please note that we haven't tested all possible places we could add the required lines, but the locations given here work.

You will need to add the following to the top of your web applications main php file.

<?php
require_once "path_to_configuration_file";
require_once XAJAX_PATH."/xajax_core/xajax.inc.php";
$xajax = new xajax();
require_once UTILITY_LIBRARY;
require_once DB_DATABASE_LIBRARY;
dl_dbinit();
include(ALOGIN_PATH."/aLoginXajaxFunctions.php");
include(ALOGIN_PATH."/aLoginAppObject.php");
?>

You must enter the path to the configuration file, but from there on you can enter the text as given here.  The order here is important so if you alter it you may have problems.

Next, after the <html> tag add

<?php
$xajax->printJavascript("XAJAX_URL");
?>

Notice that the line above requires XAJAX_URL not XAJAX_PATH.

Then, if you're using any of the provided interfaces, somewhere in the <head> tag include,

 <link rel="stylesheet" type="text/css" href="<?php echo EXT_URL?>/resources/css/ext-all.css" />
 <script type="text/javascript" src="<?php echo EXT_URL?>/adapter/ext/ext-base.js"></script>
 <script type="text/javascript" src="<?php echo EXT_URL?>/ext-all-debug.js"></script>

Next, somewhere in your javascript code you will need to create the login object, usually in a function that is called when the page loads.

loginObject = new aLoginAppObject(loginConfig);

The properties of the loginConfig object are listed below.

aLogin2 Configuration Properties

The properties of this object define the characteristics of the login process.

PROPERTYEXPLANATIONDEFAULT
loginDivID attribute of div tag that will contain the login interface.  If set to blank in the configuration object the user will have to construct the interface using the API calls available. (See article below for loginDiv interface).
"login_container"
borderPlace ExtJS border around the login interface.  Only relevant if loginDiv is defined.true
callbackFunction that should get the results of changes to the login status. If not provided, the results will never be passed back to the application.
instanceA string that identifies this particular instance of the aLoginObject.  Irrelevant unless the application is creating more than one instance.  It's unclear why this would ever be done.
successMessage to display on successful login"Login was successful"
failureMessage to display on login failure"Login failed"
newAccountsCan users create new accounts.  If false the option will not appear in the login interface.
true
changePassword

Can the user change passwords and email addresses.  If true, a change password/email option will appear in the login window.

Note that the user can't change the password until he's logged in.  Even if there is a default user defined, only users who log in can change the password.

true
newAccountMessageText for new account button.  This can contain html.  For example: "New Account: <i>Limited rights</i>""New Account"
loggedInShould the initialUser and initialPassword be considered as having "logged in". If true, then the option to change the password and email will be available to anybody.  This is very dangerous and we've yet to find a case where this would be a good idea.false
languageLanguage to use for the interfaces."English"
defaultLevel The authority level assigned to new users.  In general this should be low.  Persons requesting an authority level lower than this will get it automatically.  Persons requesting a higher level will get the default and an email message will be sent to the administrator notifying them of the request.
0
levels

This is only of use if allowing for new account requests.

An array of arrays for different authority levels and their titles.  This is used in creating the field users use to request an authority level and allows the renaming of the levels. If no array is provided, users will not be allowed to ask for a different level and will get the default level.  In setting up this array you should keep in mind the requirements of the application.  This example shows this array set up in a way that's compatible with aBlog.

levelArray = [
               [1,"User",60],
               [2,"Limited User",40],                         
               [3,"Visitor",20],
               [4,"Limited Visitor",10],
               [5,"Passerby",5],
               [6,"No Authority",0]
];

None
helpMessageText string offering help on picking authority level.
'No help available'
sessionLoginCauses the normal login interface to be skipped.  This assumes that the login process has been localized by modification of the localLoginChecks.php file to extract the username/password from session variables.  See Localization->Examples
False
localArrayArray of values that will be passed to the localization functions.  See the Localization page for more on how to localize you authentication process.Empty array
initialUserUser ID to use at object creation. String limited to 20 characters.
None
initialPassPassword to use at object creation. String limited to 20 characters.
None
initialALAuthority Level to use at object creation
None

The callback function can be complicated since it must be in a form that the login object understands.  So, for instance, if your application object wants the return to go to an internal  function called "acceptLogin", the callback can not be "acceptLogin" or "this.acceptLogin" since neither of these mean anything to the aLoginObject.  Instead, you can create a global variable called myApp and point it at your application, then you can pass "myApp.acceptLogin".

loginDiv Interface

If a loginDiv is passed to the aLogin object at creation, a login interface will automatically be build and displayed.

aLoginOptions

Besides the Login link, which of the other links appear is controlled by the configuration object for the aLogin object.