What does container.inc do exactly?
Prev | Chapter 18. Adding a module to moregroupware | Next

## What does container.inc do exactly?

container.inc is just a container for other includes. It was introduced to package all includes into one file. All the includes which are in the container.inc dont have other includes itself. This mean there are only 2 include levels, the first is the container.inc and the second level are the includes inside container.inc. There is no 3. level. Below the content of container.inc:

    <?php
          /* $Id: coding_addmodule.xml,v 1.7 2003/11/01 21:41:28 emailtotom Exp $ */

          require_once(SMARTY_DIR . "Smarty.class.php");

          // definition of moregroupware class, holding application vars
          include(INCLUDEPATH . 'mgw.class.inc');

          // functions for translation
          include(INCLUDEPATH . 'lang.inc');

          // array for tracking file revision number used in sql error report screen
          $Revisions_array = Array();

          // important functions like connect to database
          include(INCLUDEPATH . 'userfunc.inc');

          // definition of moregroupware version and label
          include(INCLUDEPATH . 'version.inc');

          // Auto-Assigns for template engine and global definitions
          include(INCLUDEPATH . 'appconfig.inc');

          // include module specific functions if present (they are now in module/inc)
          // must be named module_func.inc.php (i.e. calendar_func.inc.php)
          if(file_exists(ROOTPATH . "/modules/" . $myEnv["module"]. "/inc/" . $myEnv["module"] . "_func.inc.php")) {
          include(ROOTPATH . "/modules/" . $myEnv["module"] . "/inc/" . $myEnv["module"] . "_func.inc.php");
          }

          // help system
          if(file_exists(ROOTPATH."/modules/".$myEnv["module"]."/help/index.".$MGW->spkz.".html")) $smarty->assign("helpurl", $myEnv["module"]."/help/index.".$MGW->spkz.".html");
          elseif(file_exists(ROOTPATH."/modules/".$myEnv["module"]."/help/index.en.html")) $smarty->assign("helpurl", $myEnv["module"]."/help/index.en.html");
          elseif(file_exists(ROOTPATH."/modules/general/help/index.".$MGW->spkz.".html")) $smarty->assign("helpurl","general/help/nohelp.".$MGW->spkz.".html");
          else $smarty->assign("helpurl","general/help/nohelp.en.html");

          // include module autoexecution of several things like translation, authentication, and more
          include(INCLUDEPATH . 'module_exec.inc');
          ?>

In the next sections, we show the meanings of each include.

### require_once(SMARTY_DIR . "Smarty.class.php");

This include loads the smarty classes which will be used by other includes (appconf.inc) and of course by the user scripts. Without this include, there wont be any output at all.

### include(INCLUDEPATH .'mgw.class.inc');

The MGW class will be stored in the user session in form of an object. This object holds many user related data such as languagecode, username or his current rights. We use this object for checking various things, without being forced to make any database queries. You will learn how to use this class later on, because its very important for your module.

### include(INCLUDEPATH .'lang.inc');

This include provides the language functions which we need also in appconf.inc and sometimes in the userscripts.

### include(INCLUDEPATH .'userfunc.inc');

This is the place where we store system wide useful functions. These are functions which could useful in each module. Dont place functionalities for specialized module tasks in there.

### include(INCLUDEPATH .'version.inc');

This is the most simple include, the version.inc only contains the release number and the name of the product, this will be displayed in some places inside the groupware. See bottom status bar for example in each screen.

### include(INCLUDEPATH .'appconfig.inc');

This is the most complex include, it does various things, below is a list of things which are important to know as a programmer:

- creation of $appconf["gentemplates"], this points to the general/templates/html folder, this will be used for including html fragment from the general folder, instead of the current module template folder, within the template you can reach this variable with {$gentemplates}

- creation of $appconf["imgpath"] and $appconf["imgpathgeneral"], this point to the module image path or to the general image path (name of folder is "media"). You will need this variables inside templates. You can reach them with {$imgpath} or {$imgpathgeneral} inside templates.

- creation of $smarty object, this object you will use to program the output of your module, you will most likely use methods like $smarty->assign(), $smarty->append() and $smarty->display().

- the session will be started in this include

- following templates variables will be auto-created and should be used in the templates: {$PHPSESSID} (actual session id of user), {$rooturl}, {$username}, {$userfullname}, {$phpself}, {$gwversion}, {$gwtitle}. If you dont know some meaning, just insert them in your template, you will see what is being thrown out :)

- creation of main-menu

### include(INCLUDE .'module_exec.inc');

The module_exec include is the only include which you can control from the outside, the operations executed inside can be controlled by flags which you can define in your script. Take a look in the next topic for a detailed view on this include.

Prev | Up | Next
What is the config.inc.php file? | Home | Whats special about module_exec.inc