CRM-14043 - cid=0 contribution form giving contribution to logged in user
[civicrm-core.git] / api / v3 / examples / ActivityGetfields.php
index 813cbd49b1f6a189468fc7320cf47a699ab5fbfe..7e493fb8cfe4b03b1e561fc7ef4828f6ae491605 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
+/**
+ * Test Generated example of using activity getfields API
+ * *
  */
 function activity_getfields_example(){
 $params = array(
-  'version' => 3,
   '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(){
@@ -40,9 +48,6 @@ function activity_getfields_expectedresult(){
           'pseudoconstant' => array(
               'optionGroupName' => 'activity_type',
             ),
-          'api.aliases' => array(
-              '0' => 'activity_type',
-            ),
         ),
       'activity_date_time' => array(
           'name' => 'activity_date_time',
@@ -73,9 +78,6 @@ function activity_getfields_expectedresult(){
           'pseudoconstant' => array(
               'optionGroupName' => 'priority',
             ),
-          'api.aliases' => array(
-              '0' => 'priority',
-            ),
         ),
       'parent_id' => array(
           'name' => 'parent_id',
@@ -185,9 +187,6 @@ function activity_getfields_expectedresult(){
               'optionGroupName' => 'activity_status',
             ),
           'uniqueName' => 'activity_status_id',
-          'api.aliases' => array(
-              '0' => 'status',
-            ),
         ),
       'is_test' => array(
           'name' => 'is_test',
@@ -208,9 +207,6 @@ function activity_getfields_expectedresult(){
               'optionGroupName' => 'encounter_medium',
             ),
           'uniqueName' => 'activity_medium_id',
-          'api.aliases' => array(
-              '0' => 'medium',
-            ),
         ),
       'result' => array(
           'name' => 'result',
@@ -274,7 +270,7 @@ function activity_getfields_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }