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

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

Class PackageOptions

Package Option management

Model
Extended by AppModel
Extended by PackageOptions
Package: blesta\app\models
Copyright: Copyright (c) 2013, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/models/package_options.php

Methods summary

public
# __construct( )

Initialize PackageOptions

Initialize PackageOptions

Overrides

AppModel::__construct
public array
# getValues( integer $option_id )

Fetches all package option values (and subsequent pricing) for the given package option

Fetches all package option values (and subsequent pricing) for the given package option

Parameters

$option_id
integer
$option_id The ID of the option whose values to retrieve

Returns

array
A list of package option values, including package option pricings
public array
# getGroups( integer $option_id )

Fetches all package option groups associated with the given package option

Fetches all package option groups associated with the given package option

Parameters

$option_id
integer
$option_id The ID of the option whose groups to retrieve

Returns

array
A list of package option groups this option value is assigned to
public mixed
# get( integer $option_id )

Fetches the package option

Fetches the package option

Parameters

$option_id
integer
$option_id The ID of the package option to fetch

Returns

mixed
A stdClass object representing the package option, false if no such option exists
public array
# getByPackageId( integer $package_id )

Fetches the package options for the given package ID

Fetches the package options for the given package ID

Parameters

$package_id
integer
$package_id The ID of the package to fetch options for

Returns

array
An array of stdClass objects, each representing a package option
public mixed
# getByPricingId( integer $option_pricing_id )

Fetches a package option for a specific option pricing ID. Only option pricing and values associated with the given option pricing ID will be retrieved.

Fetches a package option for a specific option pricing ID. Only option pricing and values associated with the given option pricing ID will be retrieved.

Parameters

$option_pricing_id
integer
$option_pricing_id The ID of the package option pricing value whose package option to fetch

Returns

mixed
An stdClass object representing the package option, or false if none exist
public array
# getAll( integer $company_id )

Fetches all package option for a given company

Fetches all package option for a given company

Parameters

$company_id
integer
$company_id The company ID

Returns

array
An array of stdClass objects representing each package option
public array
# getList( integer $company_id, integer $page = 1, array $order_by = array('name'=>"asc") )

Fetches a list of all package options for a given company

Fetches a list of all package options for a given company

Parameters

$company_id
integer
$company_id The company ID to fetch package options from
$page
integer
$page The page to return results for
$order_by
array
$order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)

Returns

array
An array of objects, each representing a package option
public integer
# getListCount( integer $company_id )

Returns the total number of packages returned from PackageOptions::getList(), useful in constructing pagination for the getList() method.

Returns the total number of packages returned from PackageOptions::getList(), useful in constructing pagination for the getList() method.

Parameters

$company_id
integer
$company_id The company ID to fetch package options from

Returns

integer
The total number of package options

See

PackageOptions::getList()
public integer
# add( array $vars )

Adds a package option for the given company

Adds a package option for the given company

Parameters

$vars
array
$vars An array of package option info including: - company_id The ID of the company to assign the option to - label The label displayed for this option - name The field name for this option - type The field type for this option, one of: - select - checkbox - radio - quantity - addable 1 if the option is addable by a client - editable 1 if the option is editable by a client - values A numerically indexed array of value info including: - name The name of the package option value (display name) - value The value of the package option (optional, default null) - min The minimum value if type is 'quantity' - max The maximum value if type is 'quantity', null for unlimited quantity - step The step value if type is 'quantity' - pricing A numerically indexed array of pricing info including: - term The term as an integer 1-65535 (optional, default 1) - period The period, 'day', 'week', 'month', 'year', 'onetime' (optional, default 'month') - price The price of this term (optional, default 0.00) - setup_fee The setup fee for this package (optional, default 0.00) - currency The ISO 4217 currency code for this pricing (optional, default USD) - groups An array of package option group IDs that the option belongs to (optional)

Returns

integer
The package option ID, void on error
public integer
# edit( array $option_id, array $vars )

Updates a package option

Updates a package option

Parameters

