Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

The universal module Universal Module is the module to use when no other module will do. It allows you to specify what fields to ask for during checkout, and can even interact with a 3rd party API for provisioning of services. This is a powerful replacement to the "none" module in previous versions of Blesta.

Table of Contents
Table of Contents
maxLevel4
minLevel2
outlinetrue
classtoc

About The Universal Module

The Universal Module is the module to use when no other module will do. In some cases you may find that you need a module to request fields from a client for a particular service that will be provisioned manually. Dedicated servers are a perfect example of this. With the Universal Module you can create these fields dynamically, and even have them send a post or email notification when the service is added, updated, suspended, unsuspended, or canceled.

Using the Universal Module

Installing the Universal Module

...

Tip

When the module is installed, it should automatically load the "Manage" screen for the module. You can get back here any time by visiting [Settings] > [Company] > [Modules] > Installed and by clicking the "Manage" button for the module.

Adding a Product

Image Removed

Image Removed

Products

A Universal Module Product is a collection of package and service request fields, along with a few rules that apply to the product. The product acts as a template for creating packages and services.

Image Added

Module Options

OptionDescription
NameThe name for the product, shown when creating or editing a package.

Package Options

Package options are fields that are requested when a package is added or updated. A product can have any number of package options.

OptionDescription
LabelThe display name of the form field.
Name

The name of the input field. This is the name of the value sent in all post and email notifications, and is also used when validating input rules.

Info

If you've set the label to Email address then you'd likely want to set the name to email_address.

Type

The type of form field.

OptionDescription
TextA regular text input field.
TextareaA large text area field, for inserting multiple lines of text.
PasswordA password input field, masking the user's input.
SelectA drop-down menu.
RadioA radio field.
CheckboxA checkbox field.
HiddenA hidden field not visible to the user.
SecretA field that is never rendered or stored for the package, but is sent in all post and email notifications.
RequiredIf enabled, will require that some value is given for the field.
EncryptIf enabled, will store input values encrypted in the database.
ValuesSee Values Format.
Input RulesSee Input Rules.
NotificationsSee Notifications.

Service Options

Service options are fields that are requested when a service is added or updated. A product can have any number of service options.

Image Added

 

OptionDescription
LabelThe display name of the form field.
Name

The name of the input field. This is the name of the value sent in all post and email notifications, and is also used when validating input rules.

Info

If you've set the label to Email address then you'd likely want to set the name to email_address.

Type

The type of form field.

OptionDescription
TextA regular text input field.
TextareaA large text area field, for inserting multiple lines of text.
PasswordA password input field, masking the user's input.
SelectA drop-down menu.
RadioA radio field.
CheckboxA checkbox field.
HiddenA hidden field not visible to the user.
SecretA field that is never rendered or stored for the service, but is sent in all post and email notifications.
RequiredIf enabled, will require that some value is given for the field.
EncryptIf enabled, will store input values encrypted in the database.
ValuesSee Values Format.
Input RulesSee Input Rules.
NotificationsSee Notifications.

...

Values Format

The values field is a serialized list of field data in the format of name:value, delimited by the | (pipe) character. The name is the value stored for the field and value is the value displayed. For example, if you would like to request a list of check boxes of various flavors of ice cream you might enter: vanilla:Vanilla|chocolate:Chocolate|strawberry:Strawberry|rocky_road:Rocky Road

...

Input rules are a JSON encoded associative array object of input validation rules. They allow you to specify how each field should be validated against errors on input. For additional details on input rules see Error Checking. Let's take a look at an example:

Code Block
titleExample Input Rules
{"service_field_1hostname":{
	"valid":{
		"rule":"isEmpty",
		"negate":true,
		"message":"ServiceHostname Field 1 must not be empty"
	}
}}

In the above example we're validating the service_field_1 field the hostname field using the isEmpty rule and negating it using the negate attribute. This ensures that the service_hostname field _1 field is not empty when submitted. If the rule validation fails (service_field_1 hostname is empty) the message we defined using the message attribute will be displayed to the user.

Notifications

Notifications allow the universal module to post to a given URL or email a given address when a certain action occurs.

Image Added

Package Option Notifications

Package option notifications are executed when an action is performed on the package.

OptionDescription
Notice

The action triggers the notification.

OptionDescription
AddExecuted when a package is created.
EditExecuted when a package is updated.
Post URL/EmailThe URL to post to, or the email address to email, when the notice is triggered
HTTP CodeThe HTTP Response Code returned by the URL that signifies a successful transmission.
Response ContainsSome portion of the output returned by the URL that signifies a successful transmission. This can be used separately, or in conjunction with the HTTP Code for more refined control over successful responses.
From EmailThe address to send email notifications from.
SubjectThe subject of the email notification.
HTML/TextThe HTML and Text body content for the email notification.
Service Option Notifications

Service option notifications are executed when an action is performed on the service.

OptionDescription
Notice

The action triggers the notification.

OptionDescription
AddExecuted when a service is created.
EditExecuted when a service is updated.
SuspendExecuted when a service is suspended.
UnsuspendExecuted when a service is unsuspended.
CancelExecuted when a service is canceled.
RenewExecuted when a service is renewed. That is, the invoice generated for the service renewal is paid.
Package ChangeExecuted when the package is changed for the service.
Post URL/EmailThe URL to post to, or the email address to email, when the notice is triggered
HTTP CodeThe HTTP Response Code returned by the URL that signifies a successful transmission.
Response ContainsSome portion of the output returned by the URL that signifies a successful transmission. This can be used separately, or in conjunction with the HTTP Code for more refined control over successful responses.
From EmailThe address to send email notifications from.
SubjectThe subject of the email notification.
HTML/TextThe HTML and Text body content for the email notification.