Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • areyouahuman
      • auth
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
        • default
      • exchange
        • rates
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • quickbooks
            • invoice
      • json
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • recaptcha
      • reports
        • aging
          • invoices
        • custom
          • report
        • invoice
          • creation
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • form
      • html
      • javascript
      • xml
    • lib
  • None
  • PHP

Classes

  • Module
  • ModuleField
  • ModuleFields
  • Modules

Class Module

Abstract class that all Modules must extend

Abstract
Package: blesta\components\modules
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at components/modules/module.php

Methods summary

public string
# getName( )

Returns the name of this module

Returns the name of this module

Returns

string
The common name of this module
public string
# getVersion( )

Returns the version of this module

Returns the version of this module

Returns

string
The current version of this module
public array
# getAuthors( )

Returns the name and URL for the authors of this module

Returns the name and URL for the authors of this module

Returns

array
A numerically indexed array that contains an array with key/value pairs for 'name' and 'url', representing the name and URL of the authors of this module
public string
# getServiceName( stdClass $service )

Returns the value used to identify a particular service

Returns the value used to identify a particular service

Parameters

$service
stdClass
$service A stdClass object representing the service

Returns

string
A value used to identify this service amongst other similar services
public string
# moduleRowName( )

Returns a noun used to refer to a module row (e.g. "Server", "VPS", "Reseller Account", etc.)

Returns a noun used to refer to a module row (e.g. "Server", "VPS", "Reseller Account", etc.)

Returns

string
The noun used to refer to a module row
public string
# moduleRowNamePlural( )

Returns a noun used to refer to a module row in plural form (e.g. "Servers", "VPSs", "Reseller Accounts", etc.)

Returns a noun used to refer to a module row in plural form (e.g. "Servers", "VPSs", "Reseller Accounts", etc.)

Returns

string
The noun used to refer to a module row in plural form
public string
# moduleGroupName( )

Returns a noun used to refer to a module group (e.g. "Server Group", "Cloud", etc.)

Returns a noun used to refer to a module group (e.g. "Server Group", "Cloud", etc.)

Returns

string
The noun used to refer to a module group
public string
# moduleRowMetaKey( )

Returns the key used to identify the primary field from the set of module row meta fields. This value can be any of the module row meta fields.

Returns the key used to identify the primary field from the set of module row meta fields. This value can be any of the module row meta fields.

Returns

string
The key used to identify the primary field from the set of module row meta fields
public array
# install( )

Performs any necessary bootstraping actions. Sets Input errors on failure, preventing the module from being added.

Performs any necessary bootstraping actions. Sets Input errors on failure, preventing the module from being added.

Returns

array
A numerically indexed array of meta data containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)
public
# upgrade( string $current_version )

Performs migration of data from $current_version (the current installed version) to the given file set version. Sets Input errors on failure, preventing the module from being upgraded.

Performs migration of data from $current_version (the current installed version) to the given file set version. Sets Input errors on failure, preventing the module from being upgraded.

Parameters

$current_version
string
$current_version The current installed version of this module
public
# uninstall( integer $module_id, boolean $last_instance )

Performs any necessary cleanup actions. Sets Input errors on failure after the module has been uninstalled.

Performs any necessary cleanup actions. Sets Input errors on failure after the module has been uninstalled.

Parameters

$module_id
integer
$module_id The ID of the module being uninstalled
$last_instance
boolean
$last_instance True if $module_id is the last instance across all companies for this module, false otherwise
public string
# getLogo( )

Returns the relative path from this module's directory to the logo for this module. Defaults to views/default/images/logo.png

Returns the relative path from this module's directory to the logo for this module. Defaults to views/default/images/logo.png

Returns

string
The relative path to the module's logo
final public
# setModule( stdClass $module )

Sets the module to be used for any subsequent requests

Sets the module to be used for any subsequent requests

Parameters

$module
stdClass
A stdClass object representing the module

See

ModuleManager::get()
final public
# setModuleRow( stdClass $module_row )

Sets the module row to be used for any subsequent requests

Sets the module row to be used for any subsequent requests

Parameters

$module_row
stdClass
A stdClass object representing the module row

See

ModuleManager::getRow()
final public stdClass
# getModule( )

Fetches the module currently in use

Fetches the module currently in use

Returns

stdClass
A stdClass object representing the module
final public stdClass
# getModuleRow( integer $module_row_id = null )

Fetches the requested module row for the current module

Fetches the requested module row for the current module

Parameters