$option_id
array
$vars An array of package option info including: - label The label displayed for this option - name The field name for this option - type The field type for this option, one of: - select - checkbox - radio - quantity - addable 1 if the option is addable by a client - editable 1 if the option is editable by a client - values A numerically indexed array of value info including: - id The ID of the package option value to update. If the ID is not given, the option value will be added. (optional, required for edit) - name The name of the package option value (display name). If the 'name' is empty or not given, the option value will be deleted - value The value of the package option (optional, default null) - min The minimum value if type is 'quantity' - max The maximum value if type is 'quantity', null for unlimited quantity - step The step value if type is 'quantity' - pricing A numerically indexed array of pricing info including: - id The package option pricing ID to update. If the ID is not given, the pricing will be added. (optional, required for edit) - term The term as an integer 1-65535 (optional, default 1). If the term is not given along with an ID, the pricing will be deleted - period The period, 'day', 'week', 'month', 'year', 'onetime' (optional, default 'month') - price The price of this term (optional, default 0.00) - setup_fee The setup fee for this package (optional, default 0.00) - currency The ISO 4217 currency code for this pricing (optional, default USD) - groups An array of package option group IDs that the option belongs to (optional)
$vars

Returns

integer
The package option ID, void on error
public
# delete( integer $option_id )

Permanently removes a package option from the system

Permanently removes a package option from the system

Parameters

$option_id
integer
$option_group_id The package option ID to delete
public
# deleteOptionValues( integer $option_id, integer $value_id = null )

Deletes all package option values and associated pricing for the given package option

Deletes all package option values and associated pricing for the given package option

Parameters

$option_id
integer
$option_id The ID of the package option whose values and pricing to delete
$value_id
integer
$value_id The ID of the package option value whose value and pricing to delete (optional)
public
# removeFromGroup( integer $option_id, array $option_groups )

Removes the given package option from the given package option groups

Removes the given package option from the given package option groups

Parameters

$option_id
integer
$option_id The ID of the package option
$option_groups
array
$option_groups A numerically-indexed array of package option group IDs of the package option groups that this option should no longer be assigned to
public
# orderValues( integer $option_id, array $value_ids )

Save the package options values for the given option in the provided order

Save the package options values for the given option in the provided order

Parameters

$option_id
integer
$option_id The ID of the option to order values for
$value_ids
array
$value_ids A numerically indexed array of value IDs
public array
# getTypes( )

Retrieves a list of package option types and their language definitions

Retrieves a list of package option types and their language definitions

Returns

array
A key/value list of types and their language
public array
# getPricingPeriods( boolean $plural = false )

Retrieves a list of package pricing periods

Retrieves a list of package pricing periods

Parameters

$plural
boolean
$plural True to return language for plural periods, false for singular

Returns

array
Key=>value pairs of package pricing periods
public array
# getValuePricing( integer $value_id )

Fetch pricing for the given package option value

Fetch pricing for the given package option value

Parameters

$value_id
integer
$value_id The ID of the value to fetch

Returns

array
An array of stdClass object each representing a pricing
public mixed
# getValuePricingById( integer $pricing_id )

Fetch pricing for the given package option pricing ID

Fetch pricing for the given package option pricing ID

Parameters

$pricing_id
integer
$pricing_id The ID of option pricing

Returns

mixed
A stdClass object representing the value pricing, false otherwise
public mixed
# getValue( integer $option_id, string $value )

Fetches the value based on the given option_id and value

Fetches the value based on the given option_id and value

Parameters

$option_id
integer
$option_id The ID of the option to fetch the value for
$value
string
$value The value to fetch

Returns

mixed
A stdClass object representing the value, false if not such value exists
public mixed
# getValuePrice( integer $value_id, integer $term, string $period, string $currency, string $convert_currency = null )

Fetches pricing for the given option with the given value

Fetches pricing for the given option with the given value

Parameters

$value_id
integer
$value_id The ID of the option to fetch
$term
integer
$term The term to fetch fields for
$period
string
$period The period to fetch fields for
$currency
string
$currency The currency to fetch fields for
$convert_currency
string
$convert_currency The currency to convert to (optional)

