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 AppController

The parent controller for the application.

Controller
Extended by AppController

Direct known subclasses

_404, AdminBilling, AdminCompanyGroups, AdminCompanyLookandfeel, AdminCompanyModules, AdminCompanyPlugins, AdminCompanyTaxes, AdminCompanyThemes, AdminController, AdminDialog, AdminLicense, AdminLogin, AdminClients, AdminLogout, AdminMyinfo, AdminPackageOptions, AdminPackages, AdminSearch, AdminSettings, AdminSystemApi, AdminSystemAutomation, AdminSystemBackup, AdminSystemCompanies, AdminCompanyAutomation, AdminSystemGeneral, AdminSystemHelp, AdminSystemMarketplace, AdminSystemStaff, AdminSystemUpgrade, AdminTest, AdminTests, AdminTheme, AdminTools, AdminUpgrade, AdminCompanyBilling, Api, Callback, ClientController, ClientLogin, ClientLogout, ClientMaintenance, ClientPay, ClientTheme, Cron, Uploads, AdminCompanyCurrencies, AdminCompanyCustomfields, AdminCompanyEmails, AdminCompanyGateways, AdminCompanyGeneral

Indirect known subclasses

AdminClientsService, AdminReports, AdminReportsCustomize, ClientAccounts, ClientContacts, ClientDialog, ClientInvoices, ClientServices, ClientTransactions

Package: blesta\app
Copyright: Copyright (c) 2010, Phillips Data, Inc.
License: The Blesta License Agreement
Link: Blesta
Located at app/app_controller.php

Methods summary

final public
# __construct( mixed $controller, mixed $action, mixed $is_cli )

The main app controller constructor. Performs just-in-time bootstrapping for this particular application.

The main app controller constructor. Performs just-in-time bootstrapping for this particular application.

Overrides

Controller::__construct
protected mixed
# getCompany( )

Returns the current company being accessed

Returns the current company being accessed

Returns

mixed
A stdClass object representing the company, false if no such company exists
protected
# primeCompany( stdClass $company )

Prime resources for use with the given company. Sets language settings, currency conversion, date/time conversion, and other options.

Prime resources for use with the given company. Sets language settings, currency conversion, date/time conversion, and other options.

Parameters

$company
stdClass
$company A stdClass object representing the company to prime
public
# preAction( )

Overwritable method called before the index method, or controller specified action. This method is public to make compatible with PHP 5.1 (due to a bug not fixed until 5.2). It is, however, not a callable action.

Overwritable method called before the index method, or controller specified action. This method is public to make compatible with PHP 5.1 (due to a bug not fixed until 5.2). It is, however, not a callable action.

Overrides

Controller::preAction
protected
# triggerPreAction( )

Trigger the pre action events

Trigger the pre action events

public
# postAction( )

Post-action

Post-action

Overrides

Controller::postAction
protected
# setMaintenance( )

Sets maintenance mode, redirects clients to login page and logs them out

Sets maintenance mode, redirects clients to login page and logs them out

protected
# verifyCsrfToken( )

Verifies the CSRF token for the POST request, evaluates that CSRF is required for the form, and if the token fails to validate removes all post data and sets an erorr message. Also strips the CSRF token from valid post data after verification.

Verifies the CSRF token for the POST request, evaluates that CSRF is required for the form, and if the token fails to validate removes all post data and sets an erorr message. Also strips the CSRF token from valid post data after verification.

protected
# setMessage( string $type, string $value, boolean $return = false, array $params = null, boolean $in_current_view = true )

Sets the given error type into the view

Sets the given error type into the view

Parameters

$type
string
$type The type of message ("message", "error", "info", or "notice")
$value
string
$value The text to display
$return
boolean
$return True to return the message, false to set it withing the view
$params
array
$params An array of additional parameters to set to the message view
$in_current_view
boolean
$in_current_view True to set the message in the current view, false to set in the default view directory. That is, if invoking this method from a plugin, then setting $in_current_view to false will set the message to the default view, else a message.pdt file will be loaded from the plugin view directory.
protected
# flashMessage( string $type, string $value, array $params = null, boolean $in_current_view = true )

Sets the given message type to be displayed on the next page load

Sets the given message type to be displayed on the next page load

Parameters

