Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-07-23-17-12-38
[civicrm-core.git] / api / v3 / SurveyRespondant.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | CiviCRM version 4.3 |
6 +--------------------------------------------------------------------+
7 | Copyright Tech To The People (c) 2010 |
8 +--------------------------------------------------------------------+
9 | This file is a part of CiviCRM. |
10 | |
11 | CiviCRM is free software; you can copy, modify, and distribute it |
12 | under the terms of the GNU Affero General Public License |
13 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | |
15 | CiviCRM is distributed in the hope that it will be useful, but |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. |
19 | |
20 | You should have received a copy of the GNU Affero General Public |
21 | License and the CiviCRM Licensing Exception along |
22 | with this program; if not, contact CiviCRM LLC |
23 | at info[AT]civicrm[DOT]org. If you have questions about the |
24 | GNU Affero General Public License or the licensing of CiviCRM, |
25 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
26 +--------------------------------------------------------------------+
27 */
28
29 /**
30 * File for the CiviCRM APIv3 Survey Respondant functions
31 *
32 * @package CiviCRM_APIv3
33 * @subpackage API_Survey
34 */
35
36 /**
37 * Include utility functions
38 */
39 require_once 'api/v3/utils.php';
40
41 /**
42 * Get the list of signatories
43 *
44 * @param array $params (reference ) input parameters
45 *
46 * @return array (reference ) contribution_id of created or updated record
47 * @static void
48 * @access public
49 * @deprecated - api currently not supported
50 */
51 function civicrm_api3_survey_respondant_get(&$params) {
52
53 civicrm_api3_verify_one_mandatory($params, NULL, array('survey_id', 'id'));
54
55 if (array_key_exists('survey_id', $params)) {
56 $surveyID = $params['survey_id'];
57 }
58 else {
59 $surveyID = $params['id'];
60 }
61
62 $interviewerID = NULL;
63 if (array_key_exists('interviewer_id', $params)) {
64 $interviewerID = $params['interviewer_id'];
65 }
66
67 $statusIds = array();
68 if (array_key_exists('status_id', $params)) {
69 $statusIds = explode(',', $params['status_id']);
70 }
71
72 $respondants = CRM_Campaign_BAO_Survey::getSurveyActivities($surveyID, $interviewerID, $statusIds);
73
74 return (civicrm_api3_create_success($respondants, $params));
75 }
76
77 /**
78 * @deprecated - api currently not supported
79 */
80 function &civicrm_api3_survey_respondant_count($params) {
81
82 $petition = new CRM_Campaign_BAO_Petition();
83 if (array_key_exists('groupby', $params) &&
84 $params['groupby'] == 'country'
85 ) {
86 $signaturesCount = $petition->getPetitionSignatureTotalbyCountry($params['survey_id']);
87 }
88 else {
89 $signaturesCount = $petition->getPetitionSignatureTotal($params['survey_id']);
90 }
91 return ($signaturesCount);
92 }
93