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

  • AppController
  • AppModel

Class AppModel

The parent model for the application.

Model
Extended by AppModel

Direct known subclasses

Accounts, ApiKeys, Currencies, EmailGroups, Emails, Encryption, GatewayManager, Invoices, InvoiceTemplateManager, Languages, Logs, Marketplace, CalendarEvents, ModuleClientMeta, ModuleManager, Navigation, PackageGroups, PackageOptionGroups, PackageOptions, Packages, Payments, Permissions, PluginManager, ClientGroups, Pricings, ReportManager, ServiceChanges, Services, Settings, Staff, StaffGroups, States, Taxes, Themes, Clients, Transactions, Users, Companies, Contacts, Countries, Coupons, CronTasks

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
array
$db_info Database information for this connection

Overrides

Model::__construct
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
integer
$per_page The number of results to be returned per page
public string
# currencyToDecimal( string $value, string $currency, integer $decimals = 2 )

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
string
$value The value in it's native currency format (decimal format is also acceptable)
$currency
string
$currency The ISO 4217 currency code that represents the given $value
$decimals
integer
$decimals The number of decimals points (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
string
$value The decimal value in string format
$min
integer
$min The minimum number of decimal places
$decimal_char
char
$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
string
$date A date or date time stamp
$format
string
$format The format to return the date in
$use_cur_time
boolean
$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
array
$rules An array of rules
$status
boolean
$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
# _( string $name )

Shortcut for Language::_()

Shortcut for Language::_()

Parameters

$name
string
$name The name of the language key to fetch
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
string
$str The string to print, if it exists
$alt
string
$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
string
$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
mixed
$value A single value of $field in $table
$field
string
$field The table field to check
$table
string
$table The table to check
$allow_empty
boolean
$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
string
$state The state
$country
string
$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
string
$value The value to be encrypted
$key
string
$key The key to use, defaults to Blesta.system_key
$iv
string
$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
string
$value A base64 encoded string of encrypted data
$key
string
$key The key to use, defaults to Blesta.system_key
$iv
string
$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
string
The value to hash
$key
string
$key The key to use, default to Blesta.system_key
$hash
string
$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
mixed
$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
mixed
$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
array
$other_libs An array of other crypto libraries to load (e.g. RSA)

Methods inherited from Model

affectedRows(), begin(), commit(), getConnection(), lastInsertId(), makeDSN(), prepare(), query(), rollBack(), setAttribute(), setFetchMode()

Magic methods summary

Properties summary

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 2.8.0