$module_row_id
integer
$module_row_id The ID of the module row to fetch for the current module

Returns

stdClass
A stdClass object representing the module row
final public array
# getModuleRows( integer $module_group_id = null )

Returns all module rows available to the current module

Returns all module rows available to the current module

Parameters

$module_group_id
integer
$module_group_id The ID of the module group to filter rows by

Returns

array
An array of stdClass objects each representing a module row, false if no module set
public string
# getPackageServiceName( stdClass $packages, array $vars = null )

Returns the value used to identify a particular package service which has not yet been made into a service. This may be used to uniquely identify an uncreated service of the same package (i.e. in an order form checkout)

Returns the value used to identify a particular package service which has not yet been made into a service. This may be used to uniquely identify an uncreated service of the same package (i.e. in an order form checkout)

Parameters

$packages
stdClass
$package A stdClass object representing the selected package
$vars
array
$vars An array of user supplied info to satisfy the request

Returns

string
The value used to identify this package service

See

Module::getServiceName()
public boolean
# validateService( stdClass $package, array $vars = null )

Attempts to validate service info. This is the top-level error checking method. Sets Input errors on failure.

Attempts to validate service info. This is the top-level error checking method. Sets Input errors on failure.

Parameters

$package
stdClass
$package A stdClass object representing the selected package
$vars
array
$vars An array of user supplied info to satisfy the request

Returns

boolean
True if the service validates, false otherwise. Sets Input errors when false.
public array
# addService( stdClass $package, array $vars = null, stdClass $parent_package = null, stdClass $parent_service = null, string $status = "pending" )

Adds the service to the remote server. Sets Input errors on failure, preventing the service from being added.

Adds the service to the remote server. Sets Input errors on failure, preventing the service from being added.

Parameters

$package
stdClass
$package A stdClass object representing the selected package
$vars
array
$vars An array of user supplied info to satisfy the request
$parent_package
stdClass
$parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
$parent_service
stdClass
$parent_service A stdClass object representing the parent service of the service being added (if the current service is an addon service and parent service has already been provisioned)
$status
string
$status The status of the service being added. These include: - active - canceled - pending - suspended

Returns

array
A numerically indexed array of meta fields to be stored for this service containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public array
# editService( stdClass $package, stdClass $service, array $vars = array(), stdClass $parent_package = null, stdClass $parent_service = null )

Edits the service on the remote server. Sets Input errors on failure, preventing the service from being edited.

Edits the service on the remote server. Sets Input errors on failure, preventing the service from being edited.

Parameters

$package
stdClass
$package A stdClass object representing the current package
$service
stdClass
$service A stdClass object representing the current service
$vars
array
$vars An array of user supplied info to satisfy the request
$parent_package
stdClass
$parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
$parent_service
stdClass
$parent_service A stdClass object representing the parent service of the service being edited (if the current service is an addon service)

Returns

array
A numerically indexed array of meta fields to be stored for this service containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public mixed
# cancelService( stdClass $package, stdClass $service, stdClass $parent_package = null, stdClass $parent_service = null )

Cancels the service on the remote server. Sets Input errors on failure, preventing the service from being canceled.

Cancels the service on the remote server. Sets Input errors on failure, preventing the service from being canceled.

Parameters

$package
stdClass
$package A stdClass object representing the current package
$service
stdClass
$service A stdClass object representing the current service
$parent_package
stdClass
$parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
$parent_service
stdClass
$parent_service A stdClass object representing the parent service of the service being canceled (if the current service is an addon service)

Returns

mixed
null to maintain the existing meta fields or a numerically indexed array of meta fields to be stored for this service containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public mixed
# suspendService( stdClass $package, stdClass $service, stdClass $parent_package = null, stdClass $parent_service = null )

Suspends the service on the remote server. Sets Input errors on failure, preventing the service from being suspended.

Suspends the service on the remote server. Sets Input errors on failure, preventing the service from being suspended.

Parameters

$package
stdClass
$package A stdClass object representing the current package
$service
stdClass
$service A stdClass object representing the current service
$parent_package
stdClass
$parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
$parent_service
stdClass
$parent_service A stdClass object representing the parent service of the service being suspended (if the current service is an addon service)

Returns

mixed
null to maintain the existing meta fields or a numerically indexed array of meta fields to be stored for this service containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public mixed
# unsuspendService( stdClass $package, stdClass $service, stdClass $parent_package = null, stdClass $parent_service = null )

Unsuspends the service on the remote server. Sets Input errors on failure, preventing the service from being unsuspended.

