Overview

Packages

  • blesta
    • app
      • controllers
      • models
    • components
      • auth
        • ldap
        • motp
        • oath
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • events
      • exchange
        • rates
          • currency
            • layer
          • fixer
          • open
            • exchange
              • rates
          • x
            • rates
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
          • perforated
            • invoice
          • quickbooks
            • invoice
          • templates
            • default
      • modules
      • net
        • amazon
          • s3
        • http
        • net
          • geo
            • ip
      • plugins
      • reports
        • aging
          • invoices
        • client
          • data
            • portability
        • custom
          • report
        • invoice
          • creation
        • package
          • revenue
        • tax
          • liability
        • transactions
          • applied
          • received
      • security
      • session
        • cart
      • settingscollection
      • upgrades
        • tasks
      • upload
      • vcard
    • core
      • Automation
        • Tasks
          • Common
          • Task
        • Type
          • Common
          • Cron
      • Pricing
        • ItemComparator
        • MetaItem
        • Modifier
          • Type
            • Description
              • Type
                • Discount
                • Option
                • Service
                • Tax
            • Discount
            • Price
            • Proration
        • Presenter
          • Build
            • Invoice
            • InvoiceData
            • Options
            • Service
            • ServiceChange
            • ServiceData
          • Collection
          • Format
            • Fields
            • Type
              • Discount
              • Item
              • Option
              • Options
              • Package
              • Pricing
              • Service
              • Tax
          • Items
            • Invoice
            • Service
          • Type
      • ServiceProviders
      • Util
        • Captcha
          • Captchas
          • Common
        • Common
          • Traits
        • Events
          • Common
          • Handlers
          • Observers
        • Filters
          • Common
        • GeoIp
        • Input
          • Fields
            • Common
        • Tax
        • Widgets
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
      • widget
        • client
  • minPHP
    • helpers
      • color
      • data
        • structure
  • None
  • PHP

Classes

  • Accounts
  • Actions
  • ApiKeys
  • Backup
  • CalendarEvents
  • ClientGroups
  • Clients
  • Companies
  • Contacts
  • Countries
  • Coupons
  • CouponTerms
  • CronTasks
  • Currencies
  • EmailGroups
  • Emails
  • EmailVerifications
  • Encryption
  • GatewayManager
  • Invoices
  • InvoiceTemplateManager
  • Languages
  • Logs
  • Marketplace
  • MessageGroups
  • Messages
  • MessengerManager
  • ModuleClientMeta
  • ModuleManager
  • ModuleTypes
  • Navigation
  • PackageGroups
  • PackageOptionGroups
  • PackageOptions
  • Packages
  • Payments
  • Permissions
  • PluginManager
  • Pricings
  • ReportManager
  • ServiceChanges
  • ServiceInvoices
  • Services
  • Settings
  • Staff
  • StaffGroups
  • States
  • SystemEvents
  • Taxes
  • Themes
  • Transactions
  • Users
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class ModuleManager

Module manager. Handles installing/uninstalling and configuring modules.

Model
Extended by AppModel uses Blesta\Core\Util\Common\Traits\Container
Extended by ModuleManager uses Blesta\Core\Util\Common\Traits\Container
Package: blesta\app\models
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/module_manager.php
Methods summary
public
# __construct( )

Initialize ModuleManager

Initialize ModuleManager

Overrides

AppModel::__construct()
public mixed
# get( integer $module_id, boolean $rows = true, boolean $groups = true )

Fetches a single installed module including all of its module rows and meta data

Fetches a single installed module including all of its module rows and meta data

Parameters

$module_id
The ID of the module to fetch
$rows
True to fetch all module rows with this entry, false otherwise
$groups
True to fetch all module groups with this entry, false otherwise

Returns

mixed
A stdClass object representing the installed module, false if no such module exists
public array
# getByClass( string $class, integer $company_id = null )

Fetches a module for a given company, or all modules installed in the system for the given module class

Fetches a module for a given company, or all modules installed in the system for the given module class

Parameters

$class
The class name (in file_case)
$company_id
The ID of the company to fetch modules for (optional, default null for all)

Returns

array
An array of stdClass objects, each representing an installed module record
public array
# getAll( integer $company_id, string $sort_by = 'name', string $order = 'asc', array $filters = [] )

