ManagedAccounts extends AppModel
Managed Accounts Model
Table of Contents
Properties
| $client_uri |
Methods
| __construct() | Initialize ManagedAccounts |
| accept() | Grants access to a contact to manage a specific client |
| decline() | Declines the invitation to manage a specific client |
| get() | Fetches a managed account |
| getAll() | Fetches a list of all accounts managed by a specific client |
| getAllManagers() | Fetches a list of all contacts managing a specific client |
| getInvitation() | Fetch an invitation |
| getInvitationByToken() | Fetch an invitation by the token |
| getInvitations() | Fetches the pending invitations for a given client |
| getList() | Fetches a list of all accounts managed by a specific client |
| getListCount() | Return the total number of users returned from ManagedAccounts::getList(), useful in constructing pagination for the getList() method. |
| getManager() | Fetches a manager |
| getManagersList() | Fetches a list of all managers who have been granted access to a specific client |
| getManagersListCount() | Return the total number of users returned from ManagedAccounts::getManagersList(), useful in constructing pagination for the getManagersList() method. |
| getPermissionOptions() | Returns an array of key/value pairs of all available permission options |
| getSearchCount() | Return the total number of accounts returned from ManagedAccounts::search(), useful in constructing pagination |
| hasPermission() | Checks whether or not the manager has permissions for the given area |
| invite() | Generates and mails a new invitation |
| manage() | Manage an account |
| revoke() | Revokes the access from a contact to a specific client |
| search() | Search accounts |
| send() | Sends the email invitation link |
| setPermissions() | Sets permissions for the given contact and client |
| switchBack() | Switches back to the manager account |
| getAccounts() | Partially constructs the query required by both ManagedAccounts::getManagersList() and ManagedAccounts::getManagersListCount() |
| getManagers() | Partially constructs the query required by both ManagedAccounts::getManagersList() and ManagedAccounts::getManagersListCount() |
| searchAccounts() | Partially constructs the query for searching accounts |
Methods
__construct()
Initialize ManagedAccounts
public
__construct() : mixed
accept()
Grants access to a contact to manage a specific client
public
accept(mixed $invitation_id) : mixed
Parameters
- $invitation_id : mixed
-
The ID or the token of the invitation to approve
decline()
Declines the invitation to manage a specific client
public
decline(mixed $invitation_id) : mixed
Parameters
- $invitation_id : mixed
-
The ID or the token of the invitation to decline
get()
Fetches a managed account
public
get(int $contact_id, int $client_id) : mixed
Parameters
- $contact_id : int
-
The ID of the contact to fetch
- $client_id : int
-
The ID of the client the contact is managing
Return values
mixed —An object containing the manager, false if manager doesn't exist
getAll()
Fetches a list of all accounts managed by a specific client
public
getAll(int $client_id[, array<string|int, mixed> $order = ['last_name' => 'asc', 'first_name' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $client_id : int
-
The client ID to fetch all accounts that can be managed
- $order : array<string|int, mixed> = ['last_name' => 'asc', 'first_name' => 'asc']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
Return values
array<string|int, mixed> —A list of stdClass objects representing each contact
getAllManagers()
Fetches a list of all contacts managing a specific client
public
getAllManagers(int $client_id[, array<string|int, mixed> $order = ['last_name' => 'asc', 'first_name' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $client_id : int
-
The client ID to fetch all users who have been granted access
- $order : array<string|int, mixed> = ['last_name' => 'asc', 'first_name' => 'asc']
-
The sort and order conditions (e.g. array('sort_field'=>"ASC"), optional)
Return values
array<string|int, mixed> —A list of stdClass objects representing each contact
getInvitation()
Fetch an invitation
public
getInvitation(int $invitation_id) : mixed
Parameters
- $invitation_id : int
-
The ID of the invitation to fetch
Return values
mixed —The invitation
getInvitationByToken()
Fetch an invitation by the token
public
getInvitationByToken(string $token) : mixed
Parameters
- $token : string
-
The token of the invitation to fetch
Return values
mixed —The invitation
getInvitations()
Fetches the pending invitations for a given client
public
getInvitations(int $client_id) : mixed
Parameters
- $client_id : int
-
The ID of the client to fetch the pending invitations
Return values
mixed —An array of objects representing the pending invitations
getList()
Fetches a list of all accounts managed by a specific client
public
getList(int $client_id[, int $page = 1 ][, array<string|int, mixed> $order = ['last_name' => 'asc', 'first_name' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $client_id : int
-
The client ID to fetch managed accounts for
- $page : int = 1
-
The page to return results for (optional, default 1)
- $order : array<string|int, mixed> = ['last_name' => 'asc', 'first_name' => 'asc']
-
The sort and order fields (optional, default the last name and first name ascending)
Return values
array<string|int, mixed> —An array of objects
getListCount()
Return the total number of users returned from ManagedAccounts::getList(), useful in constructing pagination for the getList() method.
public
getListCount(int $client_id) : int
Parameters
- $client_id : int
-
The client ID to fetch managed accounts for
Tags
Return values
int —The total number of users
getManager()
Fetches a manager
public
getManager(int $contact_id, int $client_id) : mixed
Parameters
- $contact_id : int
-
The ID of the contact to fetch
- $client_id : int
-
The ID of the client the contact is managing
Return values
mixed —An object containing the manager, false if manager doesn't exist
getManagersList()
Fetches a list of all managers who have been granted access to a specific client
public
getManagersList(int $client_id[, int $page = 1 ][, array<string|int, mixed> $order = ['last_name' => 'asc', 'first_name' => 'asc'] ]) : array<string|int, mixed>
Parameters
- $client_id : int
-
The client ID to fetch users for
- $page : int = 1
-
The page to return results for (optional, default 1)
- $order : array<string|int, mixed> = ['last_name' => 'asc', 'first_name' => 'asc']
-
The sort and order fields (optional, default the last name and first name ascending)
Return values
array<string|int, mixed> —An array of objects
getManagersListCount()
Return the total number of users returned from ManagedAccounts::getManagersList(), useful in constructing pagination for the getManagersList() method.
public
getManagersListCount(int $client_id) : int
Parameters
- $client_id : int
-
The client ID to fetch managers for
Tags
Return values
int —The total number of users
getPermissionOptions()
Returns an array of key/value pairs of all available permission options
public
getPermissionOptions(int $company_id) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company to fetch options under
Return values
array<string|int, mixed> —An array of key/value pairs
getSearchCount()
Return the total number of accounts returned from ManagedAccounts::search(), useful in constructing pagination
public
getSearchCount(int $client_id, string $query) : mixed
Parameters
- $client_id : int
-
The client ID to fetch accounts for
- $query : string
-
The value to search accounts for
Tags
hasPermission()
Checks whether or not the manager has permissions for the given area
public
hasPermission(int $company_id, int $contact_id, string $area, int $client_id) : bool
Parameters
- $company_id : int
-
The ID of the company
- $contact_id : int
-
The ID of the contact
- $area : string
-
The area to check
- $client_id : int
-
The ID of the client being managed by the contact
Return values
bool —True if permission allowed, false otherwise
invite()
Generates and mails a new invitation
public
invite(int $client_id, string $email, array<string|int, mixed> $permissions) : bool
Parameters
- $client_id : int
-
The ID of the client to manage
- $email : string
-
The email address of the contact that will be granted access
- $permissions : array<string|int, mixed>
-
A numerically indexed array of arrays containing:
- area The area
Return values
bool —True if the invitation was sent successfully
manage()
Manage an account
public
manage(int $contact_id, int $client_id) : mixed
Parameters
- $contact_id : int
-
The ID of the contact belonging to the manager
- $client_id : int
-
The ID of the client to manage
revoke()
Revokes the access from a contact to a specific client
public
revoke(int $contact_id, int $client_id) : PDOStatement
Parameters
- $contact_id : int
-
The ID of the contact who have been granted access to a specific client
- $client_id : int
-
the ID of the client
Return values
PDOStatementsearch()
Search accounts
public
search(int $client_id, string $query[, int $page = 1 ]) : array<string|int, mixed>
Parameters
- $client_id : int
-
The client ID to fetch accounts for
- $query : string
-
The value to search accounts for
- $page : int = 1
-
The page number of results to fetch (optional, default 1)
Return values
array<string|int, mixed> —An array of accounts that match the search criteria
send()
Sends the email invitation link
public
send(int $invitation_id) : bool
Parameters
- $invitation_id : int
-
The ID of the email invitation to send
Return values
bool —Returns true if the message was successfully sent, false otherwise
setPermissions()
Sets permissions for the given contact and client
public
setPermissions(int $contact_id, int $client_id, array<string|int, mixed> $vars) : mixed
Parameters
- $contact_id : int
-
The ID of the contact to set permissions for
- $client_id : int
- $vars : array<string|int, mixed>
-
A numerically indexed array of arrays containing:
- area The area
switchBack()
Switches back to the manager account
public
switchBack(int $contact_id, int $client_id) : mixed
Parameters
- $contact_id : int
-
The ID of the contact of the manager to switch back
- $client_id : int
-
The ID of the client currently being managed by the manager
getAccounts()
Partially constructs the query required by both ManagedAccounts::getManagersList() and ManagedAccounts::getManagersListCount()
private
getAccounts(int $client_id) : Record
Parameters
- $client_id : int
-
The client ID to fetch users for
Return values
Record —The partially constructed query Record object
getManagers()
Partially constructs the query required by both ManagedAccounts::getManagersList() and ManagedAccounts::getManagersListCount()
private
getManagers(int $client_id) : Record
Parameters
- $client_id : int
-
The client ID to fetch users for
Return values
Record —The partially constructed query Record object
searchAccounts()
Partially constructs the query for searching accounts
private
searchAccounts(int $client_id, string $query) : Record
Parameters
- $client_id : int
-
The client ID to fetch accounts for
- $query : string
-
The value to search accounts for
Tags
Return values
Record —The partially constructed query Record object