Returns

mixed
A stdClass object representing the value pricing, false if no such pricing exists
public mixed
# getValueProratePrice( integer $value_id, integer $prorate_days, integer $term, string $period, string $currency, string $convert_currency = null )

Fetches prorated pricing for the given option with the given value

Fetches prorated pricing for the given option with the given value

Deprecated

since 3.5.0

Parameters

$value_id
integer
$value_id The ID of the option to fetch
$prorate_days
integer
$prorate_days The number of days to prorate the amount for
$term
integer
$term The term to fetch fields for
$period
string
$period The period to fetch fields for
$currency
string
$currency The currency to fetch fields for
$convert_currency
string
$convert_currency The currency to convert to (optional)

Returns

mixed
A stdClass object representing the value pricing, false if no such pricing exists

See

PackageOptions::getValueProrateAmount()
public mixed
# getValueProrateAmount( integer $value_id, string $start_date, integer $term, string $period, integer $pro_rata_day, string $currency, string $convert_currency = null )

Fetches prorated pricing for the given option with the given value

Fetches prorated pricing for the given option with the given value

Parameters

$value_id
integer
$value_id The ID of the option to fetch
$start_date
string
$start_date The start date to prorate the price from
$term
integer
$term The term to fetch fields for
$period
string
$period The period to fetch fields for
$pro_rata_day
integer
$pro_rata_day The day of the month to prorate to
$currency
string
$currency The currency to fetch fields for
$convert_currency
string
$convert_currency The currency to convert to (optional)

Returns

mixed
A stdClass object representing the value pricing, false if no such pricing exists
public array
# getAllByPackageId( integer $package_id, integer $term, string $period, string $currency, string $convert_currency = null, array $options = null )

Retrieves all package options for a package given its term, period, and currency

Retrieves all package options for a package given its term, period, and currency

Parameters

$package_id
integer
$package_id The ID of the package
$term
integer
$term The package term
$period
string
$period The package period
$currency
string
$currency The pricing currency
$convert_currency
string
$convert_currency The currency to convert to (optional, default null)
$options
array
$options An array of key/value pairs for filtering options (optional, default null). May include: - addable Set to 1 to only include options that are addable by clients; 0 to only include options that are NOT addable by clients; otherwise every option is included - editable Set to 1 to only include options that are editable by clients; 0 to only include options that are NOT editable by clients; otherwise every option is included - allow An array of option IDs to include (i.e. white-list). An empty array would return no options. Not setting this 'option_ids' key will allow any option - disallow An array of option IDs not to include (i.e. black-list). An empty array would allow all options.

Returns

array
An array of package options including their values and pricing
public ModuleFields
# getFields( integer $package_id, integer $term, string $period, string $currency, mixed $vars = null, string $convert_currency = null, array $options = null )

Get option fields

Get option fields

Parameters

$package_id
integer
$package_id The ID of the package to fetch fields for
$term
integer
$term The term to fetch fields for
$period
string
$period The period to fetch fields for
$currency
string
$currency The currency to fetch fields for
$vars
mixed
$vars stdClass A stdClass object representing a set of post fields (optional, default null)
$convert_currency
string
$convert_currency The currency to convert to (optional, default null)
$options
array
$options An array of key/value pairs for filtering options (optional, default null). May include: - addable Set to 1 to only include options that are addable by clients; 0 to only include options that are NOT addable by clients; otherwise every option is included - editable Set to 1 to only include options that are editable by clients; 0 to only include options that are NOT editable by clients; otherwise every option is included - allow An array of option IDs to include (i.e. white-list). An empty array would return no fields. Not setting this 'option_ids' key will allow any option - disallow An array of option IDs not to include (i.e. black-list). An empty array would allow all options.

Returns

ModuleFields
A ModuleFields object, containg the fields to render
public mixed
# formatPricingTerm( integer $term, string $period )

Formats the pricing term

Formats the pricing term

Parameters

$term
integer
$term The term length
$period
string
$period The period of this term

Returns

mixed
The term formatted in accordance to the period, if possible
public
# formatOptions( array $options )