Unsuspends the service on the remote server. Sets Input errors on failure, preventing the service from being unsuspended.

Parameters

$package
stdClass
$package A stdClass object representing the current package
$service
stdClass
$service A stdClass object representing the current service
$parent_package
stdClass
$parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
$parent_service
stdClass
$parent_service A stdClass object representing the parent service of the service being unsuspended (if the current service is an addon service)

Returns

mixed
null to maintain the existing meta fields or a numerically indexed array of meta fields to be stored for this service containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public mixed
# renewService( stdClass $package, stdClass $service, stdClass $parent_package = null, stdClass $parent_service = null )

Allows the module to perform an action when the service is ready to renew. Sets Input errors on failure, preventing the service from renewing.

Allows the module to perform an action when the service is ready to renew. Sets Input errors on failure, preventing the service from renewing.

Parameters

$package
stdClass
$package A stdClass object representing the current package
$service
stdClass
$service A stdClass object representing the current service
$parent_package
stdClass
$parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
$parent_service
stdClass
$parent_service A stdClass object representing the parent service of the service being renewed (if the current service is an addon service)

Returns

mixed
null to maintain the existing meta fields or a numerically indexed array of meta fields to be stored for this service containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public mixed
# changeServicePackage( stdClass $package_from, stdClass $package_to, stdClass $service, stdClass $parent_package = null, stdClass $parent_service = null )

Updates the package for the service on the remote server. Sets Input errors on failure, preventing the service's package from being changed.

Updates the package for the service on the remote server. Sets Input errors on failure, preventing the service's package from being changed.

Parameters

$package_from
stdClass
$package_from A stdClass object representing the current package
$package_to
stdClass
$package_to A stdClass object representing the new package
$service
stdClass
$service A stdClass object representing the current service
$parent_package
stdClass
$parent_package A stdClass object representing the parent service's selected package (if the current service is an addon service)
$parent_service
stdClass
$parent_service A stdClass object representing the parent service of the service being changed (if the current service is an addon service)

Returns

mixed
null to maintain the existing meta fields or a numerically indexed array of meta fields to be stored for this service containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public array
# addPackage( array $vars = null )

Validates input data when attempting to add a package, returns the meta data to save when adding a package. Performs any action required to add the package on the remote server. Sets Input errors on failure, preventing the package from being added.

Validates input data when attempting to add a package, returns the meta data to save when adding a package. Performs any action required to add the package on the remote server. Sets Input errors on failure, preventing the package from being added.

Parameters

$vars
array
An array of key/value pairs used to add the package

Returns

array
A numerically indexed array of meta fields to be stored for this package containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public array
# editPackage( stdClass $package, array $vars = null )

Validates input data when attempting to edit a package, returns the meta data to save when editing a package. Performs any action required to edit the package on the remote server. Sets Input errors on failure, preventing the package from being edited.

Validates input data when attempting to edit a package, returns the meta data to save when editing a package. Performs any action required to edit the package on the remote server. Sets Input errors on failure, preventing the package from being edited.

Parameters

$package
stdClass
$package A stdClass object representing the selected package
$vars
array
An array of key/value pairs used to edit the package

Returns

array
A numerically indexed array of meta fields to be stored for this package containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)

See

Module::getModule()
Module::getModuleRow()
public
# deletePackage( stdClass $package )

Deletes the package on the remote server. Sets Input errors on failure, preventing the package from being deleted.

Deletes the package on the remote server. Sets Input errors on failure, preventing the package from being deleted.

Parameters

$package
stdClass
$package A stdClass object representing the selected package

See

Module::getModule()
Module::getModuleRow()
public string
# manageModule( mixed $module, array & $vars )

Returns the rendered view of the manage module page

Returns the rendered view of the manage module page

Parameters

$module
mixed
$module A stdClass object representing the module and its rows
$vars
array
$vars An array of post data submitted to or on the manage module page (used to repopulate fields after an error)

Returns

string
HTML content containing information to display when viewing the manager module page
public string
# manageAddRow( array & $vars )

Returns the rendered view of the add module row page

Returns the rendered view of the add module row page

Parameters

$vars
array
$vars An array of post data submitted to or on the add module row page (used to repopulate fields after an error)

Returns

string
HTML content containing information to display when viewing the add module row page
public string
# manageEditRow( stdClass $module_row, array & $vars )

Returns the rendered view of the edit module row page

Returns the rendered view of the edit module row page

Parameters