Lists all installed modules

Lists all installed modules

Parameters

$company_id
The company ID
$sort_by
The field to sort by
$order
The direction to order results
$filters

A list of parameters to filter by, including:

  • type The type of module to filter on, null to get all types of modules

Returns

array
An array of stdClass objects representing installed modules
public array
# getInstalled( array $filters = [] )

Fetches all modules installed in the system

Fetches all modules installed in the system

Parameters

$filters

A list of parameters to filter by, including:

  • type The type of module to filter on, null to get all types of modules

Returns

array
An array of stdClass objects, each representing an installed module record
public array
# getRows( integer $module_id, integer $module_group_id = null )

Retrieves a list of module rows for a given module ID, including meta data

Retrieves a list of module rows for a given module ID, including meta data

Parameters

$module_id
The module ID
$module_group_id
The ID of the module group to filter on (optional)

Returns

array
An array of stdClass objects representing all module rows for this module
public stdClass
# getRow( integer $module_row_id )

Retrieves a module row, including meta data

Retrieves a module row, including meta data

Parameters

$module_row_id
The ID of the module row to fetch

Returns

stdClass
A stdClass object representing a module row
public array
# getGroups( integer $module_id )

Retrieves a list of module groups for this given module ID

Retrieves a list of module groups for this given module ID

Parameters

$module_id
The ID of the module to fetch groups for

Returns

array
An array of stdClass objects representing module groups
public stdClass
# getGroup( integer $module_group_id )

Retrieves a specific module group

Retrieves a specific module group

Parameters

$module_group_id
The ID of the module group to fetch

Returns

stdClass
A stdClass objects representing the module group
public An
# getMeta( integer $module_id, string $key = null )

Retrieves a list of module meta data for a given module ID

Retrieves a list of module meta data for a given module ID

Parameters

$module_id
The module ID
$key
The module meta key representing a specific meta value (optional)

Returns

An
array of stdClass objects reperesenting all module meta info for this module
public An
# getRowMeta( integer $module_row_id, string $key = null )

Retrieves a list of module row meta data for a given module row ID

Retrieves a list of module row meta data for a given module row ID

Parameters

$module_row_id
The module row ID
$key
The module row key representing a specific meta value (optional)

Returns

An
array of stdClass objects reperesenting all module rows for this module
public array
# getAvailable( integer $company_id = null )

Lists all available modules (those that exist on the file system)

Lists all available modules (those that exist on the file system)

Parameters

$company_id
The ID of the company to get available modules for

Returns

array
An array of stdClass objects representing available modules
public boolean
# isInstalled( string $class, string $company_id = null )

Checks whether the given module is installed for the specified company

Checks whether the given module is installed for the specified company

Parameters

$class
The module class (in file_case)
$company_id

The ID of hte company to fetch for (null checks if the module is installed across any company)

Returns

boolean
True if the module is installed, false otherwise
public integer
# add( array $vars )

Adds the module to the system, executing the Module::install() method

Adds the module to the system, executing the Module::install() method

Parameters

$vars

An array of module data including:

  • company_id The company ID
  • class The module class name

Returns

integer
The ID of the module installed, void on error
public
# upgrade( integer $module_id )

Runs the module's upgrade method to upgrade the module to match that of the module's file version. Sets errors in ModuleManager::errors() if any errors are set by the module's upgrade method.

Runs the module's upgrade method to upgrade the module to match that of the module's file version. Sets errors in ModuleManager::errors() if any errors are set by the module's upgrade method.

Parameters

$module_id
The ID of the module to upgrade

See

AppModel::errors()
public
# setMeta( integer $module_id, array $vars )

Updates the meta data for the given module, removing all existing data and replacing it with the given data

Updates the meta data for the given module, removing all existing data and replacing it with the given data

Parameters

$module_id
The ID of the module to update
$vars

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
# delete( integer $module_id )

Permanently and completely removes the module from the database, along with all module records. Executes the Modules::uninstall() method

Permanently and completely removes the module from the database, along with all module records. Executes the Modules::uninstall() method

Parameters

$module_id
The ID of the module to permanently and completely remove
public integer
# addRow( integer $module_id, array $vars )

Adds a new module row for the given module

Adds a new module row for the given module

Parameters