Formats options into key/value named pairs where each key is the option field name from a key/value pair array where each key is the option ID.

Formats options into key/value named pairs where each key is the option field name from a key/value pair array where each key is the option ID.

Parameters

$options
array
$options A key/value pair array where each key is the option ID
public array
# formatServiceOptions( array $options )

Formats options into configoption array elements where each key is the option ID and each value is the option's selected value

Formats options into configoption array elements where each key is the option ID and each value is the option's selected value

Parameters

$options
array
$options An array of stdClass objects, each representing a service option and its option_value

Returns

array
An array that contains configoptions and key/value pairs of option ID and the option's selected value
public boolean
# validatePricingTerm( integer $term, string $period )

Validates that the term is valid for the period. That is, the term must be > 0 if the period is something other than "onetime".

Validates that the term is valid for the period. That is, the term must be > 0 if the period is something other than "onetime".

Parameters

$term
integer
$term The Term to validate
$period
string
$period The period to validate the term against

Returns

boolean
True if validated, false otherwise
public boolean
# validatePricingPeriod( string $period )

Validates the pricing 'period' field type

Validates the pricing 'period' field type

Parameters

$period
string
$period The period type

Returns

boolean
True if validated, false otherwise
public boolean
# validateValueStep( string $step, string $type )

Validates whether the given package option value given has a valid step set

Validates whether the given package option value given has a valid step set

Parameters

$step
string
$step The package option step value
$type
string
$type The package option type

Returns

boolean
True if the package option value has a valid step set, or false otherwise
public boolean
# validateValueMin( string $min, string $type )

Validates whether the given package option value given has a valid minimum value

Validates whether the given package option value given has a valid minimum value

Parameters

$min
string
$min The package option minimum value
$type
string
$type The package option type

Returns

boolean
True if the package option value has a valid minimum value set, or false otherwise
public boolean
# validateValueMax( string $max, string $type )

Validates whether the given package option value given has a valid maximum value

Validates whether the given package option value given has a valid maximum value

Parameters

$max
string
$max The package option maximum value
$type
string
$type The package option type

Returns

boolean
True if the package option value has a valid maximum value set, or false otherwise
public boolean
# validateOptionValueLimit( array $values, string $type )

Validates whether the number of package option values is valid for the given package option type

Validates whether the number of package option values is valid for the given package option type

Parameters

$values
array
$values A numerically-indexed array of package option values
$type
string
$type The package option type

Returns

boolean
True if the number of package option values is valid for the given package option type, or false otherwise
public boolean
# validateSelectTypeValues( array $values, string $type )

Validates whether any of the given package option values contains invalid special characters for options of the 'select' type. An invalid character is determined to be one that is not equivalent to its HTML encoded version

Validates whether any of the given package option values contains invalid special characters for options of the 'select' type. An invalid character is determined to be one that is not equivalent to its HTML encoded version

Parameters

$values
array
$values A numerically-indexed array of package option values
$type
string
$type The package option type

Returns

boolean
True if all package option values contain valid characters, or false otherwise
public boolean
# validateGroupIds( array $groups, integer $company_id = null )

Validates whether all of the given package option group IDs exist and belong to the given company

Validates whether all of the given package option group IDs exist and belong to the given company

Parameters

$groups
array
$groups An array of package option group IDs
$company_id
integer
$company_id The ID of the company the groups must belong to (optional, default null)

Returns

boolean
True if all of the given package option groups exist and belong to the given company, or false otherwise

Methods inherited from AppModel

_(), boolToInt(), currencyToDecimal(), dateToUtc(), errors(), getPerPage(), ifSet(), loadCrypto(), setDefaultIfEmpty(), setPerPage(), setRulesIfSet(), strToBool(), systemDecrypt(), systemEncrypt(), systemHash(), truncateDecimal(), validateExists(), validateStateCountry()

Methods inherited from Model

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

Magic methods summary

Properties summary

Properties inherited from AppModel

$replacement_keys

Blesta API documentation generated by ApiGen 2.8.0