Developing custom plugins

Domus Organizer has a very flexible design: you can add new features simply using plugins which can be installed through Joomla! extensions installer.

The plugins can belong to two groups:

domusintegration

In this group you will find the plugins that add new features to Domus Organizer.

domusimport

This group holds the plugins that will perform the data import inside Domus Organizer.

"domusintegration" plugin event

This plugin group will allow you to add new information in an unobtrusive way; it's a standard Joomla plugin, so the manifest file will be something like this:

Example 5.1. Example of manifest file for "domusintegration" plugin

<?xml version="1.0" encoding="iso-8859-1"?>
<extension type="plugin" group="domusintegration" version="1.6" method="upgrade">
  <name>Domus Organizer Integrations - Extend property sample</name>
  <author>Davide Tampellini</author>
  <creationDate>2014-03-27</creationDate>
  <copyright>GNU GPL</copyright>
  <license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
  <authorUrl>www.fabbricabinaria.it</authorUrl>
  <version>1.0.0</version>
  <description>Example plugin to extend property info</description>

  <files>
    <filename plugin="extendproperty">extendproperty.php</filename>
    <filename>index.html</filename>
  </files>

</extension>

Every section of Domus Organizer will fire a specific event, can you intercept and handle.

Property events

The following events will be fired while dealing with properties

onDomusIntegrationPropertyRead

Prototype: (array) public function onDomusIntegrationPropertyRead($property)

Synopsis: This event is called in the admin area, while creating the tabs for the property (read tasks)

Sample plugin: plugins/domusintegration/extendproperty/extendproperty.php

This event is fired when a property is displayed in read mode inside the administrative area.

The $property variable is a FOFTable class that holds all the data fetched from the database. Since in this view the user can't edit any data, the plugin should not display any form elements or input fields.

The returning array must have two keys:

  • tabname it's the name of the tab that will be created

  • content Is the actual content of the new tab. It's up to the plugin to supply the valid HTML and to retrieve the extra stored data

onDomusIntegrationPropertyEdit

Prototype: (array) public function onDomusIntegrationPropertyEdit($property)

Synopsis: This event is called in the admin area, while creating the tabs for the property (edit tasks)

Sample plugin: plugins/domusintegration/extendproperty/extendproperty.php

This event is fired when a property is displayed in edit mode inside the administrative area.

The $property variable is a FOFTable class that holds all the data fetched from the database. The plugin should not render any form elements, since it is already created by Domus Organizer; it only should create input fields and the code required to style them.

The returning array must have two keys:

  • tabname it's the name of the tab that will be created

  • content Is the actual content of the new tab. It's up to the plugin to supply the valid HTML and to retrieve the extra stored data

[Note]Name of input fields

Please pay extra attention while choosing the name of input fields: in order to avoid conflicts, you should give them a very unique name, maybe using the name of your plugin as prefix, like plg_extendproperty_first_field

These fields will be submitted automatically and you'll be able to save their values in the onDomusIntegrationPropertyAfterSave event (see below)

onDomusIntegrationPropertyBeforeSave

Prototype: (boolean) public function onDomusIntegrationPropertyBeforeSave($data, $table)

Synopsis: This event is called in the admin area, before saving a property

Sample plugin: plugins/domusintegration/extendproperty/extendproperty.php

This event is fired before saving a property inside the database, so you can create new checks for your additional fields or to tighten the existing checks inside Domus Organizer

The $data argument is an indexed array that holds the submitted data, while the $table variable is a FOFTable class that holds all the current data retrieved from the database.

onDomusIntegrationPropertyAfterSave

Prototype: (void) public function onDomusIntegrationPropertyAfterSave($property)

Synopsis: This event is called in the admin area, after a property has been saved

Sample plugin: plugins/domusintegration/extendproperty/extendproperty.php

This event is fired after the property is successfully saved in the database.

The $property variable is a FOFTable class that holds all the data just saved inside the database.

Customer events

The following events will be fired while dealing with customers

onDomusIntegrationCustomerRead

Prototype: (array) public function onDomusIntegrationCustomerRead($customer)

Synopsis: This event is called in the admin area, while creating the tabs for the customer (read tasks)

Sample plugin: N/A

This event is fired when a customer is displayed in read mode inside the administrative area.

The $customer variable is a FOFTable class that holds all the data fetched from the database. Since in this view the user can't edit any data, the plugin should not display any form or input field.

The returning array must have two keys:

  • tabname it's the name of the tab that will be created

  • content Is the actual content of the new tab. It's up to the plugin to supply the valid HTML and to retrieve the extra stored data

onDomusIntegrationCustomerEdit

Prototype: (array) public function onDomusIntegrationCustomerEdit($customer)

Synopsis: This event is called in the admin area, while creating the tabs for the customer (edit tasks)

Sample plugin: N/A

This event is fired when a customer is displayed in edit mode inside the administrative area.

The $customer variable is a FOFTable class that holds all the data fetched from the database. The plugin should not render any form elements, since it is already created by Domus Organizer; it only should create input fields and the code required to style them.

The returning array must have two keys:

  • tabname it's the name of the tab that will be created

  • content Is the actual content of the new tab. It's up to the plugin to supply the valid HTML and to retrieve the extra stored data

[Note]Name of input fields

Please pay extra attention while choosing the name of input fields: in order to avoid conflicts, you should give them a very unique name, maybe using the name of your plugin as prefix, like plg_extendcustomer_first_field

These fields will be submitted automatically and you'll be able to save their values in the onDomusIntegrationCustomerAfterSave event (see below)

onDomusIntegrationCustomerBeforeSave

Prototype: (boolean) public function onDomusIntegrationPropertyCustomerSave($data, $table)

Synopsis: This event is called in the admin area, before saving a customer

Sample plugin: N/A

This event is fired before saving a customer inside the database, so you can create new checks for your additional fields or to tighten the existing checks inside Domus Organizer

The $data argument is an indexed array that holds the submitted data, while the $table variable is a FOFTable class that holds all the current data retrieved from the database.

onDomusIntegrationCustomerAfterSave

Prototype: (void) public function onDomusIntegrationCustomerAfterSave($customer)

Synopsis: This event is called in the admin area, after a customer has been saved

Sample plugin: N/A

This event is fired after the customer is successfully saved in the database.

The $customer variable is a FOFTable class that holds all the data just saved inside the database.