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

  • _404
  • AdminBilling
  • AdminClient
  • AdminClients
  • AdminCompanyAutomation
  • AdminCompanyBilling
  • AdminCompanyCurrencies
  • AdminCompanyCustomfields
  • AdminCompanyEmails
  • AdminCompanyGateways
  • AdminCompanyGeneral
  • AdminCompanyGroups
  • AdminCompanyModules
  • AdminCompanyPlugins
  • AdminCompanyTaxes
  • AdminDialog
  • AdminLicense
  • AdminLogin
  • AdminLogout
  • AdminMain
  • AdminMyinfo
  • AdminPackages
  • AdminSearch
  • AdminSettings
  • AdminSystemApi
  • AdminSystemAutomation
  • AdminSystemBackup
  • AdminSystemCompanies
  • AdminSystemGeneral
  • AdminSystemHelp
  • AdminSystemMarketplace
  • AdminSystemStaff
  • AdminSystemThemes
  • AdminSystemUpgrade
  • AdminTests
  • AdminTheme
  • AdminTools
  • Api
  • Callback
  • ClientAccounts
  • ClientContacts
  • ClientDialog
  • ClientInvoices
  • ClientLogin
  • ClientLogout
  • ClientMain
  • ClientPay
  • ClientServices
  • ClientTheme
  • ClientTransactions
  • Cron
  • Install
  • Main
  • Upgrade
  • Uploads

Class Cron

The Cron controller. Handles all automated tasks that run via a cron job or scheduled task.

Controller
Extended by AppController
Extended by Cron
Package: blesta\app\controllers
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/controllers/cron.php

Methods summary

public
# preAction( )

Pre-action

Pre-action

Overrides

AppController::preAction
public
# index( )

Runs the cron

Runs the cron

Overrides

Controller::index
public
# all( mixed $cron_log_group = null )

Run all cron tasks

Run all cron tasks

private
# allSystem( )

Runs all system-level cron tasks

Runs all system-level cron tasks

public
# createInvoices( string $cron_log_group = null )

Runs the create invoice task

Runs the create invoice task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private string
# createRecurringInvoices( )

Create all recurring invoices

Create all recurring invoices

Returns

string
The output from attempting to create recurring invoices
private string
# createRenewingServiceInvoices( )

Create all renewing service invoices

Create all renewing service invoices

Returns

string
The output from attempting to create all renewing service invoices
private array
# buildServiceCouponLineItems( array $services, string $default_currency, array & $coupons )

Retrieves a list of coupons to be applied to an invoice for recurring services, assumes services given are for a single client only

Retrieves a list of coupons to be applied to an invoice for recurring services, assumes services given are for a single client only

Parameters

$services
array
$services A list of services whose coupons to fetch
$default_currency
string
$default_currency The ISO 4217 currency code for the client
$coupons
array
$coupons A reference to coupons that will need to be incremented

Returns

array
A list of stdClass objects representing coupons to apply to an invoice created for a recurring service

See

Cron::createRenewingServiceInvoices()
public
# applyCredits( string $cron_log_group = null )

Runs the apply credits task

Runs the apply credits task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private array
# getCreditApplyAmounts( array $client_credits = array(), array $client_invoices = array() )

Creates a list of credits to be applied to invoices for each transaction and also closes invoices with no amount due

Creates a list of credits to be applied to invoices for each transaction and also closes invoices with no amount due

Parameters

$client_credits
array
$client_credits A list of client credits grouped by client ID
$client_invoices
array
$client_invoices A list of client credits grouped by client ID

Returns

array
A list of credits set to be applied keyed by transaction ID with each containing a list of amounts: - invoice_id The invoice ID to apply the credit to - amount The amount to apply to the invoice_id for this particular transaction

See

Cron::applyCredits()
public
# autoDebitInvoices( string $cron_log_group = null )

Runs the autodebit invoices task

Runs the autodebit invoices task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# paymentReminders( string $cron_log_group = null )

Runs the payment reminders task

Runs the payment reminders task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private boolean
# shouldSendReminder( stdClass $invoice, stdClass $client, string $action )

Determines whether or not to send a payment reminder notice for an invoice

Determines whether or not to send a payment reminder notice for an invoice

Parameters

