public
|
#
__construct( )
Initialize Companies
Overrides
|
public
integer
|
#
add( array $vars )
Add a company
Parameters
- $vars
array $vars An array of company info including: -company_id The ID of the company
whose settings to import from -name The name of the company -address The address
of the company (whole postal address) -phone The phone number of the company
-fax The fax number of the company
Returns
integer The company ID added, void on error
|
public
|
#
edit( integer $company_id, array $vars )
Edit an existing company
Parameters
- $company_id
integer $company_id The ID of the company to update
- $vars
array $vars An array of company info including: -name The name of the company -address
The address of the company (whole postal address) -phone The phone number of the
company -fax The fax number of the company
|
public
|
#
delete( integer $company_id )
Delete an existing company. Only companies no longer in use may be
removed.
Delete an existing company. Only companies no longer in use may be
removed.
Parameters
- $company_id
integer $company_id The company ID to remove from the system
|
public
mixed
|
#
generateKeyPair( integer $company_id, integer $bits, string $passphrase = null )
Generates a new public/private key pair for the company and stores it in the
database. Will not overwrite any existing key pair for the same company.
Generates a new public/private key pair for the company and stores it in the
database. Will not overwrite any existing key pair for the same company.
Parameters
- $company_id
integer $company_id The ID of the company to generate the key pair for
- $bits
integer $bits The number of bits (i.e. 1024) for the key length
- $passphrase
string $passphrase The (optional) passphrase to use to encrypt the private key with.
Only set if you want super high security (and don't even trust Blesta to decrypt
things by itself)
Returns
mixed An array containing both parts of the key pair on success, false if the key is
already set for this company
|
public
mixed
|
#
get( integer $company_id )
Fetches a company with the given ID
Fetches a company with the given ID
Parameters
- $company_id
integer $company_id The ID of the company to fetch
Returns
mixed A stdClass object representing the company, false if no such company exists
|
public
stdClass
|
#
getByHostname( string $hostname )
Retrieves the company configured for the given hostname. Looks for hostname
and www.hostname
Retrieves the company configured for the given hostname. Looks for hostname
and www.hostname
Parameters
- $hostname
string $hostname The hostname to fetch on (also looks at www.hostname)
Returns
stdClass
A stdClass object representing the company if it exists, false otherwise
|
public
array
|
#
getAllAvailable( integer $staff_id )
Fetches all companies available to the given staff ID
Fetches all companies available to the given staff ID
Parameters
- $staff_id
integer $staff_id The ID of the staff member
Returns
array An array of stdClass objects each representing a company
|
public
mixed
|
#
getAll( )
Fetches all companies
Returns
mixed An array of stdClass objects representing each company, or false if none exist
|
public
mixed
|
#
getList( integer $page = 1, string $order_by = array('id'=>"ASC") )
Fetches a list of all companies
Fetches a list of all companies
Parameters
- $page
integer $page The page to return results for
- $order_by
string $order_by The sort and order conditions (e.g. array('sort_field'=>"ASC"),
optional)
Returns
mixed An array of objects or false if no results.
|
public
integer
|
#
getListCount( )
Return the total number of client groups returned from Companies::getList(),
useful in constructing pagination for the getList() method.
Return the total number of client groups returned from Companies::getList(),
useful in constructing pagination for the getList() method.
Returns
integer The total number of clients
See
|
private
Record
|
#
getCompanies( )
Partially constructs the query required by both Companies::getList() and
Companies::getListCount()
Partially constructs the query required by both Companies::getList() and
Companies::getListCount()
Returns
Record
The partially constructed query Record object
|
public
|
#
setSettings( integer $company_id, array $settings )
Sets a group of company settings
Sets a group of company settings
Parameters
- $company_id
integer $company_id The company ID
- $settings
array $settings Settings to set as key/value pairs
|
public
|
#
setSetting( string $company_id, integer $key, string $value, mixed $encrypted = null )
Sets a company settings
Parameters
- $company_id
string $key The setting key (i.e. name)
- $key
integer $company_id The company ID
- $value
string $value The value to set for this setting
- $encrypted
mixed $encrypted True to encrypt $value, false to store unencrypted, null to encrypt
if currently set to encrypt
|
public
|
#
unsetSetting( string $company_id, mixed $key )
Unsets a setting from the company settings. CAUTION: This method will
physically remove the setting from the system, and could have dire consequences.
You should never use this method, except when attempting to remove a setting
created by Companies::setSettings() or Companies::setSetting() that did not
previously exist for this installation.
Unsets a setting from the company settings. CAUTION: This method will
physically remove the setting from the system, and could have dire consequences.
You should never use this method, except when attempting to remove a setting
created by Companies::setSettings() or Companies::setSetting() that did not
previously exist for this installation.
Parameters
- $company_id
string $key The setting to unset
- $key
|
public
mixed
|
#
getSettings( integer $company_id, boolean $ignore_inheritence = false )
Fetch all settings that may apply to this company. Settings are inherited in
the order of company_settings -> settings where "->" represents the left
item inheriting (and overwriting in the case of duplicates) values found in the
right item.
Fetch all settings that may apply to this company. Settings are inherited in
the order of company_settings -> settings where "->" represents the left
item inheriting (and overwriting in the case of duplicates) values found in the
right item.
Parameters
- $company_id
integer $company_id The company ID to retrieve settings for
- $ignore_inheritence
boolean $ignore_inheritence True to only retrieve company settings, false to get all
inherited settings (default false)
Returns
mixed An array of objects containg key/values for the settings, false if no records
found
|
public
mixed
|
#
getSetting( integer $company_id, string $key )
Fetch a specific setting that may apply to this company. Settings are
inherited in the order of company_settings -> settings where "->"
represents the left item inheriting (and overwriting in the case of duplicates)
values found in the right item.
Fetch a specific setting that may apply to this company. Settings are
inherited in the order of company_settings -> settings where "->"
represents the left item inheriting (and overwriting in the case of duplicates)
values found in the right item.
Parameters
- $company_id
integer $company_id The company ID to retrieve a setting for
- $key
string $key The key name of the setting to fetch
Returns
mixed A stdObject containg the key and value, false if no such key exists
|
private
array
|
#
getRules( array $vars, boolean $edit = false )
Returns the rule set for adding/editing companies
Returns the rule set for adding/editing companies
Parameters
- $vars
array $vars A list of vars to be validated
- $edit
boolean $edit True when editing a company, false otherwise
Returns
array Company rules
See
Companies::add() and Companies::edit()
|
public
boolean
|
#
validateHostnameUnique( string $hostname, integer $company_id = null )
Checks whether the given hostname is unique or not
Checks whether the given hostname is unique or not
Parameters
- $hostname
string $hostname The hostname to check
- $company_id
integer $company_id The company ID to exclude from the unique check (ie itself,
optional, default null)
Returns
boolean True if the given hostname is unique, false otherwise
|
public
boolean
|
#
validateCompanyInUse( integer $company_id )
Checks whether the given company ID is in use by a client or staff group
Checks whether the given company ID is in use by a client or staff group
Parameters
- $company_id
integer $company_id The company ID to check
Returns
boolean True if the company is in use, false otherwise
|
public
|
#
validateCustomization( array $vars )
Validates Invoice customization settings
Validates Invoice customization settings
Parameters
- $vars
array $vars An array of key/value pairs of invoice customization settings to validate
|