9.5. Modules

Userpanel is built with modularity principle, which means that each module, which represents one menu entry is contained in separate subdirectory of modules directory.

9.5.1. Construction of module

This graph represents directory structure of typical module:

    |     |---en
    |          |---strings.php
    |     |---default
    |          |---image.gif
    |     |---template1.html
    |     |---template2.html
    |     |---mysql.2005081901.php
    |     |---postgres.2005081901.php

This requires a few words of explanation:

9.5.2. Mandatory files configuration.php

This file contains configuration of given module and is always included during Userpanel initialization. Usually it's built as follows:

$USERPANEL->AddModule(trans('Help'),      // Name in menu
                    'help',             // Module name (must be identical as module dir)
                    trans('Runs problems solving creator'), // Tip (on menu hover)
                    5,                  // Priority (lower first)
                    trans('This module shows solving problems creator'), // Description
                    2005081901,         // DB version (similar to LMS, see 
                                        // lms/lib/upgradedb.php)
		    array(		// Array of submenus im LMS-UI Userpanel menu
		        array(		// (see lib/LMS.menu.php)
			    'name' => trans('Submenu'),
			    'link' => '?m=userpanel&module=help',
			    'tip' => trans('Tooltip'),
?> functions.php

This file contains given module functions. There is special function, named module_main() executed first when module is called. If any function is intended to be accessible from Userpanel UI, it should be prefixed with module_, ie. module_function1(), which will be available from the following URL: http://userpanel/?m=module&f=function1. Function named module_setup() is being called from configuration panel of LMS-UI.