$invoice
stdClass
$invoice An invoice object
$client
stdClass
$client The client object that the invoice belongs to
$action
string
$action The email notice action

Returns

boolean
True if a reminder should be sent out for this invoice, false otherwise

See

Cron::paymentReminders()
private mixed
# sendAutodebitNotice( stdClass $client, stdClass $contact, stdClass $invoice, mixed $autodebit_account = null )

Sends an autodebit notice to the given contact regarding this invoice

Sends an autodebit notice to the given contact regarding this invoice

Parameters

$client
stdClass
$client The client object
$contact
stdClass
$contact The contact object representing one of the client's contacts
$invoice
stdClass
$invoice The invoice to send a payment notice about, belonging to this client
$autodebit_account
mixed
An stdClass object representing the autodebit payment account for this client (if any) (optional)

Returns

mixed
An array of errors on failure, or false on success

See

Cron::paymentReminders()
private mixed
# sendPaymentNotice( string $action, stdClass $client, stdClass $contact, stdClass $invoice, mixed $autodebit_account = null )

Sends a payment notice to the given contact regarding this invoice

Sends a payment notice to the given contact regarding this invoice

Parameters

$action
string
$action The payment notice setting (i.e. one of "notice1", "notice2", "notice3")
$client
stdClass
$client The client object
$contact
stdClass
$contact The contact object representing one of the client's contacts
$invoice
stdClass
$invoice The invoice to send a payment notice about, belonging to this client
$autodebit_account
mixed
An stdClass object representing the autodebit payment account for this client (if any) (optional)

Returns

mixed
An array of errors on failure, or false on success

See

Cron::paymentReminders()
public
# cardExpirationReminders( string $cron_log_group = null )

Runs the card expiration reminder task

Runs the card expiration reminder task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# deliverInvoices( string $cron_log_group = null )

Runs the deliver invoices task

Runs the deliver invoices task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private array
# groupInvoices( array $invoices, string $type = null, array $options = null )

Groups invoices into invoice IDs by client and $type

Groups invoices into invoice IDs by client and $type

Parameters

$invoices
array
$invoices A list of stdClass objects representing invoices
$type
string
$type The method to use to group the invoices by client (optional), including: - delivery_method Group the invoices by client ID and invoice delivery method - currency Group the invoices by client ID and invoice currency
$options
array
$options A set of options that may be used for some types

Returns

array
A list of invoices grouped by client and delivery method
private array
# sendInvoices( array $invoice_ids, stdClass $client, string $delivery_method, string $invoice_status_type = "unpaid" )

Sends a group of invoices to a given client via the delivery method and marks each invoice delivered

Sends a group of invoices to a given client via the delivery method and marks each invoice delivered

Parameters

$invoice_ids
array
$invoice_ids A list of invoice IDs belonging to the client
$client
stdClass
An stdClass object representing the client
$delivery_method
string
$delivery_method The delivery method to send the invoices with
$invoice_status_type
string
$invoice_status_type The invoice status type indicating the type of invoice_ids given: (optional, default "unpaid") - paid - unpaid

Returns

array
An array of errors from attempting to deliver the invoices
public
# deliverInvoiceReport( mixed $cron_log_group = null )
public
# processRenewingServices( string $cron_log_group = null )

Runs the process renewing services task

Runs the process renewing services task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# suspendServices( string $cron_log_group = null )

Runs the suspend services task

Runs the suspend services task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# unsuspendServices( string $cron_log_group = null )

Runs the unsuspend services task

Runs the unsuspend services task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# cancelScheduledServices( string $cron_log_group = null )

Runs the cancel scheduled services task

Runs the cancel scheduled services task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# addPaidPendingServices( string $cron_log_group = null )

Runs the add paid pending services task

Runs the add paid pending services task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# updateExchangeRates( string $cron_log_group = null )

Runs the update exchange rates task

Runs the update exchange rates task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# pluginTasks( string $cron_log_group = null )

Runs all plugin tasks

Runs all plugin tasks

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
public
# cleanLogs( string $cron_log_group = null )

Runs the clean-up logs task

Runs the clean-up logs task

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private
# sftpBackup( string $cron_log_group = null )

Runs the sFTP database backup task (system)

