Module Application Structure
Prev | Chapter 20. Adding a module to moregroupware | Next

## Module Application Structure

The following code block is takem from contacts/index.php, its the main module script for contacts. The very first 5 lines are important to be moregroupware-module compliant.

    <?php
          $myEnv["module"] = "contact";
          $myEnv["output"] = "html";

          include("../config.inc.php");
          include(INCLUDEPATH . "container.inc");

          // adding file revision into global array
          revisionInit("\$Revision: 1.3 $", __FILE__);

The first line is a declaration of the modulename, the modulename MUST be the same as the folder name. This string will be used in the complete framework to determine the different paths in the groupware. The second line identifies the output target, this will be normally html.

The next two lines are mandatory, you can copy them into your own module script. In the next chapter there is a description of what these two important includes do.

The last line adds the file's revision number to a global array, this is used as a debugging aid.

### Never use include($var/myinclude.php)!

Please use never an include like described above, because this way you open a big security hole. Always use something like this: include(ROOTPATH . "/folder/myinclude.php")

You should always use $HTTP_*_VARS to access input data! Never rely on register_globals being on! It is deprecated, insecure and clumsy!

### Don't use your own database connections

You see parameters like $appconf["dbuser"] or other database based parameters, please dont use them to create your own database connections, use the auto-generated $conn ADOdb object instead, more on this later.

Prev | Up | Next
Chapter 20. Adding a module to moregroupware | Home | What is the config.inc.php file?