CRM-14043 - cid=0 contribution form giving contribution to logged in user
[civicrm-core.git] / api / v3 / examples / Activity / GetTargetandAssignee.php
CommitLineData
6a488035 1<?php
fb32de45 2/**
3 * Test Generated example of using activity API
4 * Example demonstrates setting & retrieving the target & source *
6a488035
TO
5 */
6function activity__example(){
feb2a730 7$params = array(
9f1b81e0 8 'source_contact_id' => 1,
6a488035
TO
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,
6a488035 16 'priority_id' => 1,
9f1b81e0 17 'target_contact_id' => 1,
18 'assignee_contact_id' => 1,
6a488035
TO
19);
20
fb32de45 21try{
22 $result = civicrm_api3('activity', '', $params);
23}
24catch (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}
6a488035 31
fb32de45 32return $result;
6a488035
TO
33}
34
fb32de45 35/**
6a488035
TO
36 * Function returns array of result expected from previous function
37 */
38function activity__expectedresult(){
39
feb2a730 40 $expectedResult = array(
6a488035
TO
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 1,
44 'id' => 1,
feb2a730 45 'values' => array(
46 '1' => array(
6a488035 47 'id' => '1',
6a488035
TO
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
fb32de45 75 return $expectedResult;
6a488035
TO
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*/