$module_row
stdClass
$module_row The stdClass representation of the existing module row
$vars
array
$vars An array of post data submitted to or on the edit module row page (used to repopulate fields after an error)

Returns

string
HTML content containing information to display when viewing the edit module row page
public array
# addModuleRow( array & $vars )

Adds the module row on the remote server. Sets Input errors on failure, preventing the row from being added.

Adds the module row on the remote server. Sets Input errors on failure, preventing the row from being added.

Parameters

$vars
array
$vars An array of module info to add

Returns

array
A numerically indexed array of meta fields for the module row containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)
public array
# editModuleRow( stdClass $module_row, array & $vars )

Edits the module row on the remote server. Sets Input errors on failure, preventing the row from being updated.

Edits the module row on the remote server. Sets Input errors on failure, preventing the row from being updated.

Parameters

$module_row
stdClass
$module_row The stdClass representation of the existing module row
$vars
array
$vars An array of module info to update

Returns

array
A numerically indexed array of meta fields for the module row containing: - key The key for this meta field - value The value for this key - encrypted Whether or not this field should be encrypted (default 0, not encrypted)
public
# deleteModuleRow( stdClass $module_row )

Deletes the module row on the remote server. Sets Input errors on failure, preventing the row from being deleted.

Deletes the module row on the remote server. Sets Input errors on failure, preventing the row from being deleted.

Parameters

$module_row
stdClass
$module_row The stdClass representation of the existing module row
public array
# getGroupOrderOptions( )

Returns an array of available service delegation order methods. The module will determine how each method is defined. For example, the method "first" may be implemented such that it returns the module row with the least number of services assigned to it.

Returns an array of available service delegation order methods. The module will determine how each method is defined. For example, the method "first" may be implemented such that it returns the module row with the least number of services assigned to it.

Returns

array
An array of order methods in key/value pairs where the key is the type to be stored for the group and value is the name for that option

See

Module::selectModuleRow()
public integer
# selectModuleRow( mixed $module_group_id )

Determines which module row should be attempted when a service is provisioned for the given group based upon the order method set for that group.

Determines which module row should be attempted when a service is provisioned for the given group based upon the order method set for that group.

Returns

integer
The module row ID to attempt to add the service with

See

Module::getGroupOrderOptions()
public ModuleFields
# getPackageFields( mixed $vars = null )

Returns all fields used when adding/editing a package, including any javascript to execute when the page is rendered with these fields.

Returns all fields used when adding/editing a package, including any javascript to execute when the page is rendered with these fields.

Parameters

$vars
mixed
$vars stdClass A stdClass object representing a set of post fields

Returns

ModuleFields
A ModuleFields object, containg the fields to render as well as any additional HTML markup to include
public array
# getEmailTags( )

Returns an array of key values for fields stored for a module, package, and service under this module, used to substitute those keys with their actual module, package, or service meta values in related emails.

Returns an array of key values for fields stored for a module, package, and service under this module, used to substitute those keys with their actual module, package, or service meta values in related emails.

Returns

array
A multi-dimensional array of key/value pairs where each key is one of 'module', 'package', or 'service' and each value is a numerically indexed array of key values that match meta fields under that category.

See

Modules::addModuleRow()
Modules::editModuleRow()
Modules::addPackage()
Modules::editPackage()
Modules::addService()
Modules::editService()
public ModuleFields
# getAdminAddFields( stdClass $package, mixed $vars = null )

Returns all fields to display to an admin attempting to add a service with the module

Returns all fields to display to an admin attempting to add a service with the module

Parameters

$package
stdClass
$package A stdClass object representing the selected package
$vars
mixed
$vars stdClass A stdClass object representing a set of post fields

Returns

ModuleFields
A ModuleFields object, containg the fields to render as well as any additional HTML markup to include
public ModuleFields
# getClientAddFields( stdClass $package, mixed $vars = null )

Returns all fields to display to a client attempting to add a service with the module

Returns all fields to display to a client attempting to add a service with the module

Parameters

$package
stdClass
$package A stdClass object representing the selected package
$vars
mixed
$vars stdClass A stdClass object representing a set of post fields

Returns

ModuleFields
A ModuleFields object, containg the fields to render as well as any additional HTML markup to include
public ModuleFields
# getAdminEditFields( stdClass $package, mixed $vars = null )

Returns all fields to display to an admin attempting to edit a service with the module

Returns all fields to display to an admin attempting to edit a service with the module

Parameters

