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