First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.create API.
|
||||
*
|
||||
* Demonstrates create with Contact Reference Custom Field.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'activity_type_id' => 'Test activity type',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'status_id' => 2,
|
||||
'priority_id' => 1,
|
||||
'duration' => 120,
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'custom_2' => '1',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'source_record_id' => '',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '20110602143613',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'phone_id' => '',
|
||||
'phone_number' => '',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'parent_id' => '',
|
||||
'is_test' => '',
|
||||
'medium_id' => '',
|
||||
'is_auto' => '',
|
||||
'relationship_id' => '',
|
||||
'is_current_revision' => '',
|
||||
'original_id' => '',
|
||||
'result' => '',
|
||||
'is_deleted' => '',
|
||||
'campaign_id' => '',
|
||||
'engagement_level' => '',
|
||||
'weight' => '',
|
||||
'is_star' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityCreateCustomContactRefField"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Get with Contact Ref Custom Field
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'return.custom_2' => 1,
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'custom_1' => 'defaultValue',
|
||||
'custom_2_id' => '1',
|
||||
'custom_2' => 'Anderson, Anthony',
|
||||
'source_contact_id' => '1',
|
||||
'custom_1_1' => 'defaultValue',
|
||||
'custom_2_1' => 'Anderson, Anthony',
|
||||
'custom_2_1_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityCreateCustomContactRefField"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
108
sites/all/modules/civicrm/api/v3/examples/Activity/Create.php
Normal file
108
sites/all/modules/civicrm/api/v3/examples/Activity/Create.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.create API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'activity_type_id' => 'Test activity type',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'status_id' => 2,
|
||||
'priority_id' => 1,
|
||||
'duration' => 120,
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'custom_1' => 'custom string',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'source_record_id' => '',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '20110602143613',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'phone_id' => '',
|
||||
'phone_number' => '',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'parent_id' => '',
|
||||
'is_test' => '',
|
||||
'medium_id' => '',
|
||||
'is_auto' => '',
|
||||
'relationship_id' => '',
|
||||
'is_current_revision' => '',
|
||||
'original_id' => '',
|
||||
'result' => '',
|
||||
'is_deleted' => '',
|
||||
'campaign_id' => '',
|
||||
'engagement_level' => '',
|
||||
'weight' => '',
|
||||
'is_star' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityCreateCustomSubType"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Demonstrates _high filter (at time of writing doesn't work if contact_id is set.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'filter.activity_date_time_high' => '20120101000000',
|
||||
'sequential' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '2011-01-01 00:00:00',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '1',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'source_contact_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetFilterMaxDate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Demonstrates _low filter (at time of writing doesn't work if contact_id is set.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'filter.activity_date_time_low' => '20120101000000',
|
||||
'sequential' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 2,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '2',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '2012-02-16 00:00:00',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '1',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'source_contact_id' => '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetFilterMaxDate"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.delete API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_delete_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'delete', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_delete_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'values' => 1,
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testDeleteActivity"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
96
sites/all/modules/civicrm/api/v3/examples/Activity/Get.php
Normal file
96
sites/all/modules/civicrm/api/v3/examples/Activity/Get.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'contact_id' => 1,
|
||||
'activity_type_id' => 9999,
|
||||
'sequential' => 1,
|
||||
'return.custom_1' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'custom_1' => 'custom string',
|
||||
'source_contact_id' => '1',
|
||||
'status' => 'Completed',
|
||||
'activity_name' => 'Test activity type',
|
||||
'custom_1_1' => 'custom string',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityGetContact_idCustom"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
526
sites/all/modules/civicrm/api/v3/examples/Activity/GetFields.php
Normal file
526
sites/all/modules/civicrm/api/v3/examples/Activity/GetFields.php
Normal file
|
@ -0,0 +1,526 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.getfields API.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getfields_example() {
|
||||
$params = array(
|
||||
'action' => 'create',
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'getfields', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getfields_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 29,
|
||||
'values' => array(
|
||||
'source_record_id' => array(
|
||||
'name' => 'source_record_id',
|
||||
'type' => 1,
|
||||
'title' => 'Source Record',
|
||||
'description' => 'Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
),
|
||||
'activity_type_id' => array(
|
||||
'name' => 'activity_type_id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity Type ID',
|
||||
'description' => 'FK to civicrm_option_value.id, that has to be valid, registered activity type.',
|
||||
'required' => TRUE,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.activity_type_id',
|
||||
'headerPattern' => '/(activity.)?type(.id$)/i',
|
||||
'export' => TRUE,
|
||||
'default' => '1',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'activity_type',
|
||||
'optionEditPath' => 'civicrm/admin/options/activity_type',
|
||||
),
|
||||
),
|
||||
'activity_date_time' => array(
|
||||
'name' => 'activity_date_time',
|
||||
'type' => 12,
|
||||
'title' => 'Activity Date',
|
||||
'description' => 'Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.activity_date_time',
|
||||
'headerPattern' => '/(activity.)?date(.time$)?/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select Date',
|
||||
'format' => 'activityDateTime',
|
||||
),
|
||||
),
|
||||
'phone_id' => array(
|
||||
'name' => 'phone_id',
|
||||
'type' => 1,
|
||||
'title' => 'Phone (called) ID',
|
||||
'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Core_DAO_Phone',
|
||||
'html' => array(
|
||||
'type' => 'EntityRef',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'FKApiName' => 'Phone',
|
||||
),
|
||||
'phone_number' => array(
|
||||
'name' => 'phone_number',
|
||||
'type' => 2,
|
||||
'title' => 'Phone (called) Number',
|
||||
'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
|
||||
'maxlength' => 64,
|
||||
'size' => 30,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 64,
|
||||
'size' => 30,
|
||||
),
|
||||
),
|
||||
'priority_id' => array(
|
||||
'name' => 'priority_id',
|
||||
'type' => 1,
|
||||
'title' => 'Priority',
|
||||
'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'priority',
|
||||
'optionEditPath' => 'civicrm/admin/options/priority',
|
||||
),
|
||||
),
|
||||
'parent_id' => array(
|
||||
'name' => 'parent_id',
|
||||
'type' => 1,
|
||||
'title' => 'Parent Activity Id',
|
||||
'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Activity_DAO_Activity',
|
||||
'FKApiName' => 'Activity',
|
||||
),
|
||||
'is_auto' => array(
|
||||
'name' => 'is_auto',
|
||||
'type' => 16,
|
||||
'title' => 'Auto',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
),
|
||||
'relationship_id' => array(
|
||||
'name' => 'relationship_id',
|
||||
'type' => 1,
|
||||
'title' => 'Relationship Id',
|
||||
'description' => 'FK to Relationship ID',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Contact_DAO_Relationship',
|
||||
'FKApiName' => 'Relationship',
|
||||
),
|
||||
'is_current_revision' => array(
|
||||
'name' => 'is_current_revision',
|
||||
'type' => 16,
|
||||
'title' => 'Is this activity a current revision in versioning chain?',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_current_revision',
|
||||
'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
|
||||
'export' => TRUE,
|
||||
'default' => '1',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
),
|
||||
),
|
||||
'original_id' => array(
|
||||
'name' => 'original_id',
|
||||
'type' => 1,
|
||||
'title' => 'Original Activity ID ',
|
||||
'description' => 'Activity ID of the first activity record in versioning chain.',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Activity_DAO_Activity',
|
||||
'FKApiName' => 'Activity',
|
||||
),
|
||||
'weight' => array(
|
||||
'name' => 'weight',
|
||||
'type' => 1,
|
||||
'title' => 'Order',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
),
|
||||
'is_star' => array(
|
||||
'name' => 'is_star',
|
||||
'type' => 16,
|
||||
'title' => 'Is Starred',
|
||||
'description' => 'Activity marked as favorite.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_star',
|
||||
'headerPattern' => '/(activity.)?(star|favorite)/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
),
|
||||
'id' => array(
|
||||
'name' => 'id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity ID',
|
||||
'description' => 'Unique Other Activity ID',
|
||||
'required' => TRUE,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.id',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'uniqueName' => 'activity_id',
|
||||
'api.aliases' => array(
|
||||
'0' => 'activity_id',
|
||||
),
|
||||
),
|
||||
'subject' => array(
|
||||
'name' => 'subject',
|
||||
'type' => 2,
|
||||
'title' => 'Subject',
|
||||
'description' => 'The subject/purpose/short description of the activity.',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.subject',
|
||||
'headerPattern' => '/(activity.)?subject/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
),
|
||||
'uniqueName' => 'activity_subject',
|
||||
),
|
||||
'duration' => array(
|
||||
'name' => 'duration',
|
||||
'type' => 1,
|
||||
'title' => 'Duration',
|
||||
'description' => 'Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.duration',
|
||||
'headerPattern' => '/(activity.)?duration(s)?$/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'uniqueName' => 'activity_duration',
|
||||
),
|
||||
'location' => array(
|
||||
'name' => 'location',
|
||||
'type' => 2,
|
||||
'title' => 'Location',
|
||||
'description' => 'Location of the activity (optional, open text).',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.location',
|
||||
'headerPattern' => '/(activity.)?location$/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
),
|
||||
'uniqueName' => 'activity_location',
|
||||
),
|
||||
'details' => array(
|
||||
'name' => 'details',
|
||||
'type' => 32,
|
||||
'title' => 'Details',
|
||||
'description' => 'Details about the activity (agenda, notes, etc).',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.details',
|
||||
'headerPattern' => '/(activity.)?detail(s)?$/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'RichTextEditor',
|
||||
'rows' => 2,
|
||||
'cols' => 80,
|
||||
),
|
||||
'uniqueName' => 'activity_details',
|
||||
),
|
||||
'status_id' => array(
|
||||
'name' => 'status_id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity Status',
|
||||
'description' => 'ID of the status this activity is currently in. Foreign key to civicrm_option_value.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.status_id',
|
||||
'headerPattern' => '/(activity.)?status(.label$)?/i',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'activity_status',
|
||||
'optionEditPath' => 'civicrm/admin/options/activity_status',
|
||||
),
|
||||
'uniqueName' => 'activity_status_id',
|
||||
'api.aliases' => array(
|
||||
'0' => 'activity_status',
|
||||
),
|
||||
),
|
||||
'is_test' => array(
|
||||
'name' => 'is_test',
|
||||
'type' => 16,
|
||||
'title' => 'Test',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_test',
|
||||
'headerPattern' => '/(is.)?test(.activity)?/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
),
|
||||
'uniqueName' => 'activity_is_test',
|
||||
),
|
||||
'medium_id' => array(
|
||||
'name' => 'medium_id',
|
||||
'type' => 1,
|
||||
'title' => 'Activity Medium',
|
||||
'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
|
||||
'default' => 'NULL',
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'encounter_medium',
|
||||
'optionEditPath' => 'civicrm/admin/options/encounter_medium',
|
||||
),
|
||||
'uniqueName' => 'activity_medium_id',
|
||||
),
|
||||
'result' => array(
|
||||
'name' => 'result',
|
||||
'type' => 2,
|
||||
'title' => 'Result',
|
||||
'description' => 'Currently being used to store result id for survey activity, FK to option value.',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
'maxlength' => 255,
|
||||
'size' => 45,
|
||||
),
|
||||
'uniqueName' => 'activity_result',
|
||||
),
|
||||
'is_deleted' => array(
|
||||
'name' => 'is_deleted',
|
||||
'type' => 16,
|
||||
'title' => 'Activity is in the Trash',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.is_deleted',
|
||||
'headerPattern' => '/(activity.)?(trash|deleted)/i',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Text',
|
||||
),
|
||||
'uniqueName' => 'activity_is_deleted',
|
||||
),
|
||||
'campaign_id' => array(
|
||||
'name' => 'campaign_id',
|
||||
'type' => 1,
|
||||
'title' => 'Campaign',
|
||||
'description' => 'The campaign for which this activity has been triggered.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.campaign_id',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'FKClassName' => 'CRM_Campaign_DAO_Campaign',
|
||||
'html' => array(
|
||||
'type' => 'CheckBox',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'table' => 'civicrm_campaign',
|
||||
'keyColumn' => 'id',
|
||||
'labelColumn' => 'title',
|
||||
),
|
||||
'uniqueName' => 'activity_campaign_id',
|
||||
'FKApiName' => 'Campaign',
|
||||
),
|
||||
'engagement_level' => array(
|
||||
'name' => 'engagement_level',
|
||||
'type' => 1,
|
||||
'title' => 'Engagement Index',
|
||||
'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
|
||||
'import' => TRUE,
|
||||
'where' => 'civicrm_activity.engagement_level',
|
||||
'export' => TRUE,
|
||||
'table_name' => 'civicrm_activity',
|
||||
'entity' => 'Activity',
|
||||
'bao' => 'CRM_Activity_BAO_Activity',
|
||||
'html' => array(
|
||||
'type' => 'Select',
|
||||
'size' => 6,
|
||||
'maxlength' => 14,
|
||||
),
|
||||
'pseudoconstant' => array(
|
||||
'optionGroupName' => 'engagement_index',
|
||||
'optionEditPath' => 'civicrm/admin/options/engagement_index',
|
||||
),
|
||||
'uniqueName' => 'activity_engagement_level',
|
||||
),
|
||||
'source_contact_id' => array(
|
||||
'name' => 'source_contact_id',
|
||||
'title' => 'Activity Source Contact',
|
||||
'description' => 'Person who created this activity. Defaults to current user.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
'api.default' => 'user_contact_id',
|
||||
'FKApiName' => 'Contact',
|
||||
),
|
||||
'assignee_contact_id' => array(
|
||||
'name' => 'assignee_id',
|
||||
'title' => 'Activity Assignee',
|
||||
'description' => 'Contact(s) assigned to this activity.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
'FKApiName' => 'Contact',
|
||||
),
|
||||
'target_contact_id' => array(
|
||||
'name' => 'target_id',
|
||||
'title' => 'Activity Target',
|
||||
'description' => 'Contact(s) participating in this activity.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Contact_DAO_Contact',
|
||||
'FKApiName' => 'Contact',
|
||||
),
|
||||
'case_id' => array(
|
||||
'name' => 'case_id',
|
||||
'title' => 'Case ID',
|
||||
'description' => 'For creating an activity as part of a case.',
|
||||
'type' => 1,
|
||||
'FKClassName' => 'CRM_Case_DAO_Case',
|
||||
'FKApiName' => 'Case',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testGetFields"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.create API.
|
||||
*
|
||||
* Demonstrates setting & retrieving activity target & source.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_example() {
|
||||
$params = array(
|
||||
'source_contact_id' => 1,
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '20110316',
|
||||
'duration' => 120,
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => 1,
|
||||
'activity_type_id' => 1,
|
||||
'priority_id' => 1,
|
||||
'target_contact_id' => 1,
|
||||
'assignee_contact_id' => 1,
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'create', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_create_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'1' => array(
|
||||
'id' => '1',
|
||||
'source_record_id' => '',
|
||||
'activity_type_id' => '1',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'activity_date_time' => '20110316000000',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'phone_id' => '',
|
||||
'phone_number' => '',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '1',
|
||||
'priority_id' => '1',
|
||||
'parent_id' => '',
|
||||
'is_test' => '',
|
||||
'medium_id' => '',
|
||||
'is_auto' => '',
|
||||
'relationship_id' => '',
|
||||
'is_current_revision' => '',
|
||||
'original_id' => '',
|
||||
'result' => '',
|
||||
'is_deleted' => '',
|
||||
'campaign_id' => '',
|
||||
'engagement_level' => '',
|
||||
'weight' => '',
|
||||
'is_star' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityReturnTargetAssignee"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.getsingle API.
|
||||
*
|
||||
* Demonstrates retrieving activity target & source contact names.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getsingle_example() {
|
||||
$params = array(
|
||||
'id' => 1,
|
||||
'return' => array(
|
||||
'0' => 'source_contact_name',
|
||||
'1' => 'target_contact_name',
|
||||
'2' => 'assignee_contact_name',
|
||||
'3' => 'subject',
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'getsingle', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_getsingle_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'id' => '1',
|
||||
'subject' => 'Make-it-Happen Meeting',
|
||||
'source_contact_id' => '6',
|
||||
'source_contact_name' => 'D Bug',
|
||||
'target_contact_id' => array(
|
||||
'1' => '4',
|
||||
),
|
||||
'target_contact_name' => array(
|
||||
'3' => 'A Cat',
|
||||
'4' => 'B Good',
|
||||
),
|
||||
'assignee_contact_id' => array(),
|
||||
'assignee_contact_name' => array(
|
||||
'5' => 'C Shore',
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityReturnTargetAssigneeName"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
/**
|
||||
* Test Generated example demonstrating the Activity.get API.
|
||||
*
|
||||
* Demonstrates getting assignee_contact_id & using it to get the contact.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_example() {
|
||||
$params = array(
|
||||
'activity_id' => 1,
|
||||
'sequential' => 1,
|
||||
'return.assignee_contact_id' => 1,
|
||||
'api.contact.get' => array(
|
||||
'id' => '$value.source_contact_id',
|
||||
),
|
||||
);
|
||||
|
||||
try{
|
||||
$result = civicrm_api3('Activity', 'get', $params);
|
||||
}
|
||||
catch (CiviCRM_API3_Exception $e) {
|
||||
// Handle error here.
|
||||
$errorMessage = $e->getMessage();
|
||||
$errorCode = $e->getErrorCode();
|
||||
$errorData = $e->getExtraParams();
|
||||
return array(
|
||||
'is_error' => 1,
|
||||
'error_message' => $errorMessage,
|
||||
'error_code' => $errorCode,
|
||||
'error_data' => $errorData,
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function returns array of result expected from previous function.
|
||||
*
|
||||
* @return array
|
||||
* API result array
|
||||
*/
|
||||
function activity_get_expectedresult() {
|
||||
|
||||
$expectedResult = array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'id' => '1',
|
||||
'activity_type_id' => '9999',
|
||||
'subject' => 'test activity type id',
|
||||
'activity_date_time' => '2011-06-02 14:36:13',
|
||||
'duration' => '120',
|
||||
'location' => 'Pennsylvania',
|
||||
'details' => 'a test activity',
|
||||
'status_id' => '2',
|
||||
'priority_id' => '1',
|
||||
'is_test' => 0,
|
||||
'is_auto' => 0,
|
||||
'is_current_revision' => '1',
|
||||
'is_deleted' => 0,
|
||||
'is_star' => 0,
|
||||
'assignee_contact_id' => array(
|
||||
'0' => '3',
|
||||
),
|
||||
'source_contact_id' => '1',
|
||||
'api.contact.get' => array(
|
||||
'is_error' => 0,
|
||||
'version' => 3,
|
||||
'count' => 1,
|
||||
'id' => 1,
|
||||
'values' => array(
|
||||
'0' => array(
|
||||
'contact_id' => '1',
|
||||
'contact_type' => 'Individual',
|
||||
'contact_sub_type' => '',
|
||||
'sort_name' => 'Anderson, Anthony',
|
||||
'display_name' => 'Mr. Anthony Anderson II',
|
||||
'do_not_email' => 0,
|
||||
'do_not_phone' => 0,
|
||||
'do_not_mail' => 0,
|
||||
'do_not_sms' => 0,
|
||||
'do_not_trade' => 0,
|
||||
'is_opt_out' => 0,
|
||||
'legal_identifier' => '',
|
||||
'external_identifier' => '',
|
||||
'nick_name' => '',
|
||||
'legal_name' => '',
|
||||
'image_URL' => '',
|
||||
'preferred_communication_method' => '',
|
||||
'preferred_language' => 'en_US',
|
||||
'preferred_mail_format' => 'Both',
|
||||
'first_name' => 'Anthony',
|
||||
'middle_name' => 'J.',
|
||||
'last_name' => 'Anderson',
|
||||
'prefix_id' => '3',
|
||||
'suffix_id' => '3',
|
||||
'formal_title' => '',
|
||||
'communication_style_id' => '',
|
||||
'job_title' => '',
|
||||
'gender_id' => '',
|
||||
'birth_date' => '',
|
||||
'is_deceased' => 0,
|
||||
'deceased_date' => '',
|
||||
'household_name' => '',
|
||||
'organization_name' => '',
|
||||
'sic_code' => '',
|
||||
'contact_is_deleted' => 0,
|
||||
'current_employer' => '',
|
||||
'address_id' => '',
|
||||
'street_address' => '',
|
||||
'supplemental_address_1' => '',
|
||||
'supplemental_address_2' => '',
|
||||
'supplemental_address_3' => '',
|
||||
'city' => '',
|
||||
'postal_code_suffix' => '',
|
||||
'postal_code' => '',
|
||||
'geo_code_1' => '',
|
||||
'geo_code_2' => '',
|
||||
'state_province_id' => '',
|
||||
'country_id' => '',
|
||||
'phone_id' => '',
|
||||
'phone_type_id' => '',
|
||||
'phone' => '',
|
||||
'email_id' => '1',
|
||||
'email' => 'anthony_anderson@civicrm.org',
|
||||
'on_hold' => 0,
|
||||
'im_id' => '',
|
||||
'provider_id' => '',
|
||||
'im' => '',
|
||||
'worldregion_id' => '',
|
||||
'world_region' => '',
|
||||
'languages' => 'English (United States)',
|
||||
'individual_prefix' => 'Mr.',
|
||||
'individual_suffix' => 'II',
|
||||
'communication_style' => '',
|
||||
'gender' => '',
|
||||
'state_province_name' => '',
|
||||
'state_province' => '',
|
||||
'country' => '',
|
||||
'id' => '1',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return $expectedResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* This example has been generated from the API test suite.
|
||||
* The test that created it is called "testActivityGetGoodID1"
|
||||
* and can be found at:
|
||||
* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
|
||||
*
|
||||
* You can see the outcome of the API tests at
|
||||
* https://test.civicrm.org/job/CiviCRM-master-git/
|
||||
*
|
||||
* To Learn about the API read
|
||||
* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
|
||||
*
|
||||
* Browse the api on your own site with the api explorer
|
||||
* http://MYSITE.ORG/path/to/civicrm/api
|
||||
*
|
||||
* Read more about testing here
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/Testing
|
||||
*
|
||||
* API Standards documentation:
|
||||
* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue