Blesta
  • Package
  • Class
  • Tree
  • Deprecated

Packages

  • blesta
    • app
      • components
        • events
          • default
      • controllers
      • models
    • components
      • auth
      • delivery
        • interfax
        • postal
          • methods
      • download
      • email
      • exchange
        • rates
          • foxrate
          • google
            • finance
          • yahoo
            • finance
      • gateway
        • payments
      • gateways
      • invoice
        • delivery
        • templates
      • json
      • modules
      • net
        • http
        • net
          • amazon
            • s3
          • geo
            • ip
      • plugins
      • recaptcha
      • security
      • session
        • cart
      • settingscollection
      • upgrades
      • upload
      • vcard
    • helpers
      • currency
        • format
      • data
        • structure
          • array
          • string
      • text
        • parser
  • com
    • tecnick
      • tcpdf
        • blesta
          • components
            • invoice
              • templates
                • quickbooks
                  • invoice
                • templates
                  • default
  • Crypt
    • AES
    • DES
    • Hash
    • Random
    • RC4
    • Rijndael
    • RSA
    • TerraDES
  • File
    • ANSI
    • ASN1
    • X509
  • Math
    • BigInteger
  • minPHP
    • components
      • input
      • record
    • helpers
      • color
      • data
        • structure
      • date
      • html
      • xml
    • lib
  • Net
    • SFTP
    • SSH1
    • SSH2
  • None
  • PHP
  • PHPMailer
  • Services
    • JSON
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

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

Class Packages

Package management

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

Methods summary

public
# __construct( )

Initialize Packages

Initialize Packages

Overrides

AppModel::__construct
public integer
# add( array $vars )

Adds a new package to the system

Adds a new package to the system

Parameters

$vars
array
$vars An array of package information including: - module_id The ID of the module this package belongs to (optional, default NULL) - name The name of the package - description The description of the package (optional, default NULL) - description_html The HTML description of the package (optional, default NULL) - qty The maximum quantity available in this package, if any (optional, default NULL) - module_row The module row this package belongs to (optional, default 0) - taxable Whether or not this package is taxable (optional, default 0) - status The status of this package, 'active', 'inactive', 'restricted' (optional, default 'active') - company_id The ID of the company this package belongs to - email_content A numerically indexed array of email content including: - lang The language of the email content - html The html content for the email (optional) - text The text content for the email, will be created automatically from html if not given (optional) - 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) - cancel_fee The cancelation fee for this package (optional, default 0.00) - currency The ISO 4217 currency code for this pricing (optional, default USD) - groups A numerically indexed array of package group assignments (optional) - * A set of miscellaneous fields to pass, in addition to the above fields, to the module when adding the package (optional)

Returns

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

Update an existing package ID with the data given

Update an existing package ID with the data given

Parameters

$package_id
integer
$package_id The ID of the package to update
$vars
array
$vars An array of package information including: - module_id The ID of the module this package belongs to (optional, default NULL) - name The name of the package - description The description of the package (optional, default NULL) - description_html The HTML description of the package (optional, default NULL) - qty The maximum quantity available in this package, if any (optional, default NULL) - module_row The module row this package belongs to (optional, default 0) - taxable Whether or not this package is taxable (optional, default 0) - status The status of this package, 'active', 'inactive', 'restricted' (optional, default 'active') - company_id The ID of the company this package belongs to (optional) - email_content A numerically indexed array of email content including: - lang The language of the email content - html The html content for the email (optional) - text The text content for the email, will be created automatically from html if not given (optional) - pricing A numerically indexed array of pricing info including: - id The pricing ID (optional, required if an edit else will add as new) - term The term as an integer 1-65535 (optional, default 1), if term is empty will remove this pricing option - 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) - cancel_fee The cancelation fee for this package (optional, default 0.00) - currency The ISO 4217 currency code for this pricing (optional, default USD) - groups A numerically indexed array of package group assignments (optional), if given will replace all package group assignments with those given - * A set of miscellaneous fields to pass, in addition to the above fields, to the module when adding the package (optional)
public
# delete( integer $package_id )

Permanently removes the given package from the system. Packages can only be deleted if no services exist for that package.

Permanently removes the given package from the system. Packages can only be deleted if no services exist for that package.

Parameters

