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

  • AdminController
  • AppModel
  • ClientController
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated

Class AppModel

The parent model for the application.

Model
Extended by AppModel uses Blesta\Core\Util\Common\Traits\Container

Direct known subclasses

Accounts, Actions, Coupons, CouponTerms, CronTasks, Currencies, EmailGroups, Emails, EmailVerifications, Encryption, GatewayManager, Invoices, ApiKeys, InvoiceTemplateManager, Languages, Logs, Marketplace, MessageGroups, Messages, MessengerManager, ModuleClientMeta, ModuleManager, ModuleTypes, Backup, Navigation, PackageGroups, PackageOptionGroups, PackageOptions, Packages, Payments, Permissions, PluginManager, Pricings, ReportManager, CalendarEvents, ServiceChanges, ServiceInvoices, Services, Settings, Staff, StaffGroups, States, SystemEvents, Taxes, Themes, ClientGroups, Transactions, Users, Clients, Companies, Contacts, Countries
Package: blesta\app
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/app_model.php
Methods summary
public
# __construct( array $db_info = null )

The main app model constructor.

The main app model constructor.

Parameters

$db_info
A key/value array representing database connection information
public integer
# getPerPage( )

Fetch the number of results set to be returned per page result

Fetch the number of results set to be returned per page result

Returns

integer
The number of results to be returned per page
public
# setPerPage( integer $per_page )

Sets the number of results set to be returned per page result. Minimum value is 1.

Sets the number of results set to be returned per page result. Minimum value is 1.

Parameters

$per_page
The number of results to be returned per page
public string
# currencyToDecimal( string $value, string $currency, integer $decimals = null )

Converts currency values (those submitted via an add/edit invoice request) to their decimal format for use in inserting into the database

Converts currency values (those submitted via an add/edit invoice request) to their decimal format for use in inserting into the database

Parameters

$value
The value in it's native currency format (decimal format is also acceptable)
$currency
The ISO 4217 currency code that represents the given $value
$decimals

