| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 5 | |
| 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 | /** |
| 29 | * This api exposes CiviCRM Survey Respondant. |
| 30 | * |
| 31 | * @deprecated - api currently not supported |
| 32 | * |
| 33 | * @package CiviCRM_APIv3 |
| 34 | */ |
| 35 | |
| 36 | /** |
| 37 | * Notify caller of deprecated function. |
| 38 | * |
| 39 | * @deprecated api notice |
| 40 | * @return string |
| 41 | * String output indicates this entire api entity as deprecated |
| 42 | */ |
| 43 | function _civicrm_api3_survey_respondant_deprecation() { |
| 44 | return 'The SurveyRespondant api is not currently supported.'; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Get the list of signatories. |
| 49 | * |
| 50 | * @deprecated - api currently not supported |
| 51 | * |
| 52 | * @param array $params |
| 53 | * input parameters. |
| 54 | * |
| 55 | * @return array |
| 56 | */ |
| 57 | function civicrm_api3_survey_respondant_get($params) { |
| 58 | |
| 59 | civicrm_api3_verify_one_mandatory($params, NULL, ['survey_id', 'id']); |
| 60 | |
| 61 | if (array_key_exists('survey_id', $params)) { |
| 62 | $surveyID = $params['survey_id']; |
| 63 | } |
| 64 | else { |
| 65 | $surveyID = $params['id']; |
| 66 | } |
| 67 | |
| 68 | $interviewerID = NULL; |
| 69 | if (array_key_exists('interviewer_id', $params)) { |
| 70 | $interviewerID = $params['interviewer_id']; |
| 71 | } |
| 72 | |
| 73 | $statusIds = []; |
| 74 | if (array_key_exists('status_id', $params)) { |
| 75 | $statusIds = explode(',', $params['status_id']); |
| 76 | } |
| 77 | |
| 78 | $respondants = CRM_Campaign_BAO_Survey::getSurveyActivities($surveyID, $interviewerID, $statusIds); |
| 79 | |
| 80 | return (civicrm_api3_create_success($respondants, $params, 'SurveyRespondant', 'get')); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Count survey respondents. |
| 85 | * |
| 86 | * @deprecated - api currently not supported |
| 87 | * |
| 88 | * @param array $params |
| 89 | * @return array |
| 90 | */ |
| 91 | function &civicrm_api3_survey_respondant_count($params) { |
| 92 | |
| 93 | $petition = new CRM_Campaign_BAO_Petition(); |
| 94 | if (array_key_exists('groupby', $params) && |
| 95 | $params['groupby'] == 'country' |
| 96 | ) { |
| 97 | $signaturesCount = $petition->getPetitionSignatureTotalbyCountry($params['survey_id']); |
| 98 | } |
| 99 | else { |
| 100 | $signaturesCount = $petition->getPetitionSignatureTotal($params['survey_id']); |
| 101 | } |
| 102 | return ($signaturesCount); |
| 103 | } |