<?php
-
-/*
-
+/**
+ * Test Generated example of using activity getfields API
+ * *
*/
function activity_getfields_example(){
-$params = array(
- 'version' => 3,
+$params = array(
'action' => 'create',
);
- $result = civicrm_api( 'activity','getfields',$params );
+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('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
+}
- return $result;
+return $result;
}
-/*
+/**
* Function returns array of result expected from previous function
*/
function activity_getfields_expectedresult(){
- $expectedResult = array(
+ $expectedResult = array(
'is_error' => 0,
'version' => 3,
- 'count' => 28,
- 'values' => array(
- 'source_record_id' => array(
+ 'count' => 27,
+ 'values' => array(
+ 'source_record_id' => array(
'name' => 'source_record_id',
'type' => 1,
'title' => 'Source Record',
),
- 'activity_type_id' => array(
+ 'activity_type_id' => array(
'name' => 'activity_type_id',
'type' => 1,
'title' => 'Activity Type ID',
'import' => true,
'where' => 'civicrm_activity.activity_type_id',
'headerPattern' => '/(activity.)?type(.id$)/i',
+ 'pseudoconstant' => array(
+ 'optionGroupName' => 'activity_type',
+ ),
),
- 'activity_date_time' => array(
+ 'activity_date_time' => array(
'name' => 'activity_date_time',
'type' => 12,
'title' => 'Activity Date',
'headerPattern' => '/(activity.)?date(.time$)?/i',
'export' => true,
),
- 'phone_id' => array(
+ 'phone_id' => array(
'name' => 'phone_id',
'type' => 1,
'title' => 'Phone (called) ID',
'FKClassName' => 'CRM_Core_DAO_Phone',
),
- 'phone_number' => array(
+ 'phone_number' => array(
'name' => 'phone_number',
'type' => 2,
'title' => 'Phone (called) Number',
'maxlength' => 64,
'size' => 30,
),
- 'priority_id' => array(
+ 'priority_id' => array(
'name' => 'priority_id',
'type' => 1,
'title' => 'Priority',
- 'pseudoconstant' => array(
- 'name' => 'priority',
+ 'pseudoconstant' => array(
'optionGroupName' => 'priority',
),
- 'api.aliases' => array(
- '0' => 'priority',
- ),
- 'options' => array(
- '1' => 'Urgent',
- '2' => 'Normal',
- '3' => 'Low',
- ),
),
- 'parent_id' => array(
+ 'parent_id' => array(
'name' => 'parent_id',
'type' => 1,
'title' => 'Parent Activity Id',
'FKClassName' => 'CRM_Activity_DAO_Activity',
),
- 'is_auto' => array(
+ 'is_auto' => array(
'name' => 'is_auto',
'type' => 16,
'title' => 'Auto',
),
- 'relationship_id' => array(
+ 'relationship_id' => array(
'name' => 'relationship_id',
'type' => 1,
'title' => 'Relationship Id',
'default' => 'UL',
'FKClassName' => 'CRM_Contact_DAO_Relationship',
),
- 'is_current_revision' => array(
+ 'is_current_revision' => array(
'name' => 'is_current_revision',
'type' => 16,
'title' => 'Is this activity a current revision in versioning chain?',
'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
'export' => true,
),
- 'original_id' => array(
+ 'original_id' => array(
'name' => 'original_id',
'type' => 1,
'title' => 'Original Activity ID ',
'FKClassName' => 'CRM_Activity_DAO_Activity',
),
- 'weight' => array(
+ 'weight' => array(
'name' => 'weight',
'type' => 1,
'title' => 'Weight',
),
- 'id' => array(
+ 'id' => array(
'name' => 'id',
'type' => 1,
'title' => 'Activity ID',
'where' => 'civicrm_activity.id',
'export' => true,
'uniqueName' => 'activity_id',
- 'api.aliases' => array(
+ 'api.aliases' => array(
'0' => 'activity_id',
),
),
- 'subject' => array(
+ 'subject' => array(
'name' => 'subject',
'type' => 2,
'title' => 'Subject',
'export' => true,
'uniqueName' => 'activity_subject',
),
- 'duration' => array(
+ 'duration' => array(
'name' => 'duration',
'type' => 1,
'title' => 'Duration',
'export' => true,
'uniqueName' => 'activity_duration',
),
- 'location' => array(
+ 'location' => array(
'name' => 'location',
'type' => 2,
'title' => 'Location',
'export' => true,
'uniqueName' => 'activity_location',
),
- 'details' => array(
+ 'details' => array(
'name' => 'details',
'type' => 32,
'title' => 'Details',
'export' => true,
'uniqueName' => 'activity_details',
),
- 'status_id' => array(
+ 'status_id' => array(
'name' => 'status_id',
'type' => 1,
'title' => 'Activity Status Id',
'import' => true,
'where' => 'civicrm_activity.status_id',
'headerPattern' => '/(activity.)?status(.label$)?/i',
+ 'pseudoconstant' => array(
+ 'optionGroupName' => 'activity_status',
+ ),
'uniqueName' => 'activity_status_id',
),
- 'is_test' => array(
+ 'is_test' => array(
'name' => 'is_test',
'type' => 16,
'title' => 'Test',
'export' => true,
'uniqueName' => 'activity_is_test',
),
- 'medium_id' => array(
+ 'medium_id' => array(
'name' => 'medium_id',
'type' => 1,
'title' => 'Activity Medium',
'default' => 'UL',
+ 'pseudoconstant' => array(
+ 'optionGroupName' => 'encounter_medium',
+ ),
'uniqueName' => 'activity_medium_id',
),
- 'result' => array(
+ 'result' => array(
'name' => 'result',
'type' => 2,
'title' => 'Result',
'size' => 45,
'uniqueName' => 'activity_result',
),
- 'is_deleted' => array(
+ 'is_deleted' => array(
'name' => 'is_deleted',
'type' => 16,
'title' => 'Activity is in the Trash',
'export' => true,
'uniqueName' => 'activity_is_deleted',
),
- 'campaign_id' => array(
+ 'campaign_id' => array(
'name' => 'campaign_id',
'type' => 1,
'title' => 'Campaign ID',
'FKClassName' => 'CRM_Campaign_DAO_Campaign',
'uniqueName' => 'activity_campaign_id',
),
- 'engagement_level' => array(
+ 'engagement_level' => array(
'name' => 'engagement_level',
'type' => 1,
'title' => 'Engagement Index',
'import' => true,
'where' => 'civicrm_activity.engagement_level',
'export' => true,
+ 'pseudoconstant' => array(
+ 'optionGroupName' => 'engagement_index',
+ ),
'uniqueName' => 'activity_engagement_level',
),
- 'source_contact_id' => array(
+ 'source_contact_id' => array(
+ 'name' => 'source_contact_id',
+ 'title' => 'Activity Source Contact',
+ 'type' => 1,
+ 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
'api.default' => 'user_contact_id',
),
- 'assignee_contact_id' => array(
+ 'assignee_contact_id' => array(
'name' => 'assignee_id',
'title' => 'assigned to',
'type' => 1,
- 'FKClassName' => 'CRM_Activity_DAO_ActivityAssignment',
+ 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
),
- 'target_contact_id' => array(
+ 'target_contact_id' => array(
'name' => 'target_id',
'title' => 'Activity Target',
'type' => 1,
- 'FKClassName' => 'CRM_Activity_DAO_ActivityTarget',
- ),
- 'activity_status_id' => array(
- 'name' => 'status_id',
- 'title' => 'Status Id',
- 'type' => 1,
+ 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
),
),
);
- return $expectedResult ;
+ return $expectedResult;
}