Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright Tech To The People (c) 2010 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
c28e1768 | 29 | * This api exposes CiviCRM Survey Respondant. |
6a488035 TO |
30 | * |
31 | * @package CiviCRM_APIv3 | |
32 | * @subpackage API_Survey | |
33 | */ | |
34 | ||
a14e9d08 | 35 | /** |
22242c87 EM |
36 | * Notify caller of deprecated function. |
37 | * | |
a14e9d08 | 38 | * @deprecated api notice |
a6c01b45 | 39 | * @return string |
72b3a70c | 40 | * to indicate this entire api entity is deprecated |
a14e9d08 CW |
41 | */ |
42 | function _civicrm_api3_survey_respondant_deprecation() { | |
43 | return 'The survey_respondant api is not currently supported.'; | |
44 | } | |
45 | ||
6a488035 | 46 | /** |
dc64d047 EM |
47 | * Get the list of signatories. |
48 | * | |
c23f45d3 | 49 | * @deprecated - api currently not supported |
22242c87 | 50 | * |
cf470720 | 51 | * @param array $params |
22242c87 | 52 | * input parameters. |
6a488035 | 53 | * |
a6c01b45 | 54 | * @return array |
6a488035 TO |
55 | */ |
56 | function civicrm_api3_survey_respondant_get(&$params) { | |
57 | ||
58 | civicrm_api3_verify_one_mandatory($params, NULL, array('survey_id', 'id')); | |
59 | ||
60 | if (array_key_exists('survey_id', $params)) { | |
61 | $surveyID = $params['survey_id']; | |
62 | } | |
63 | else { | |
64 | $surveyID = $params['id']; | |
65 | } | |
66 | ||
67 | $interviewerID = NULL; | |
68 | if (array_key_exists('interviewer_id', $params)) { | |
69 | $interviewerID = $params['interviewer_id']; | |
35671d00 | 70 | } |
6a488035 TO |
71 | |
72 | $statusIds = array(); | |
73 | if (array_key_exists('status_id', $params)) { | |
74 | $statusIds = explode(',', $params['status_id']); | |
75 | } | |
76 | ||
77 | $respondants = CRM_Campaign_BAO_Survey::getSurveyActivities($surveyID, $interviewerID, $statusIds); | |
78 | ||
79 | return (civicrm_api3_create_success($respondants, $params)); | |
80 | } | |
81 | ||
11e09c59 | 82 | /** |
dc64d047 EM |
83 | * Count survey respondents. |
84 | * | |
6a488035 | 85 | * @deprecated - api currently not supported |
dc64d047 | 86 | * |
d0997921 | 87 | * @param array $params |
645ee340 | 88 | * @return array |
6a488035 TO |
89 | */ |
90 | function &civicrm_api3_survey_respondant_count($params) { | |
91 | ||
92 | $petition = new CRM_Campaign_BAO_Petition(); | |
93 | if (array_key_exists('groupby', $params) && | |
94 | $params['groupby'] == 'country' | |
95 | ) { | |
96 | $signaturesCount = $petition->getPetitionSignatureTotalbyCountry($params['survey_id']); | |
97 | } | |
98 | else { | |
99 | $signaturesCount = $petition->getPetitionSignatureTotal($params['survey_id']); | |
100 | } | |
101 | return ($signaturesCount); | |
102 | } |