$type
string
$type The type of message ("message", "error", or "notice")
$value
string
$value The text to display
$params
array
$params An array of additional parameters to set to session flash
$in_current_view
boolean
$in_current_view True to set the message in the current view, false to set in the default view directory. That is, if invoking this method from a plugin, then setting $in_current_view to false will set the message to the default view, else a message.pdt file will be loaded from the plugin view directory.
protected integer
# requireLogin( string $redirect_to = null )

Ensures that the user has an active session with a "blesta_id" set. Detects whether the current request is an AJAX request, and only redirects non-AJAX based requests, otherwise issues "401 Unauthorized".

Ensures that the user has an active session with a "blesta_id" set. Detects whether the current request is an AJAX request, and only redirects non-AJAX based requests, otherwise issues "401 Unauthorized".

Verifies that the user has an active session with a "blesta_staff_id" or "blesta_client_id" set, depending on the portal being accessed.

Also verifies that the user is authorized to access the requested resource. For non-AJAX requests renders an error for when unauthorized, otherwise issues "403 Forbidden".

Parameters

$redirect_to
string
$redirect_to The URI/URL to redirect to for non-AJAX unauthorized requests, defaults to the login screen. CAUTION: Be careful where you redirect as you may create a redirection loop if the page you are directing to also invokes this method

Returns

integer
The ID of the user currently logged in to the portal
protected integer
# isLoggedIn( )

Checks whether the user is logged in to the current portal (admin or client)

Checks whether the user is logged in to the current portal (admin or client)

Returns

integer
Returns the ID of the user if the user is logged in as a the given type, null otherwise
protected boolean
# isStaffAsClient( )

Checks whether the current user is a staff user and whether the user is currently logged into the client portal.

Checks whether the current user is a staff user and whether the user is currently logged into the client portal.

Returns

boolean
True if the user is a staff user logged in as a client, false otherwise
protected boolean
# isAjax( )

Determines whether the current request is an AJAX request

Determines whether the current request is an AJAX request

Returns

boolean
True if this is an AJAX request, false otherwise.
protected boolean
# renderAjaxWidgetIfAsync( mixed $content_only = false )

Invokes AppController:renderAjaxWidget if the request was made Asynchronously, also sets $is_ajax to true within the view

Invokes AppController:renderAjaxWidget if the request was made Asynchronously, also sets $is_ajax to true within the view

Parameters

$content_only
mixed
$content_only If (boolean) true, will set the "replacer" variable in the JSON response to notify the AJAX requester that only the widget content section is to be replaced, (boolean) false will replace entire widget section is set to be replaced, null renders the widget as whole

Returns

boolean
false if the request was made asynchronously, true otherwise

See

AppController::renderAjaxWidget()
protected
# renderAjaxWidget( string $view, mixed $content_only = false )

Output the swappable content section of a widget box using the given view in JSON format suitable for AJAX handling and replacement

Output the swappable content section of a widget box using the given view in JSON format suitable for AJAX handling and replacement

Parameters

$view
string
$view The name of the view to render
$content_only
mixed
$content_only If (boolean) true, will set the "replacer" variable in the JSON response so notify the AJAX requester that only the widget content section is to be replaced, (boolean) false will replace entire widget section is set to be replaced, null renders the widget as whole

See

AppController::renderAjaxWidgetIfAsync()
protected
# outputAsJson( mixed $data )

Renders the data to the standard output stream as a JSON string

Renders the data to the standard output stream as a JSON string

Parameters

$data
mixed
$data The data to encode as a JSON string and output
protected array
# getMonths( )

Retrieves a list of the months and their abbreviations for the calendar

Retrieves a list of the months and their abbreviations for the calendar

Returns

array
A list of month names and abbreviations
protected array
# getDaysOfWeek( )

Retrieves a list of the days of the week and their abbreviations for the calendar

Retrieves a list of the days of the week and their abbreviations for the calendar

Returns

array
A list of day names, abbreviations, and the weekly start day
protected array
# getTimes( mixed $interval = 1 )

Retrieve a list of times (in 24-hour format)

Retrieve a list of times (in 24-hour format)

Returns

array
A list of times
public
# reorderWidgets( )

Record the state of the widget windows on the Home Dashboard screen via an ajax request

Record the state of the widget windows on the Home Dashboard screen via an ajax request

public
# toggleWidget( )