$module_id
The ID of the module to add a row to
$vars
An array of key/value pairs to be sent to the module for conversion into module row meta data

Returns

integer
The module Row ID, void on error

See

AppModel::errors()
public integer
# editRow( integer $module_row_id, array $vars )

Edits a module row

Edits a module row

Parameters

$module_row_id
The ID of the module row to update
$vars
An array of key/value pairs to be sent to the module for conversion into module row meta data

Returns

integer
The module Row ID, void on error

See

AppModel::errors()
public
# deleteRow( integer $module_row_id )

Permanently removes a module row and its related meta data if safe to do so.

Permanently removes a module row and its related meta data if safe to do so.

Parameters

$module_row_id
The ID of the module row to remove

See

AppModel::errors()
public integer
# addGroup( integer $module_id, array $vars )

Adds a module group to the system

Adds a module group to the system

Parameters

$module_id
The ID of the module to add the group under
$vars

array of module group data including:

  • name The name of the module group
  • module_rows A numerically indexed array of module row IDs to assign to this group
  • add_order A key used to determine the order in which module rows are selected from this group when provisioning a service

Returns

integer
The module group ID, void if error
public
# editGroup( integer $module_group_id, array $vars )

Updates a module group to the system

Updates a module group to the system

Parameters

$module_group_id
The ID of the module group to update
$vars

array of module group data including:

  • name The name of the module group
  • module_rows A numerically indexed array of module row IDs to assign to this group
public
# deleteGroup( integer $module_group_id )

Permanently removes the module group if safe to do so.

Permanently removes the module group if safe to do so.

Parameters

$module_group_id
The ID of the module group to remove

See

AppModel::errors()
public mixed
# moduleRpc( integer $module_id, string $method, array $params = null, integer $module_row_id = null )

Invokes the given method with the given parameters on the give module, returning the result from the module.

Invokes the given method with the given parameters on the give module, returning the result from the module.

Parameters

$module_id
The ID of the module to initialize
$method
The name of the method to invoke on the module
$params
An array of parameters to pass to the method to be invoked
$module_row_id
The module row ID to initialize with

Returns

mixed
The value returned from the module for the requested method

See

AppModel::errors()
public Module
# initModule( integer $module_id, integer $company_id = null )

Initializes the module if it has been installed and returns its instance

Initializes the module if it has been installed and returns its instance

Parameters

$module_id
The ID of the module to initialize
$company_id
If set will check to ensure the module belongs to the given company_id

Returns

Module
An object of type Module if the requested module has been installed and exists, false otherwise
public string
# translate( string $class, string $term )

Retrieves the translated definition of the given term for the given module class. This assumes the module language file is the $class name

Retrieves the translated definition of the given term for the given module class. This assumes the module language file is the $class name

Parameters

$class
The class name (in file_case)
$term
The language term from the module to translate

Returns

string
The translated term, if found
public boolean
# validateBelongsToModule( $module_row_id, $module_id )

Validates that the given module row ID belongs to the given module ID

Validates that the given module row ID belongs to the given module ID

Parameters

$module_row_id
ID of the module row to check
$module_id
ID of the module to check against the module row ID

Returns

boolean
True if the module row ID belongs to the module or is empty, false otherwise.
public boolean
# validateAssignedToPackage( integer $module_id, string $status = null )

Validates that the given module

Validates that the given module

Parameters

$module_id
The ID of the module to check
$status

status type (null for all services, service type, or ! service type).

Example:

  • active (only active service)
  • !active (only not active service)

Returns

boolean
True if the module_id is not assigned to any packages, false if it is
public boolean
# validateAssignedToService( integer $module_row_id = null, integer $module_id = null, string $status = null )

Validates that the given module row ID, or module ID, is not assigned to any service

Validates that the given module row ID, or module ID, is not assigned to any service

Parameters

$module_row_id
The ID of the module row to check
$module_id
The ID of the module to check
$status

status type (null for all services, service type, or ! service type).

Example:

  • active (only active service)
  • !active (only not active service)

Returns

boolean
True if the module row is not assigned to any active service, false if it is
Methods inherited from AppModel
_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()
Methods used from Blesta\Core\Util\Common\Traits\Container
getFromContainer()
Properties inherited from AppModel
$logger, $replacement_keys
Blesta API documentation generated by ApiGen