Merge pull request #4865 from eileenmcnaughton/my-first-factory
[civicrm-core.git] / api / v3 / SurveyRespondant.php
CommitLineData
6a488035 1<?php
6a488035
TO
2
3/*
4 +--------------------------------------------------------------------+
39de6fd5 5 | CiviCRM version 4.6 |
6a488035
TO
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
a14e9d08
CW
36/**
37 * @deprecated api notice
38 * @return string to indicate this entire api entity is deprecated
39 */
40function _civicrm_api3_survey_respondant_deprecation() {
41 return 'The survey_respondant api is not currently supported.';
42}
43
6a488035
TO
44/**
45 * Get the list of signatories
46 *
cf470720
TO
47 * @param array $params
48 * (reference ) input parameters.
6a488035
TO
49 *
50 * @return array (reference ) contribution_id of created or updated record
51 * @static void
52 * @access public
53 * @deprecated - api currently not supported
54 */
55function civicrm_api3_survey_respondant_get(&$params) {
56
57 civicrm_api3_verify_one_mandatory($params, NULL, array('survey_id', 'id'));
58
59 if (array_key_exists('survey_id', $params)) {
60 $surveyID = $params['survey_id'];
61 }
62 else {
63 $surveyID = $params['id'];
64 }
65
66 $interviewerID = NULL;
67 if (array_key_exists('interviewer_id', $params)) {
68 $interviewerID = $params['interviewer_id'];
35671d00 69 }
6a488035
TO
70
71 $statusIds = array();
72 if (array_key_exists('status_id', $params)) {
73 $statusIds = explode(',', $params['status_id']);
74 }
75
76 $respondants = CRM_Campaign_BAO_Survey::getSurveyActivities($surveyID, $interviewerID, $statusIds);
77
78 return (civicrm_api3_create_success($respondants, $params));
79}
80
11e09c59 81/**
6a488035
TO
82 * @deprecated - api currently not supported
83 */
84function &civicrm_api3_survey_respondant_count($params) {
85
86 $petition = new CRM_Campaign_BAO_Petition();
87 if (array_key_exists('groupby', $params) &&
88 $params['groupby'] == 'country'
89 ) {
90 $signaturesCount = $petition->getPetitionSignatureTotalbyCountry($params['survey_id']);
91 }
92 else {
93 $signaturesCount = $petition->getPetitionSignatureTotal($params['survey_id']);
94 }
95 return ($signaturesCount);
96}