Runs the sFTP database backup task (system)

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private
# amazonS3Backup( string $cron_log_group = null )

Runs the AmazonS3 database backup task (system)

Runs the AmazonS3 database backup task (system)

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private
# license( string $cron_log_group = null )

Runs the system task to call home and validate the license

Runs the system task to call home and validate the license

Parameters

$cron_log_group
string
$cron_log_group The cron log group that this event is apart of (optional, default null)
private boolean
# isTimeToRun( stdClass $cron_task, boolean $system = false )

Determines whether a cron task is enabled and if it is time for the task to run or not

Determines whether a cron task is enabled and if it is time for the task to run or not

Parameters

$cron_task
stdClass
$cron_task An stdClass object representing the cron task
$system
boolean
$system True if the task is a system-level task, false if it is company-level (optional, default false)

Returns

boolean
True if this cron task can be run, false otherwise
private boolean
# isCurrentDay( integer $day )

Determines whether today is the day of the month given

Determines whether today is the day of the month given

Parameters

$day
integer
$day The day of the month to check (i.e. in range [1,31])

Returns

boolean
True if today is the current day given, false otherwise
private mixed
# logTaskStarted( integer $run_id, string $event, string $cron_log_group, string $start_date, string $output = null )

Logs to the cron that a task has started

Logs to the cron that a task has started

Parameters

$run_id
integer
$run_id The run ID of this event
$event
string
$event The event to log
$cron_log_group
string
$cron_log_group The cron log group that this event is apart of
$start_date
string
$start_date The start date of the task in Y-m-d H:i:s format
$output
string
$output The output from running the task (optional)

Returns

mixed
An array of errors, or false if there are no errors
private mixed
# logTaskCompleted( integer $run_id, string $event, string $cron_log_group, string $end_date, string $output )

Logs to the cron that a current task has been completed

Logs to the cron that a current task has been completed

Parameters

$run_id
integer
$run_id The run ID of this event
$event
string
$event The event to log
$cron_log_group
string
$cron_log_group The cron log group that this event is apart of
$end_date
string
$end_date The start date of the task in Y-m-d H:i:s format
$output
string
$output The output from running the task

Returns

mixed
An array of errors, or false if there are no errors
private string
# createCronLogGroup( )

Creates a cron log group

Creates a cron log group

Returns

string
The cron log group
private mixed
# getCronTask( string $cron_task_key, string $plugin_dir = null, boolean $system = false )

Retrieves a cron task

Retrieves a cron task

Parameters

$cron_task_key
string
$cron_task_key The cron task key of the cron task to get
$plugin_dir
string
$plugin_dir The directory to the plugin this cron task is associated with
$system
boolean
$system True if the task is a system-level task, false if it is company-level (optional, default false)

Returns

mixed
An stdClass representing the cron task, or false if none exist
private string
# setOutput( string $new, string $old = "", boolean $echo = true )

Sets output data

Sets output data

Parameters

$new
string
$new The new output data
$old
string
$old The old output data, if any (optional, default "")
$echo
boolean
$echo True to output the new text

Returns

string
A concatenation of the old and new output

Methods inherited from AppController

__construct(), authorized(), flashMessage(), getCompany(), getDaysOfWeek(), getMonths(), getTimes(), getWidgets(), isAjax(), isLoggedIn(), isStaffAsClient(), licenseCheck(), outputAsJson(), postAction(), primeCompany(), renderAjaxWidget(), renderAjaxWidgetIfAsync(), reorderWidgets(), requireLogin(), setMessage(), setWidgetState(), toggleWidget()

Methods inherited from Controller

clearCache(), components(), draw(), emptyCache(), helpers(), partial(), redirect(), render(), set(), setDefaultViewPath(), startCaching(), stopCaching(), uses()

Magic methods summary

Properties summary

private array $cron_tasks
#

A list of cron task settings for the current company

A list of cron task settings for the current company

Properties inherited from AppController

$admin_uri, $base_uri, $base_url, $client_uri, $company_id, $components, $helpers, $layout, $request_uri, $server_protocol

Properties inherited from Controller

$action, $controller, $files, $get, $is_cli, $plugin, $post, $structure, $structure_view, $uri, $uri_str, $uses, $view

Blesta API documentation generated by ApiGen 2.8.0