Developing New Scripts

Directory Structure

The scripts that make up the system are seperated into just two directories. The main root directory contains all the scripts that are called directly from links in the system. Scripts or portions of scripts that are included in one or more of the main scripts are held in the includes/ sub-directory. The scripts to create the database are held under the sql directory - these are sql scripts created by mysqldump. Documentation is under the doc/ sub-directory where this manual and the FAQ are held. Font files required by pdf.php the R&OS class file for creating pdf reports are held in the fonts/ sub-directory. Formatting style sheets are held under the css - see the themes section under getting started above.

Construction of new scripts should make use of the following building blocks that are used throughout the system.

session.inc

This page must be included after the page has set the variable $PageSecurity to an appropriate integer (see the security schema section), session.inc has the following functons:

header.inc

This file should be included after the variable $title has been set to the name of the page. This file relies on config.php being already loaded, so session.inc (which in turn includes config.php) must be included before header.inc. The code in this script has the following functions:

footer.inc

This file contains the small logo, company name and copyright notice with the closing "" tags.

config.php

The developer should familiarise themselves with the variables in config.php as these are available to all scripts that have included session.inc. Of particular use is $rootpath which is the directory where the web server holds the system files. Having started the page with session.inc and header.inc - and then finishing with footer.inc much of the work to ensure a consistent look and feel is already done.

PDFStarter.php

The only time when it is not appropriate to include session.inc or header.inc is when a pdf script is to be created. Here the file PDFStarter.php contains the initiation of the session and the check for proper user authentication and authorisation for the specific page using the $PageSecurity variable which must be defined before PDFStarter.php is included. Normally, config.php and ConnectDB.inc are included seperately (and before PDF_starter_ros.inc) in PDF scripts. PDF report scripts all make use of the FPDF class by Olivier Plathey but previously a differnt class was used so there is an extension to this which translates the calls to the old pdf class to the FPDF class. Probably better to write new scripts using the FPDF syntax.

Database Abstraction - ConnectDB.inc

Whilst the system has been developed using MySql it has always been envisaged that users should not be forced to use Mysql - in keeping with open source principles. For this reason all requests of the database are made via abstraction functions in ConnectDB.inc. This policy has been rigorously maintained and developing extensions to the system which do not conform to this scheme would destroy the portability currently available between databases. Instead of using the PHP database specific functions then the functions defined in ConnectDB_mysql.inc should be used The full list of functions should be reviewed from the file includes/ConnectDB_mysql.inc - which contains the mysql specific abstraction functions. Only these functions should be used in other scripts. Care has been taken to ensure that standards compliant SQL is used throughout, to ensure any database conversion issues are minimal. SQL specific to any RDBMS even mysql should be avoided in favour of generic standards compliant SQL. There are instances where mysql specific SQL has been used such as INTERVAL and SHOW TABLES - these are historical.

DateFunctions.inc

This script holds a number of functions for manipulating dates used throughout the system - amongst the most useful:

SQL_CommonFuctions.inc

This script has some common functions used throughout the system - in particular: