Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 3 Module Framework : Metadata Framework : Application Metadata

Application Metadata
All application modules are defined in the modules.php file. It contains several variables that define which modules are active and usable in the application.
The file is located under the ‘<sugar root>/utils’ folder. It contains the $moduleList() array variable which contains the reference to the array key to look up the string to be used to display the module in the tabs at the top of the application, the coding standard is for the value to be in the plural of the module name (i.e. Contacts, Accounts, Widgets, etc).
The $beanList() array stores a list of all active beans (modules) in the application. The $beanList entries are stored in a ‘name’ => ‘value fashion with the ‘name’ value being in the plural and the ‘value’ being in the singular of the module name. The ‘value’ of a $beanList() entry is used to lookup values in our next modules.php variable, the $beanFiles() array.
The $beanFiles variable is also stored in a ‘name’ => ‘value’ fashion. The ‘name’ is typically the singular and a reference to the class name of the object which is looked up from the $beanList ‘value’ and the ‘value’ is a reference to the class file. From these three arrays you can include the class, instantiate an instance, and execute module functionality.

For example:
global $moduleList,$beanList,$beanFiles;
$module_object = ‘Contacts’;
$class_name = $beanList[$module_object];
$class_file_path = $beanFiles[$class_name];
require_once($class_file_path);
$new_module_object = new $class_name();
$module_string_name = $moduleList[$module_object];
 
The remaining relevant variables in the modules.php file are the $modInvisList variable which makes modules invisible in the regular UI (i.e., no tab appears for these modules), and the $adminOnlyList which is an extra level of security for modules that are supposed to only be accessed by administrators via the admin panel.
 

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License