$package_id
integer
$package_id The package ID to delete
public mixed
# get( integer $package_id )

Fetches the given package

Fetches the given package

Parameters

$package_id
integer
$package_id The package ID to fetch

Returns

mixed
A stdClass object representing the package, false if no such package exists
public mixed
# getByPricingId( integer $package_pricing_id )

Fetches the given package by package pricing ID

Fetches the given package by package pricing ID

Parameters

$package_pricing_id
integer
$package_pricing_id The package pricing ID to use to fetch the package

Returns

mixed
A stdClass object representing the package, false if no such package exists
public array
# getAll( integer $company_id, array $order = array('name'=>"ASC"), string $status = null )

Fetch all packages belonging to the given company

Fetch all packages belonging to the given company

Parameters

$company_id
integer
$company_id The ID of the company to fetch pages for
$order
array
$order The sort order in key = value order, where 'key' is the field to sort on and 'value' is the order to sort (asc or desc)
$status
string
$status The status type of packages to retrieve ('active', 'inactive', 'restricted', default null for all)

Returns

array
An array of stdClass objects each representing a package
public array
# getList( integer $page = 1, array $order_by = array('id_code'=>"asc"), string $status = null )

Fetches a list of all packages

Fetches a list of all packages

Parameters

$page
integer
$page The page to return results for (optional, default 1)
$order_by
array
$order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
$status
string
$status The status type of packages to retrieve ('active', 'inactive', 'restricted', default null for all)

Returns

array
An array of stdClass objects each representing a package
public array
# search( string $query, integer $page = 1 )

Search packages

Search packages

Parameters

$query
string
$query The value to search packages for
$page
integer
$page The page number of results to fetch (optional, default 1)

Returns

array
An array of packages that match the search criteria
public
# getSearchCount( string $query )

Return the total number of packages returned from Packages::search(), useful in constructing pagination

Return the total number of packages returned from Packages::search(), useful in constructing pagination

Parameters

$query
string
$query The value to search services for

See

Packages::search()
private Record
# searchPackages( string $query )

Partially constructs the query for searching packages

Partially constructs the query for searching packages

Parameters

$query
string
$query The value to search packages for

Returns

Record
The partially constructed query Record object

See

Packages::search(), Packages::getSearchCount()
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
# getStatusTypes( )

Retrieves a list of package status types

Retrieves a list of package status types

Returns

array
Key=>value pairs of package status types
public array
# calcLineTotals( integer $client_id, array $package_pricings, string $coupon_code = null )

Caclulates the cost in one or more package pricings for a client with the given coupon. Tax is only apply if the package is configured as taxable and there exist tax rules that apply to the given client.

Caclulates the cost in one or more package pricings for a client with the given coupon. Tax is only apply if the package is configured as taxable and there exist tax rules that apply to the given client.

Parameters

$client_id
integer
$client_id The ID of the client to which the pricings are to be applied
$package_pricings
array
$package_pricings A numerical array of packacing pricing and quantity values of the form: - pricing_id The package pricing ID - qty The qty being purchased for the package pricing ID - fees A numerical array of fee types to include in the pricing calculations, including: - setup - cancel
$coupon_code
string
$coupon_code The coupon code to apply to each package pricing ID

Returns

array
An array of pricing information including: - subtotal The total before discount, fees, and tax - discount The total savings - fees An array of fees requested including: - setup The setup fee - cancel The cancel fee - total The total after discount, fees, but before tax - total_w_tax The total after discount, fees, and tax - tax The total tax
public integer
# getListCount( string $status = null )

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

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

Parameters

$status
string
$status The status type of packages to retrieve ('active', 'inactive', 'restricted', default null for all)

Returns

integer
The total number of packages

See

Packages::getList()
public mixed
# getAllGroups( integer $company_id, integer $package_id = null )

Fetches all package groups belonging to a company, or optionally, all package groups belonging to a specific package

Fetches all package groups belonging to a company, or optionally, all package groups belonging to a specific package

Parameters

$company_id
integer
$company_id The company ID
$package_id
integer
$package_id The package ID to fetch groups of (optional, default null)

Returns

mixed
An array of stdClass objects representing package groups, or false if none found
public
# getAllAddonGroups( mixed $parent_group_id )

Returns all addon package groups for the given package group.

Returns all addon package groups for the given package group.

