This manual is deprecated. Please visit https://groupoffice.readthedocs.io for the latest documentation.

Extending settings with your own module

From Group-Office Groupware and CRM Documentation
Jump to: navigation, search

When creating your own module then you probably would have some module settings that you want to add to the Group-Office settings panel.

Therefore you will need to add your form fields to the settings tab panel and you will need to add some PHP code in your own module to handle those form fields.

The javascript code

You need to add a tab for your own module to the settings window.

Therefore you need to create a panel and you will need the code to add the panel to the existing tabbed form panel.

The code for an example panel:


GO.modulename.SettingsPanel = function(config) {
  
  if (!config)
    config = {};

  config.autoScroll = true;
  config.border = false;
  config.hideLabel = true;
  config.title = GO.modulename.lang.tabtitle;
  config.hideMode='offsets';
  config.layout = 'form';
  config.labelWidth=125;
  config.bodyStyle='padding:5px;';
  config.items = {
   // Add the form elements here
  }

  GO.modulename.SettingsPanel.superclass.constructor.call(this, config);
};


Ext.extend(GO.modulename.SettingsPanel, Ext.Panel, {

}

If you want to do something with the form fields of your module before you submit them or before they are loaded then you can extend your created settingspanel:


Ext.extend(GO.modulename.SettingsPanel, Ext.Panel, {

  ......

  onSaveSettings : function() {
    // The code that needs to be executed before the form is submitted.
  },
	
  ......

  onLoadSettings : function(action){
    // The code that needs to be executed before the loading is complete.
  }

  ......

});


The code to add your panel to the settings window as a new tab:


GO.mainLayout.onReady(function() {
  GO.moduleManager.addSettingsPanel('modulename',
  GO.modulename.SettingsPanel);
});

The PHP code

In your ModulenameModule.php file you need to override 2 static functions:

For submitting your form fields you need to override the static "submitSettings" function:


class GO_Modulename_ModulenameModule extends GO_Base_Module{

  ......

  public static function submitSettings(&$settingsController, &$params, &$response, $user) {
		
    // Put the code to process the posted form fields here.
    // The form fields with their values are stored in $params 
   		
    return parent::submitSettings($settingsController, $params, $response, $user);
  }

  ......


For loading your form fields you need to override the static "loadSettings" function:

	

class GO_Modulename_ModulenameModule extends GO_Base_Module{

  ......

  public static function loadSettings(&$settingsController, &$params, &$response, $user) {
		
    // Put the code to load the form fields here.
    // The form field values need to be added to the $response parameter 

    return parent::loadSettings($settingsController, $params, $response, $user);
  }

  ......