CRM-14043 - cid=0 contribution form giving contribution to logged in user
[civicrm-core.git] / api / v3 / examples / Activity / GetTargetandAssignee.php
1 <?php
2 /**
3 * Test Generated example of using activity API
4 * Example demonstrates setting & retrieving the target & source *
5 */
6 function activity__example(){
7 $params = array(
8 'source_contact_id' => 1,
9 'subject' => 'Make-it-Happen Meeting',
10 'activity_date_time' => '20110316',
11 'duration' => 120,
12 'location' => 'Pensulvania',
13 'details' => 'a test activity',
14 'status_id' => 1,
15 'activity_type_id' => 1,
16 'priority_id' => 1,
17 'target_contact_id' => 1,
18 'assignee_contact_id' => 1,
19 );
20
21 try{
22 $result = civicrm_api3('activity', '', $params);
23 }
24 catch (CiviCRM_API3_Exception $e) {
25 // handle error here
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
29 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
30 }
31
32 return $result;
33 }
34
35 /**
36 * Function returns array of result expected from previous function
37 */
38 function activity__expectedresult(){
39
40 $expectedResult = array(
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 1,
44 'id' => 1,
45 'values' => array(
46 '1' => array(
47 'id' => '1',
48 'source_record_id' => '',
49 'activity_type_id' => '1',
50 'subject' => 'Make-it-Happen Meeting',
51 'activity_date_time' => '20110316000000',
52 'duration' => '120',
53 'location' => 'Pensulvania',
54 'phone_id' => '',
55 'phone_number' => '',
56 'details' => 'a test activity',
57 'status_id' => '1',
58 'priority_id' => '1',
59 'parent_id' => '',
60 'is_test' => '',
61 'medium_id' => '',
62 'is_auto' => '',
63 'relationship_id' => '',
64 'is_current_revision' => '',
65 'original_id' => '',
66 'result' => '',
67 'is_deleted' => '',
68 'campaign_id' => '',
69 'engagement_level' => '',
70 'weight' => '',
71 ),
72 ),
73 );
74
75 return $expectedResult;
76 }
77
78
79 /*
80 * This example has been generated from the API test suite. The test that created it is called
81 *
82 * testActivityReturnTargetAssignee and can be found in
83 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTest.php
84 *
85 * You can see the outcome of the API tests at
86 * http://tests.dev.civicrm.org/trunk/results-api_v3
87 *
88 * To Learn about the API read
89 * http://book.civicrm.org/developer/current/techniques/api/
90 *
91 * and review the wiki at
92 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
93 *
94 * Read more about testing here
95 * http://wiki.civicrm.org/confluence/display/CRM/Testing
96 *
97 * API Standards documentation:
98 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
99 */