Toggles the open state of the given widget, saving its state

Toggles the open state of the given widget, saving its state

public
# getWidgets( )

Outputs a JSON encoded array of all widgets to be displayed within the requested controller. Expects $this->get[0] to identify the client ID for which items are to be rendered.

Outputs a JSON encoded array of all widgets to be displayed within the requested controller. Expects $this->get[0] to identify the client ID for which items are to be rendered.

protected
# adminWidgets( )

Outputs a JSON encoded array of admin widgets for the requested controller

Outputs a JSON encoded array of admin widgets for the requested controller

protected
# clientWidgets( )

Outputs a JSON encoded array of admin widgets for the requested controller

Outputs a JSON encoded array of admin widgets for the requested controller

protected
# setWidgetState( string $widget_location )

Loads and sets the current widget state for all widgets stored

Loads and sets the current widget state for all widgets stored

Parameters

$widget_location
string
$widget_location The location of the widget ("widget_staff_home", or "widget_staff_client", or "widget_staff_billing")
protected integer
# layoutSections( string $layout )

Returns the number of section contained in the given layout

Returns the number of section contained in the given layout

Parameters

$layout
string
$layout The layout to fetch sections for (layout1, layout2, etc.)

Returns

integer
The number of sections contained in that layout
final protected
# licenseCheck( )

Checks to ensure the license is valid, redirects user to update license key if invalid

Checks to ensure the license is valid, redirects user to update license key if invalid

protected
# setNav( )

Sets the primary and secondary navigation links. Performs authorization checks on each navigational element. May cache nav results if possible for better performance.

Sets the primary and secondary navigation links. Performs authorization checks on each navigational element. May cache nav results if possible for better performance.

protected array
# setNavActive( array $nav, boolean $is_cached = false, stdClass $group = null )

Sets which primary and secondary nav items are active. Will also verify access permissions to the given primary and secondary nav items if not pulled from cache

Sets which primary and secondary nav items are active. Will also verify access permissions to the given primary and secondary nav items if not pulled from cache

Parameters

$nav
array
$nav The array of primary and secondary nav items
$is_cached
boolean
$is_cached Trus if $nav was cached and therefore does not require permission validation.
$group
stdClass
$group The client or staff group to verify permissions on (if not cached)

Returns

array
The updated $nav array, with the correct primary and secondary nav items set as active
protected
# setTheme( )

Sets the theme color scheme

Sets the theme color scheme

protected boolean
# authorized( string $controller = null, string $action = null, stdClass $group = null )

Verifies that the currently logged in user is authorized for the given Controller and Action (or current Controller/Action if none given). Will first check whether the Controller and Action is a permission value, and if so, checks to ensure the staff or client group user is authorized to access that resource

Verifies that the currently logged in user is authorized for the given Controller and Action (or current Controller/Action if none given). Will first check whether the Controller and Action is a permission value, and if so, checks to ensure the staff or client group user is authorized to access that resource

Parameters

$controller
string
$controller The controller to check authorization on, null will default to the current controller
$action
string
$action The action to check authorization on, null will default to the current action
$group
stdClass
$group The staff or client group to check authorization on, null will fetch the group of the current user

Returns

boolean
Returns true if the user is authorized for that resource, false otherwise
protected
# setDefaultView( string $dir )

Set the default view to be rendered henceforth

Set the default view to be rendered henceforth

Parameters

$dir
string
$dir

Methods inherited from Controller

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

Magic methods summary

Properties summary

public string $request_uri
#

The requested URI

The requested URI

public string $server_protocol
#

The server protocol (e.g. HTTP/1.0)

The server protocol (e.g. HTTP/1.0)

public string $base_url
#

The base URL for this request (e.g https://www.domain.com/)

The base URL for this request (e.g https://www.domain.com/)

public string $base_uri
#

The base URI for this request (e.g. admin)

The base URI for this request (e.g. admin)

protected mixed $company_id
#

@ var int The company ID

@ var int The company ID

protected string $admin_uri
#

The URI to the admin portal

The URI to the admin portal

protected string $client_uri
#

The URI to the client portal

The URI to the client portal

protected array $helpers
#

All helpers to load by default

All helpers to load by default

protected array $components
#

All components to load by default

All components to load by default

protected string $layout
#

The view layout directory

The view layout directory

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