$package
stdClass
$package A stdClass object representing the selected package
$vars
mixed
$vars stdClass A stdClass object representing a set of post fields

Returns

ModuleFields
A ModuleFields object, containg the fields to render as well as any additional HTML markup to include
public string
# getAdminServiceInfo( stdClass $service, stdClass $package )

Fetches the HTML content to display when viewing the service info in the admin interface.

Fetches the HTML content to display when viewing the service info in the admin interface.

Parameters

$service
stdClass
$service A stdClass object representing the service
$package
stdClass
$package A stdClass object representing the service's package

Returns

string
HTML content containing information to display when viewing the service info
public string
# getClientServiceInfo( stdClass $service, stdClass $package )

Fetches the HTML content to display when viewing the service info in the client interface.

Fetches the HTML content to display when viewing the service info in the client interface.

Parameters

$service
stdClass
$service A stdClass object representing the service
$package
stdClass
$package A stdClass object representing the service's package

Returns

string
HTML content containing information to display when viewing the service info
public array
# getAdminTabs( stdClass $package )

Returns all tabs to display to an admin when managing a service whose package uses this module

Returns all tabs to display to an admin when managing a service whose package uses this module

Parameters

$package
stdClass
$package A stdClass object representing the selected package

Returns

array
An array of tabs in the format of method => title. Example: array('methodName' => "Title", 'methodName2' => "Title2")
public array
# getClientTabs( stdClass $package )

Returns all tabs to display to a client when managing a service whose package uses this module

Returns all tabs to display to a client when managing a service whose package uses this module

Parameters

$package
stdClass
$package A stdClass object representing the selected package

Returns

array
An array of tabs in the format of method => title, or method => array where array contains: - name (required) The name of the link - icon (optional) use to display a custom icon - href (optional) use to link to a different URL Example: array('methodName' => "Title", 'methodName2' => "Title2") array('methodName' => array('name' => "Title", 'icon' => "icon"))
public mixed
# errors( )

Return all validation errors encountered

Return all validation errors encountered

Returns

mixed
Boolean false if no errors encountered, an array of errors otherwise
protected
# httpRequest( string $method, string $url = null, mixed $params = null )

Process a request over HTTP using the supplied method type, url and parameters.

Process a request over HTTP using the supplied method type, url and parameters.

Parameters

$method
string
$method The method type (e.g. GET, POST)
$url
string
$url The URL to post to
$params
mixed
An array of parameters or a URL encoded list of key/value pairs
protected string
# log( string $url, string $data = null, string $direction = "input", boolean $success = false )

Attempts to log the given info to the module log.

Attempts to log the given info to the module log.

Parameters

$url
string
$url The URL contacted for this request
$data
string
$data A string of module data sent along with the request (optional)
$direction
string
$direction The direction of the log entry (input or output, default input)
$success
boolean
$success True if the request was successful, false otherwise

Returns

string
Returns the 8-character group identifier, used to link log entries together

Throws

Exception
Thrown if $data was invalid and could not be added to the log
protected stdClass
# serviceFieldsToObject( array $fields )

Converts numerically indexed service field arrays into an object with member variables

Converts numerically indexed service field arrays into an object with member variables

Parameters

$fields
array
$fields A numerically indexed array of stdClass objects containing key and value member variables, or an array containing 'key' and 'value' indexes

Returns

stdClass
A stdClass objects with member variables
protected ModuleFields
# arrayToModuleFields( array $arr, ModuleFields $fields = null, stdClass $vars = null )

Converts an array to a ModuleFields object

Converts an array to a ModuleFields object

Parameters

$arr
array
An array of key/value pairs where each key is the field name and each value is array consisting of: - label The field label - type The field type(text, textarea, select, checkbox, radio) - options A key/value array where each key is the option value and each value is the option name, or a string to set as the default value for hidden and text inputs - attributes A key/value array
$fields
ModuleFields
$fields An existing ModuleFields object to append fields to, null to create create a new object
$vars
stdClass
$vars A stdClass object of input key/value pairs

Returns

ModuleFields
A ModuleFields object containing the fields
protected
# loadConfig( mixed $file )

Loads a given config file

Loads a given config file

Magic methods summary

Properties summary

protected Http $Http
#

An Http object, used to make HTTP requests

An Http object, used to make HTTP requests

protected stdClass $config
#

A stdClass object representing the configuration for this module

A stdClass object representing the configuration for this module

public string $base_uri
#

The base URI for the requested module action

The base URI for the requested module action

Blesta API documentation generated by ApiGen 2.8.0