The number of decimal places (precision) (optional, default null to use the currency's defined precision)

Returns

string
The currency value converted into decimal format
public static
# truncateDecimal( string $value, integer $min, char $decimal_char = '.' )

Removes trailing zeros from a string preserving $min decimal places

Removes trailing zeros from a string preserving $min decimal places

Parameters

$value
The decimal value in string format
$min
The minimum number of decimal places
$decimal_char
The character used in $value for decimal representation

Retrun

string The format decimal value with trailing zeros removed up to the $min value
public string
# dateToUtc( string $date, string $format = 'Y-m-d H:i:s', boolean $use_cur_time = false )

Converts dates and date times to a UTC date time stamp suitable for inserting into the database.

Converts dates and date times to a UTC date time stamp suitable for inserting into the database.

If $date does not contain any timezone information the company timezone setting will attempt to be used to disambiguate the timezone of the given date.

This method accepts many different date time formats including (but not limited to):

2010-12-31 12:00:00 PST 2010-12-31 12:00:00 UTC 2010-12-31T12:00:00 +0200 2010-12-31T12:00:00 +02:00

Parameters

$date
A date or date time stamp
$format
The format to return the date in
$use_cur_time

If no time set in $date set to true to use the current time, false will use default time (midnight)

Returns

string
A date in UTC time in the given format
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 array
# setRulesIfSet( array $rules, boolean $status = true )

Sets each of the the given rules to contain the 'if_set' key with the given status

Sets each of the the given rules to contain the 'if_set' key with the given status

Parameters

$rules
An array of rules
$status
The value of 'if_set' to use for every rule (optional, default true)

Returns

array
The $rules array with an 'if_set' key for every rule
protected
# _( $name )
protected string
# ifSet( string & $str, string $alt = '' )

Returns the given string as-is, if it exists, and an alternative value may be returned if the given $str does not exist. It's useful for rules and passing text into AppModel::_() for language replacement.

Returns the given string as-is, if it exists, and an alternative value may be returned if the given $str does not exist. It's useful for rules and passing text into AppModel::_() for language replacement.

Parameters

$str
The string to print, if it exists
$alt
The alternate string to use if $str is not set

Returns

string
The result

See

AppModel::_()
public mixed
# setDefaultIfEmpty( string $value )

Sets a value to the default value of it's table column if it is an empty string

Sets a value to the default value of it's table column if it is an empty string

Parameters

$value
The value to set to its default value if empty

Returns

mixed
The default value of this $value if empty, otherwise $value itself
public boolean
# validateExists( mixed $value, string $field, string $table, boolean $allow_empty = true )

Validates a table field contains the value given

Validates a table field contains the value given

Parameters

$value
A single value of $field in $table
$field
The table field to check
$table
The table to check
$allow_empty

Set to true if $value can be empty, false otherwise (false will return true if $allow_empty is disabled and $value is empty)

Returns

boolean
True if a record exists with the given value, false otherwise
public boolean
# validateStateCountry( string $state, string $country )

Validates that the given state belongs to the given country

Validates that the given state belongs to the given country

Parameters

$state
The state
$country
The country

Returns

boolean
True if the state belongs to the country, false otherwise
public string
# systemEncrypt( string $value, string $key = null, string $iv = null )

Encrypts the given value using 256-bit AES in CBC mode using a SHA-256 HMAC hash as the key, based on the system configured setting in Blesta.system_key

Encrypts the given value using 256-bit AES in CBC mode using a SHA-256 HMAC hash as the key, based on the system configured setting in Blesta.system_key

Parameters

$value
The value to be encrypted
$key
The key to use, defaults to Blesta.system_key
$iv
The initialization vector to use, defaults to Blesta.system_key

Returns

string
The base64 encoded encrypted data
public string
# systemDecrypt( string $value, string $key = null, string $iv = null )

Decrypts the given value using 256-bit AES in CBC mode using SHA-256 HMAC hash as the key, based on the system configured setting in Blesta.system_key

Decrypts the given value using 256-bit AES in CBC mode using SHA-256 HMAC hash as the key, based on the system configured setting in Blesta.system_key

Parameters

$value
A base64 encoded string of encrypted data
$key
The key to use, defaults to Blesta.system_key
$iv
The initialization vector to use, defaults to Blesta.system_key

Returns

string
The decrypted data
public string
# systemHash( string $value, string $key = null, string $hash = 'sha256' )

Hashes the given value using the given hash algorithm in HMAC (defaults to sha256)

Hashes the given value using the given hash algorithm in HMAC (defaults to sha256)

Parameters

$value
value to hash
$key
The key to use, default to Blesta.system_key
$hash
The hash algorithm to use

Returns

string
The hash as a hexadecimal string
public integer
# boolToInt( mixed $value )

Converts a boolean or string value to integer (0 if "false" or boolean false, 1 otherwise)

Converts a boolean or string value to integer (0 if "false" or boolean false, 1 otherwise)

Parameters

$value
The value to convert to an integer value

Returns

integer
0 if the value evaluates to false or string "false", 1 otherwise
public boolean
# strToBool( mixed $value )

Converts a string to a boolean value

Converts a string to a boolean value

Parameters

$value
The value to convert to a boolean

Returns

boolean
false if the value evaluates to false or string "false", true otherwise
protected
# loadCrypto( array $other_libs = null )

Prepares the crypto systems for use. Loads the Security components and AES and Hash component libraries as needed.

Prepares the crypto systems for use. Loads the Security components and AES and Hash component libraries as needed.

Parameters

$other_libs
An array of other crypto libraries to load (e.g. RSA)
Methods used from Blesta\Core\Util\Common\Traits\Container
getFromContainer()
Properties summary
protected Monolog\Logger $logger

An instance of the logger

An instance of the logger

#
protected array $replacement_keys

An array of replacement keys used by various models and set in config

An array of replacement keys used by various models and set in config

#
Blesta API documentation generated by ApiGen