public mixed
# getAllPackagesByGroup( integer $package_group_id )

Fetches all packages belonging to a specific package group

Fetches all packages belonging to a specific package group

Parameters

$package_group_id
integer
$package_group_id The ID of the package group

Returns

mixed
An array of stdClass objects representing packages, or false if none exist
public array
# getCompatiblePackages( integer $package_id, integer $module_id, string $type )

Get all compatible packages

Get all compatible packages

Parameters

$package_id
integer
$package_id The ID of the package to fetch all compatible packages for
$module_id
integer
$module_id The ID of the module to include compatible packages for
$type
string
$type The type of package group to include ("standard", "addon")

Returns

array
An array of stdClass objects, each representing a compatible package and its pricing
private array
# getPackageEmails( integer $package_id )

Fetches all emails created for the given package

Fetches all emails created for the given package

Parameters

$package_id
integer
$package_id The package ID to fetch email for

Returns

array
An array of stdClass objects representing email content
private array
# getPackagePricing( integer $package_id )

Fetches all pricing for the given package

Fetches all pricing for the given package

Parameters

$package_id
integer
$package_id The package ID to fetch pricing for

Returns

array
An array of stdClass objects representing package pricing
private mixed
# getAPackagePricing( integer $package_pricing_id )

Fetches a single pricing, including its package's taxable status

Fetches a single pricing, including its package's taxable status

Parameters

$package_pricing_id
integer
$package_pricing_id The ID of the package pricing to fetch

Returns

mixed
A stdClass object representing the package pricing, false if no such package pricing exists
private array
# getPackageMeta( integer $package_id )

Fetches all package meta data for the given package

Fetches all package meta data for the given package

Parameters

$package_id
integer
$package_id The package ID to fetch meta data for

Returns

array
An array of stdClass objects representing package meta data
private array
# getPackageGroups( integer $package_id )

Fetches all package group assignment for the given package

Fetches all package group assignment for the given package

Parameters

$package_id
integer
$package_id The package ID to fetch pricing for

Returns

array
An array of stdClass objects representing package groups
private Record
# getPackages( string $status = null )

Partially constructs the query required by both Packages::getList() and Packages::getListCount()

Partially constructs the query required by both Packages::getList() and Packages::getListCount()

Parameters

$status
string
$status The status type of packages to retrieve ('active', 'inactive', 'restricted', default null for all)

Returns

Record
The partially constructed query Record object
private
# setGroups( integer $package_id, array $groups = null )

Removes all existing groups set for the given package, replaces them with the given list of groups

Removes all existing groups set for the given package, replaces them with the given list of groups

Parameters

$package_id
integer
$package_id The package to replace groups on
$groups
array
$groups A numerically-indexed array of group IDs
private
# setMeta( integer $package_id, array $vars )

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

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

Parameters

$package_id
integer
$package_id The ID of the package to update
$vars
array
$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)
private
# formatRawMeta( array $raw_meta )

Formats an array of raw meta stdClass objects into a stdClass object whose public member variables represent meta keys and whose values are automatically decrypted and unserialized as necessary.

Formats an array of raw meta stdClass objects into a stdClass object whose public member variables represent meta keys and whose values are automatically decrypted and unserialized as necessary.

Parameters

$raw_meta
array
$raw_meta An array of stdClass objects representing meta data
public boolean
# validateServiceExists( integer $package_id )

Checks whether a service exists for a specific package ID

Checks whether a service exists for a specific package ID

Parameters

$package_id
integer
$package_id The package ID to check

Returns

boolean
True if a service exists for this package, false otherwise
public boolean
# validateStatus( string $status )

Validates the package 'status' field type

Validates the package 'status' field type

Parameters

$status
string
$status The status type

Returns

boolean
True if validated, false otherwise
public boolean
# validatePeriod( 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
# validateGroup( integer $group_id, integer $company_id )

Validates that the given group belongs to the given company ID

Validates that the given group belongs to the given company ID

Parameters

$group_id
integer
$group_id The ID of the group to test
$company_id
integer
$company_id The ID of the company to validate exists for the given group

Returns

boolean
True if validated, false otherwise
private array
# getRules( mixed $vars )

Fetches the rules for adding/editing a package

Fetches the rules for adding/editing a package

Returns

array
The package rules

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