Methods summary
public
array
|
#
behaviors( )
Returns a list of behaviors that this controller should behave as. The return
value should be an array of behavior configurations indexed by behavior names.
Each behavior configuration can be either a string specifying the behavior class
or an array of the following structure:
'behaviorName'=>array(
'class'=>'path.to.BehaviorClass',
'property1'=>'value1',
'property2'=>'value2',
)
Returns a list of behaviors that this controller should behave as. The return
value should be an array of behavior configurations indexed by behavior names.
Each behavior configuration can be either a string specifying the behavior class
or an array of the following structure:
'behaviorName'=>array(
'class'=>'path.to.BehaviorClass',
'property1'=>'value1',
'property2'=>'value2',
)
Note, the behavior classes must implement IBehavior or extend from
CBehavior. Behaviors declared in this method will be attached to the
controller when it is instantiated.
For more details about behaviors, see CComponent.
Returns
array the behavior configurations (behavior name=>behavior configuration)
Overrides
|
public
array
|
#
filters( )
Returns
array action filters
Overrides
|
public
array
|
#
actions( )
Returns a list of external action classes. Array keys are action IDs, and
array values are the corresponding action class in dot syntax (e.g.
'edit'=>'application.controllers.article.EditArticle') or arrays representing
the configuration of the actions, such as the following,
return array(
'action1'=>'path.to.Action1Class',
'action2'=>array(
'class'=>'path.to.Action2Class',
'property1'=>'value1',
'property2'=>'value2',
),
);
Derived classes may override this method to declare external actions.
Returns a list of external action classes. Array keys are action IDs, and
array values are the corresponding action class in dot syntax (e.g.
'edit'=>'application.controllers.article.EditArticle') or arrays representing
the configuration of the actions, such as the following,
return array(
'action1'=>'path.to.Action1Class',
'action2'=>array(
'class'=>'path.to.Action2Class',
'property1'=>'value1',
'property2'=>'value2',
),
);
Derived classes may override this method to declare external actions.
Note, in order to inherit actions defined in the parent class, a child class
needs to merge the parent actions with child actions using functions like
array_merge().
You may import actions from an action provider (such as a widget, see CWidget::actions), like the following:
return array(
...other actions...
// import actions declared in ProviderClass::actions()
// the action IDs will be prefixed with 'pro.'
'pro.'=>'path.to.ProviderClass',
// similar as above except that the imported actions are
// configured with the specified initial property values
'pro2.'=>array(
'class'=>'path.to.ProviderClass',
'action1'=>array(
'property1'=>'value1',
),
'action2'=>array(
'property2'=>'value2',
),
),
)
In the above, we differentiate action providers from other action
declarations by the array keys. For action providers, the array keys must
contain a dot. As a result, an action ID 'pro2.action1' will be resolved as the
'action1' action declared in the 'ProviderClass'.
Returns
array list of external action classes
See
Overrides
|
public
type
|
#
actionCheckPermissions( type $action, type $username = null, type $api = 0 )
Multi-purpose method for checking permissions. If called as an action, it
will return "true" or "false" in plain text (to stay backwards- compatibile with
old API scripts). Otherwise, will return true or false. *
Multi-purpose method for checking permissions. If called as an action, it
will return "true" or "false" in plain text (to stay backwards- compatibile with
old API scripts). Otherwise, will return true or false. *
Parameters
- $action
type $action
- $username
type $username
- $api
type $api
Returns
type
|
public
|
#
actionCreate( )
Creates a new record.
This method allows for the creation of new records via API request. Requests
should be made of the following format:
www.[server].com/index.php/path/to/x2/index.php/api/create/model/[modelType]
With the model's attributes as $_POST data. Furthermore, in the post array a
valid username and API key must be submitted under the indices 'user' and
'userKey' for the request to be authenticated.
|
public
|
#
actionDelete( )
Delete a model record by primary key value.
Delete a model record by primary key value.
|
public
|
|
public
|
#
actionListUsers( )
Get a list of all users in the app.
Get a list of all users in the app.
|
public
|
#
actionLookup( )
Obtain a model using search parameters.
Obtain a model using search parameters.
Finds a record based on its first name, last name, and/or email and responds
with its full attributes as a JSON-encoded string.
URLs to use this function: index.php/api/lookup/[model
name]/[attribute]/[value]/...
'user' and 'userKey' are required.
|
public
|
#
actionRelationship( )
REST-ful API method for adding and removing relationships between
records.
REST-ful API method for adding and removing relationships between
records.
|
public
|
#
actionTags( )
Operations involving tags associated with a model.
Operations involving tags associated with a model.
There needs to be the tagged model's primary key value in the URL's
parameters, in addition to the model's class. If DELETE, or POST, there needs to
be an array of tags, JSON-encoded, in postdata, to delete or add to the
model.
|
public
|
#
actionUpdate( )
Updates a preexisting record.
Updates a preexisting record.
Usage of this function is very similar to ApiController::actionCreate() , although it
requires the "id" parameter that corresponds to the (auto-increment) id field of
the record in the database. Thus, URLs for post requests to this API function
should be formatted as follows:
index.php/api/update/model/[model name]/id/[record id]
The attributes of the model should be submitted in the $_POST array along
with 'user' and 'userKey' just as in create.
|
public
|
#
actionView( )
Obtain a model by its record ID.
Obtain a model by its record ID.
Looks up a model by its record ID and responds with its attributes as a
JSON-encoded string.
URLs to use this function: index.php/view/id/[record id]
Include 'user' and 'userKey' just like in create and update.
|
public
|
#
actionVoip( boolean $actionHist = 0 )
Records a phone call as a notification.
Records a phone call as a notification.
Given a phone number, if a contact matching that phone number exists, a
notification assigned to that contact's assignee will be created. Software-based
telephony systems such as Asterisk can thus immediately notify sales reps of a
phone call by making a cURL request to a url formatted as follows:
api/voip/data/[phone number]
(Note: the phone number itself must not contain anything but digits, i.e. no
periods or dashes.)
For Asterisk, one possible integration method is to insert into the dialplan,
at the appropriate position, a call to a script that uses PHPAGI
to extract the phone number. The script can then make the necessary request to
this action.
Parameters
- $actionHist
boolean $actionHist If set to 1, create an action history item for the contact.
|
public
|
#
checkValidModel( )
Checks the GET parameters for a valid model class.
Checks the GET parameters for a valid model class.
|
public
|
#
filterAuthenticate( CFilterChain $filterChain )
Checks credentials for API access
Checks credentials for API access
Parameters
- $filterChain
CFilterChain $filterChain
|
public
|
#
filterAvailable( type $filterChain )
Sends the appropriate response if X2Engine is locked.
Sends the appropriate response if X2Engine is locked.
Parameters
- $filterChain
type $filterChain
|
public
|
#
filterCheckCRUDPermissions( type $filterChain )
Basic permissions check filter.
Basic permissions check filter.
It is meant to simplify the simpler actions where named after existing
actions (or actions listed among the keys of ApiController::$actionAuthItemMap )
Parameters
- $filterChain
type $filterChain
|
public
|
|
public
|
#
filterValidModel( CFilterChain $filterChain )
Ensures that the "model" parameter is present and valid.
Ensures that the "model" parameter is present and valid.
Parameters
- $filterChain
CFilterChain $filterChain
|
public
|
#
getModel( mixed $new = false )
Model getter; assumes $_GET parameters include the model's primary key, but
$_POST is included for backwards compatibility.
Model getter; assumes $_GET parameters include the model's primary key, but
$_POST is included for backwards compatibility.
|
public
|
#
modelSetUsernameFields( mixed & $model )
A quick and dirty hack for filling in the gaps if the model requested does
not make use of the changelog behavior (which takes care of that
automatically)
A quick and dirty hack for filling in the gaps if the model requested does
not make use of the changelog behavior (which takes care of that
automatically)
|
public
string
|
#
validationMsg( type $action, type $model )
Compose a UI-friendly validation error summary in HTML
Compose a UI-friendly validation error summary in HTML
Parameters
- $action
type $action
- $model
type $model
Returns
string
|
public
|
#
log( mixed $message, mixed $level = 'trace' )
|
protected
|
#
_sendResponse( integer $status = 200, string $body = '', boolean $direct = false )
Respond to a request with a specified status code and body.
Respond to a request with a specified status code and body.
Parameters
- $status
integer $status The HTTP status code.
- $body
string $body The body of the response message, or the object to be JSON-encoded in the
response (if "direct" is used)
- $direct
boolean $direct Whether the body should be JSON-encoded and returned directly instead of
putting it into the standard response object's "model" property or the like.
|
protected
string
|
#
_getStatusCodeMessage( integer $status )
Obtain an appropriate message for a given HTTP response code.
Obtain an appropriate message for a given HTTP response code.
Parameters
Returns
string
|
protected
|
#
_respondBadPk( X2Model $modelSingle, array $params )
Tells the client that the primary key was bad or missing.
Tells the client that the primary key was bad or missing.
Parameters
- $modelSingle
X2Model
$modelSingle
- $params
array $params
|
Methods inherited from CController
__construct(),
accessRules(),
afterAction(),
afterRender(),
beforeRender(),
clearPageStates(),
createAbsoluteUrl(),
createAction(),
createActionFromMap(),
createUrl(),
filterAccessControl(),
filterAjaxOnly(),
filterPostOnly(),
forward(),
getAction(),
getActionParams(),
getCachingStack(),
getClips(),
getId(),
getLayoutFile(),
getModule(),
getPageState(),
getRoute(),
getUniqueId(),
getViewFile(),
getViewPath(),
init(),
invalidActionParams(),
isCachingStackEmpty(),
loadPageStates(),
missingAction(),
processDynamicOutput(),
processOutput(),
recordCachingAction(),
redirect(),
refresh(),
renderClip(),
renderDynamic(),
renderDynamicInternal(),
renderPartial(),
renderText(),
replaceDynamicOutput(),
run(),
runAction(),
runActionWithFilters(),
savePageStates(),
setAction(),
setPageState()
|