From 35671d0041c0ba33d55e442064c9b074ee57b996 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 6 Jan 2015 13:35:56 -0800 Subject: [PATCH] INFRA-132 - api/ - phpcbf --- api/api.php | 6 +-- api/v3/ActionSchedule.php | 4 +- api/v3/Activity.php | 15 +++---- api/v3/ActivityType.php | 1 - api/v3/Address.php | 1 - api/v3/Attachment.php | 2 +- api/v3/Campaign.php | 1 - api/v3/Case.php | 8 ++-- api/v3/Constant.php | 10 ++--- api/v3/Contact.php | 49 +++++++++++---------- api/v3/ContactType.php | 1 - api/v3/Contribution.php | 20 ++++----- api/v3/ContributionSoft.php | 1 - api/v3/Country.php | 1 - api/v3/CustomField.php | 6 +-- api/v3/Domain.php | 22 +++++----- api/v3/Email.php | 1 - api/v3/Entity.php | 1 - api/v3/EntityTag.php | 3 +- api/v3/Event.php | 4 +- api/v3/Extension.php | 4 +- api/v3/File.php | 2 +- api/v3/MembershipType.php | 3 +- api/v3/MessageTemplate.php | 6 +-- api/v3/Note.php | 1 - api/v3/OptionValue.php | 1 - api/v3/Participant.php | 3 +- api/v3/ParticipantPayment.php | 3 +- api/v3/ParticipantStatusType.php | 1 - api/v3/PaymentProcessor.php | 1 - api/v3/Phone.php | 1 - api/v3/Phone/Get.php | 1 - api/v3/Pledge.php | 1 - api/v3/PledgePayment.php | 7 +-- api/v3/Profile.php | 75 ++++++++++++++++---------------- api/v3/Relationship.php | 2 +- api/v3/RelationshipType.php | 1 - api/v3/ReportTemplate.php | 2 +- api/v3/Setting.php | 35 +++++++-------- api/v3/Survey.php | 1 - api/v3/SurveyRespondant.php | 3 +- api/v3/System.php | 1 - api/v3/SystemLog.php | 9 ++-- api/v3/Tag.php | 1 - api/v3/UFField.php | 1 - api/v3/UFGroup.php | 1 - api/v3/UFJoin.php | 1 - api/v3/UFMatch.php | 1 - api/v3/Website.php | 7 ++- api/v3/WordReplacement.php | 4 +- api/v3/utils.php | 57 ++++++++++++------------ 51 files changed, 176 insertions(+), 218 deletions(-) diff --git a/api/api.php b/api/api.php index 119ce3985e..483069dde8 100644 --- a/api/api.php +++ b/api/api.php @@ -64,8 +64,8 @@ function _civicrm_api3_api_getfields(&$apiRequest) { // the main param getfields takes is 'action' - however this param is not compatible with REST // so we accept 'api_action' as an alias of action on getfields if (!empty($apiRequest['params']['api_action'])) { - // $apiRequest['params']['action'] = $apiRequest['params']['api_action']; - // unset($apiRequest['params']['api_action']); + // $apiRequest['params']['action'] = $apiRequest['params']['api_action']; + // unset($apiRequest['params']['api_action']); } return array('action' => array('api.aliases' => array('api_action'))); } @@ -116,7 +116,6 @@ function _civicrm_api_get_camel_name($entity) { */ function _civicrm_api_replace_variables($entity, $action, &$params, &$parentResult, $separator = '.') { - foreach ($params as $field => $value) { if (is_string($value) && substr($value, 0, 6) == '$value') { @@ -183,4 +182,3 @@ function _civicrm_api_get_entity_name_from_dao($bao){ $daoName = str_replace("BAO", "DAO", get_class($bao)); return _civicrm_api_get_entity_name_from_camel(CRM_Core_DAO_AllCoreTables::getBriefName($daoName)); } - diff --git a/api/v3/ActionSchedule.php b/api/v3/ActionSchedule.php index 4fb71d2224..bc01516cba 100644 --- a/api/v3/ActionSchedule.php +++ b/api/v3/ActionSchedule.php @@ -73,7 +73,7 @@ function civicrm_api3_action_schedule_create($params) { function _civicrm_api3_action_schedule_create_spec(&$params) { $params['title']['api.required'] = TRUE; $params['mapping_id']['api.required'] = TRUE; -// $params['entity_status']['api.required'] = TRUE; + // $params['entity_status']['api.required'] = TRUE; $params['entity_value']['api.required'] = TRUE; } @@ -91,5 +91,3 @@ function _civicrm_api3_action_schedule_create_spec(&$params) { function civicrm_api3_action_schedule_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - - diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 5c72c36c36..5da510e8f9 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -76,7 +76,6 @@ function civicrm_api3_activity_create($params) { return $errors; } - // processing for custom data $values = $activityArray = array(); _civicrm_api3_custom_format_params($params, $values, 'Activity'); @@ -236,7 +235,7 @@ function civicrm_api3_activity_get($params) { else { $activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE); } - $options = _civicrm_api3_get_options_from_params($params, FALSE,'activity','get'); + $options = _civicrm_api3_get_options_from_params($params, FALSE, 'activity', 'get'); if($options['is_count']) { return civicrm_api3_create_success($activities, $params, 'activity', 'get'); } @@ -278,16 +277,19 @@ function _civicrm_api3_activity_get_formatResult($params, $activities) { $activities[$key]['assignee_contact_id'] = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($activityArray['id']); } break; + case 'target_contact_id': foreach ($activities as $key => $activityArray) { $activities[$key]['target_contact_id'] = CRM_Activity_BAO_ActivityTarget::retrieveTargetIdsByActivityId($activityArray['id']); } break; + case 'source_contact_id': foreach ($activities as $key => $activityArray) { $activities[$key]['source_contact_id'] = CRM_Activity_BAO_Activity::getSourceContactID($activityArray['id']); } break; + default: if (substr($n, 0, 6) == 'custom') { $returnProperties[$n] = $v; @@ -369,7 +371,6 @@ function _civicrm_api3_activity_check_params(&$params) { } } - $sql = ' SELECT count(*) FROM civicrm_contact @@ -379,8 +380,8 @@ SELECT count(*) } } - - $activityIds = array('activity' => CRM_Utils_Array::value('id', $params), + $activityIds = array( + 'activity' => CRM_Utils_Array::value('id', $params), 'parent' => CRM_Utils_Array::value('parent_id', $params), 'original' => CRM_Utils_Array::value('original_id', $params), ); @@ -409,7 +410,7 @@ SELECT count(*) $activityTypeIdInList = array_search(($activityName ? $activityName : $activityLabel), $activityTypes); if (!$activityTypeIdInList) { - $errorString = $activityName ? "Invalid Activity Name : $activityName" : "Invalid Activity Type Label"; + $errorString = $activityName ? "Invalid Activity Name : $activityName" : "Invalid Activity Type Label"; throw new Exception($errorString); } elseif ($activityTypeId && ($activityTypeId != $activityTypeIdInList)) { @@ -430,7 +431,6 @@ SELECT count(*) throw new API_Exception('Invalid Activity Duration (in minutes)'); } - //if adding a new activity & date_time not set make it now // this should be managed by the wrapper layer & setting ['api.default'] in speces // needs testing @@ -490,4 +490,3 @@ function _civicrm_api3_activity_getlist_output($result, $request) { } return $output; } - diff --git a/api/v3/ActivityType.php b/api/v3/ActivityType.php index 70ae8fcce3..e7aa9f873e 100644 --- a/api/v3/ActivityType.php +++ b/api/v3/ActivityType.php @@ -118,4 +118,3 @@ function _civicrm_api3_activity_type_create_spec(&$params) { function civicrm_api3_activity_type_delete($params) { return civicrm_api3_create_success(CRM_Core_BAO_OptionValue::del($params['id']), $params); } - diff --git a/api/v3/Address.php b/api/v3/Address.php index 69ce06da13..69aef9e8fb 100644 --- a/api/v3/Address.php +++ b/api/v3/Address.php @@ -155,4 +155,3 @@ function civicrm_api3_address_delete($params) { function civicrm_api3_address_get(&$params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Address'); } - diff --git a/api/v3/Attachment.php b/api/v3/Attachment.php index 53bac35603..2755a23cd8 100644 --- a/api/v3/Attachment.php +++ b/api/v3/Attachment.php @@ -210,7 +210,7 @@ function civicrm_api3_attachment_delete($params) { $filePaths = array(); $fileIds = array(); while ($dao->fetch()) { - $filePaths [] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri; + $filePaths[] = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $dao->uri; $fileIds[] = $dao->id; } diff --git a/api/v3/Campaign.php b/api/v3/Campaign.php index e1eec08156..d1585dfa51 100644 --- a/api/v3/Campaign.php +++ b/api/v3/Campaign.php @@ -98,4 +98,3 @@ function civicrm_api3_campaign_get($params) { function civicrm_api3_campaign_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/Case.php b/api/v3/Case.php index 96d0e70f42..f1ca95f259 100644 --- a/api/v3/Case.php +++ b/api/v3/Case.php @@ -258,13 +258,13 @@ SELECT DISTINCT case_id $options['return'] = array('contacts' => 1, 'activities' => 1); } - $foundcases = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Case'); + $foundcases = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Case'); $cases = array(); foreach ($foundcases['values'] as $foundcase) { - if ($case = _civicrm_api3_case_read($foundcase['id'], $options)) { - $cases[$foundcase['id']] = $case; - } + if ($case = _civicrm_api3_case_read($foundcase['id'], $options)) { + $cases[$foundcase['id']] = $case; } + } return civicrm_api3_create_success($cases, $params, 'case', 'get'); } diff --git a/api/v3/Constant.php b/api/v3/Constant.php index 7a7df3cad9..d49e767b51 100644 --- a/api/v3/Constant.php +++ b/api/v3/Constant.php @@ -48,7 +48,7 @@ function _civicrm_api3_constant_deprecation() { * @deprecated as of CiviCRM 4.4. * It's recommended to use the api getoptions action instead * - * @param string Name of a public static method of + * @param string Name of a public static method of * CRM_Core_PseudoConstant: one of * * @return array - * @example ConstantGet.php + * @example ConstantGet.php * {@getfields constant_get} */ function civicrm_api3_constant_get($params) { @@ -103,7 +103,6 @@ function civicrm_api3_constant_get($params) { //ie $values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name); // once tests are 100% can try removing the first block & a similar block from Generic:getoptions - // Whitelist approach is safer $allowedClasses = array( 'CRM_Core_PseudoConstant', @@ -183,8 +182,8 @@ function _civicrm_api3_constant_get_spec(&$params) { 'worldRegion', 'wysiwygEditor', ); - $params = (array - ('name' => array( + $params = (array( + 'name' => array( 'title' => 'Constant Name', 'name' => 'name', 'api.required' => 1, @@ -192,4 +191,3 @@ function _civicrm_api3_constant_get_spec(&$params) { )) ); } - diff --git a/api/v3/Contact.php b/api/v3/Contact.php index e3dbcd3ca3..cf70975aca 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -69,7 +69,8 @@ function civicrm_api3_contact_create($params) { if (($email = CRM_Utils_Array::value('email', $params)) && !is_array($params['email'])) { $defLocType = CRM_Core_BAO_LocationType::getDefault(); $params['email'] = array( - 1 => array('email' => $email, + 1 => array( + 'email' => $email, 'is_primary' => 1, 'location_type_id' => ($defLocType->id) ? $defLocType->id : 1, ), @@ -79,7 +80,9 @@ function civicrm_api3_contact_create($params) { if (!empty($params['home_url'])) { $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); - $params['website'] = array(1 => array('website_type_id' => key($websiteTypes), + $params['website'] = array( + 1 => array( + 'website_type_id' => key($websiteTypes), 'url' => $params['home_url'], ), ); @@ -164,7 +167,7 @@ function civicrm_api3_contact_get($params) { function civicrm_api3_contact_getcount($params) { $options = array(); _civicrm_api3_contact_get_supportanomalies($params, $options); - $count = _civicrm_api3_get_using_query_object('contact', $params, $options,1); + $count = _civicrm_api3_get_using_query_object('contact', $params, $options, 1); return (int) $count; } @@ -212,7 +215,7 @@ function _civicrm_api3_contact_get_spec(&$params) { $params['tag']['title'] = 'Assigned tags (filter, array)'; $params['birth_date_low'] = array('name' => 'birth_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birth Date is equal to or greater than')); $params['birth_date_high'] = array('name' => 'birth_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Birth Date is equal to or less than')); - $params['deceased_date_low'] = array('name' => 'deceased_date_low','type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or greater than')); + $params['deceased_date_low'] = array('name' => 'deceased_date_low', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or greater than')); $params['deceased_date_high'] = array('name' => 'deceased_date_high', 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Deceased Date is equal to or less than')); } @@ -251,7 +254,8 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) { if (is_array($params['filter.group_id'])) { $groups = $params['filter.group_id']; } - else $groups = explode(',', $params['filter.group_id']); + else { $groups = explode(',', $params['filter.group_id']); + } unset($params['filter.group_id']); $groups = array_flip($groups); $groups[key($groups)] = 1; @@ -308,25 +312,27 @@ function civicrm_api3_contact_delete($params) { * @throws API_Exception * @throws CiviCRM_API3_Exception */ -function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeErrorArray = false, $obsoletevalue = true, $dedupeRuleGroupID = null ) +function _civicrm_api3_contact_check_params(&$params, $dupeCheck = TRUE, $dupeErrorArray = FALSE, $obsoletevalue = TRUE, $dedupeRuleGroupID = NULL) { switch (strtolower(CRM_Utils_Array::value('contact_type', $params))) { case 'household': - civicrm_api3_verify_mandatory($params, null, array('household_name')); + civicrm_api3_verify_mandatory($params, NULL, array('household_name')); break; + case 'organization': - civicrm_api3_verify_mandatory($params, null, array('organization_name')); + civicrm_api3_verify_mandatory($params, NULL, array('organization_name')); break; + case 'individual': - civicrm_api3_verify_one_mandatory($params, null, array( + civicrm_api3_verify_one_mandatory($params, NULL, array( 'first_name', 'last_name', 'email', 'display_name', ) - ); - break; + ); + break; } // Fixme: This really needs to be handled at a lower level. @See CRM-13123 @@ -335,10 +341,10 @@ function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeE } if (!empty($params['contact_sub_type']) && !empty($params['contact_type'])) { - if (!(CRM_Contact_BAO_ContactType::isExtendsContactType($params['contact_sub_type'], $params['contact_type']))) { - throw new API_Exception("Invalid or Mismatched Contact Subtype: " . implode(', ', (array)$params['contact_sub_type'])); - } + if (!(CRM_Contact_BAO_ContactType::isExtendsContactType($params['contact_sub_type'], $params['contact_type']))) { + throw new API_Exception("Invalid or Mismatched Contact Subtype: " . implode(', ', (array) $params['contact_sub_type'])); } + } if ($dupeCheck) { // check for record already existing @@ -354,8 +360,8 @@ function _civicrm_api3_contact_check_params( &$params, $dupeCheck = true, $dupeE $ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $params['contact_type'], 'Unsupervised', array()); - if (count($ids) >0) { - throw new API_Exception("Found matching contacts: ". implode(',',$ids),"duplicate",array("ids"=>$ids)); + if (count($ids) > 0) { + throw new API_Exception("Found matching contacts: ". implode(',', $ids), "duplicate", array("ids" => $ids)); } } @@ -510,13 +516,11 @@ function _civicrm_api3_greeting_format_params($params) { $greetingId = CRM_Utils_Array::key('Customized', $greetings); } - $customValue = isset($params['contact_id']) ? - CRM_Core_DAO::getFieldValue( + $customValue = isset($params['contact_id']) ? CRM_Core_DAO::getFieldValue( 'CRM_Contact_DAO_Contact', $params['contact_id'], "{$key}{$greeting}_custom" - ) : - FALSE; + ) : FALSE; if (array_key_exists("{$key}{$greeting}_id", $params) && empty($params["{$key}{$greeting}_id"])) { $nullValue = TRUE; @@ -810,7 +814,7 @@ LIMIT 0, {$limit} while ($dao->fetch()) { $t = array('id' => $dao->id); foreach ($as as $k) { - $t[$k] = isset($dao->$k)? $dao->$k: ''; + $t[$k] = isset($dao->$k) ? $dao->$k : ''; } $t['data'] = $dao->data; $contactList[] = $t; @@ -877,7 +881,8 @@ function civicrm_api3_contact_merge($params) { $mode = CRM_Utils_Array::value('mode', $params, 'safe'); $autoFlip = CRM_Utils_Array::value('auto_flip', $params, TRUE); - $dupePairs = array(array('srcID' => CRM_Utils_Array::value('main_id', $params), + $dupePairs = array(array( + 'srcID' => CRM_Utils_Array::value('main_id', $params), 'dstID' => CRM_Utils_Array::value('other_id', $params), )); $result = CRM_Dedupe_Merger::merge($dupePairs, array(), $mode, $autoFlip); diff --git a/api/v3/ContactType.php b/api/v3/ContactType.php index f3357af3d2..1d161a6c10 100644 --- a/api/v3/ContactType.php +++ b/api/v3/ContactType.php @@ -98,4 +98,3 @@ function civicrm_api3_contact_type_get($params) { function civicrm_api3_contact_type_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 6385630dd8..03bea847ce 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -147,11 +147,11 @@ function _civicrm_api3_contribution_create_spec(&$params) { } /** -* Support for schema changes made in 4.5 -* The main purpose of the API is to provide integrators a level of stability not provided by -* the core code or schema - this means we have to provide support for api calls (where possible) -* across schema changes. -*/ + * Support for schema changes made in 4.5 + * The main purpose of the API is to provide integrators a level of stability not provided by + * the core code or schema - this means we have to provide support for api calls (where possible) + * across schema changes. + */ function _civicrm_api3_contribution_create_legacy_support_45(&$params){ //legacy soft credit handling - recommended approach is chaining if(!empty($params['soft_credit_to'])){ @@ -222,7 +222,7 @@ function civicrm_api3_contribution_get($params) { while ($dao->fetch()) { //CRM-8662 $contribution_details = $query->store($dao); - $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id , TRUE); + $softContribution = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dao->contribution_id, TRUE); $contribution[$dao->contribution_id] = array_merge($contribution_details, $softContribution); if(isset($contribution[$dao->contribution_id]['financial_type_id'])){ $contribution[$dao->contribution_id]['financial_type_id'] = $contribution[$dao->contribution_id]['financial_type_id']; @@ -278,7 +278,7 @@ function _civicrm_api3_contribution_get_spec(&$params) { * @access public */ function _civicrm_api3_contribute_format_params($params, &$values, $create = FALSE) { -//legacy way of formatting from v2 api - v3 way is to define metadata & do it in the api layer + //legacy way of formatting from v2 api - v3 way is to define metadata & do it in the api layer _civicrm_api3_filter_fields_for_bao('Contribution', $params, $values); return array(); } @@ -365,7 +365,7 @@ function civicrm_api3_contribution_sendconfirmation($params) { $contribution->id = $params['id']; if (! $contribution->find(TRUE)) { throw new Exception('Contribution does not exist'); -} + } $input = $ids = $cvalues = array('receipt_from_email' => $params['receipt_from_email']); $contribution->loadRelatedObjects($input, $ids, FALSE, TRUE); $contribution->composeMessageArray($input, $ids, $cvalues, FALSE, FALSE); @@ -384,7 +384,7 @@ function _civicrm_api3_contribution_sendconfirmation_spec(&$params) { 'title' => 'Contribution ID' ); $params['receipt_from_email'] = array( - 'api.required' =>1, + 'api.required' => 1, 'title' => 'From Email address (string) required until someone provides a patch :-)', ); $params['receipt_from_name'] = array( @@ -437,7 +437,7 @@ function civicrm_api3_contribution_completetransaction(&$params) { $objects['contribution'] = &$contribution; $input['component'] = $contribution->_component; $input['is_test'] = $contribution->is_test; - $input['trxn_id']= !empty($params['trxn_id']) ? $params['trxn_id'] : $contribution->trxn_id; + $input['trxn_id'] = !empty($params['trxn_id']) ? $params['trxn_id'] : $contribution->trxn_id; $input['amount'] = $contribution->total_amount; if(isset($params['is_email_receipt'])){ $input['is_email_receipt'] = $params['is_email_receipt']; diff --git a/api/v3/ContributionSoft.php b/api/v3/ContributionSoft.php index e757492b1b..112615e1f0 100644 --- a/api/v3/ContributionSoft.php +++ b/api/v3/ContributionSoft.php @@ -102,4 +102,3 @@ function civicrm_api3_contribution_soft_delete($params) { function civicrm_api3_contribution_soft_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/Country.php b/api/v3/Country.php index 38242c6855..f7577e0695 100644 --- a/api/v3/Country.php +++ b/api/v3/Country.php @@ -99,4 +99,3 @@ function civicrm_api3_country_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_DAO(__FUNCTION__), $params); } - diff --git a/api/v3/CustomField.php b/api/v3/CustomField.php index 0672cfde62..2b7578444f 100644 --- a/api/v3/CustomField.php +++ b/api/v3/CustomField.php @@ -137,7 +137,7 @@ function civicrm_api3_custom_field_delete($params) { * * @param array $params * Array to search on. - *{* + * {* * * @return array @getfields CustomField_get} @@ -166,8 +166,8 @@ function civicrm_api3_custom_field_get($params) { * removing as it might be useful in wrapper layer */ function _civicrm_api3_custom_field_validate_field($fieldName, $value, $fieldDetails, &$errors = array()) { - return; - //see comment block + return; + //see comment block if (!$value) { return $errors; } diff --git a/api/v3/Domain.php b/api/v3/Domain.php index a7ef5b0c4f..eddb04cb55 100644 --- a/api/v3/Domain.php +++ b/api/v3/Domain.php @@ -56,8 +56,8 @@ function civicrm_api3_domain_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - _civicrm_api3_dao_set_filter($bao, $params, true, 'domain'); - $domains = _civicrm_api3_dao_to_array($bao, $params, true,'domain'); + _civicrm_api3_dao_set_filter($bao, $params, TRUE, 'domain'); + $domains = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'domain'); foreach ($domains as $domain) { if(!empty($domain['contact_id'])){ @@ -85,21 +85,21 @@ function civicrm_api3_domain_get($params) { 'phone_type_id', $values['location']['phone'][1] ) - ), + ), 'phone' => CRM_Utils_Array::value( 'phone', $values['location']['phone'][1] ) - ); - } + ); + } - if ( !empty( $values['location']['address'] ) ) { - foreach ($address_array as $value) { - $domain['domain_address'][$value] = CRM_Utils_Array::value($value, + if ( !empty( $values['location']['address'] ) ) { + foreach ($address_array as $value) { + $domain['domain_address'][$value] = CRM_Utils_Array::value($value, $values['location']['address'][1] - ); + ); + } } - } list($domain['from_name'], $domain['from_email'] @@ -108,7 +108,6 @@ function civicrm_api3_domain_get($params) { } } - return civicrm_api3_create_success($domains, $params, 'domain', 'get', $bao); } @@ -150,4 +149,3 @@ function _civicrm_api3_domain_create_spec(&$params) { unset($params['version']); $params['name']['api.required'] = 1; } - diff --git a/api/v3/Email.php b/api/v3/Email.php index 767f4b6623..f2770457d8 100644 --- a/api/v3/Email.php +++ b/api/v3/Email.php @@ -101,4 +101,3 @@ function civicrm_api3_email_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/Entity.php b/api/v3/Entity.php index 204dd3ae01..dc48dbfd85 100644 --- a/api/v3/Entity.php +++ b/api/v3/Entity.php @@ -39,4 +39,3 @@ function civicrm_api3_entity_getfields($params) { // without putting an exception in for entity return civicrm_api3_create_success(array()); } - diff --git a/api/v3/EntityTag.php b/api/v3/EntityTag.php index b5b2f4d1f1..586b87fa80 100644 --- a/api/v3/EntityTag.php +++ b/api/v3/EntityTag.php @@ -89,7 +89,7 @@ function civicrm_api3_entity_tag_create($params) { } /** - *{@getfields EntityTag_delete} + * {@getfields EntityTag_delete} * @example EntityTagGet.php * * @param array $params @@ -163,4 +163,3 @@ function _civicrm_api3_entity_tag_common($params, $op = 'add') { } return $values; } - diff --git a/api/v3/Event.php b/api/v3/Event.php index c2ebc3529c..c08d30c0b1 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -177,7 +177,7 @@ function _civicrm_api3_event_get_spec(&$params) { */ function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id){ if(!empty($event[$event_id]['payment_processor'])){ - $processors = explode(CRM_Core_DAO::VALUE_SEPARATOR,$event[$event_id]['payment_processor']); + $processors = explode(CRM_Core_DAO::VALUE_SEPARATOR, $event[$event_id]['payment_processor']); if(count($processors) == 3 ){ $event[$event_id]['payment_processor_id'] = $processors[1]; } @@ -189,7 +189,7 @@ function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id){ * * This API is used for deleting a event * - * @param Array $params + * @param array $paramsArray containing event_id to be deleted. * Array containing event_id to be deleted. * * @return boolean true if success, error otherwise diff --git a/api/v3/Extension.php b/api/v3/Extension.php index 99795196bf..c1fa873952 100644 --- a/api/v3/Extension.php +++ b/api/v3/Extension.php @@ -281,8 +281,8 @@ function civicrm_api3_extension_get($params) { //try { // $info = (array) $mapper->keyToInfo($key); //} catch (CRM_Extension_Exception $e) { - $info = array(); - $info['key'] = $key; + $info = array(); + $info['key'] = $key; //} $info['status'] = $status; $result[] = $info; diff --git a/api/v3/File.php b/api/v3/File.php index 8db55ecdd4..d77fb756d5 100644 --- a/api/v3/File.php +++ b/api/v3/File.php @@ -99,7 +99,7 @@ function civicrm_api3_file_get($params) { * This api is used for updating an existing file. * Required parameters : id of a file * - * @param Array $params + * @param array $paramsAn array of name/value property values of civicrm_file. * An array of name/value property values of civicrm_file. * * @return array of updated file object property values diff --git a/api/v3/MembershipType.php b/api/v3/MembershipType.php index 0bb4d62d8a..91dae25620 100644 --- a/api/v3/MembershipType.php +++ b/api/v3/MembershipType.php @@ -72,7 +72,7 @@ function _civicrm_api3_membership_type_create_spec(&$params) { // todo could set default here probably $params['domain_id']['api.required'] = 1; $params['member_of_contact_id']['api.required'] = 1; - $params['financial_type_id']['api.required'] =1; + $params['financial_type_id']['api.required'] = 1; $params['name']['api.required'] = 1; $params['duration_unit']['api.required'] = 1; $params['duration_interval']['api.required'] = 1; @@ -109,4 +109,3 @@ function civicrm_api3_membership_type_get($params) { function civicrm_api3_membership_type_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/MessageTemplate.php b/api/v3/MessageTemplate.php index 463c7fb7dd..ed1716b219 100644 --- a/api/v3/MessageTemplate.php +++ b/api/v3/MessageTemplate.php @@ -48,11 +48,11 @@ function civicrm_api3_message_template_create($params) { */ function _civicrm_api3_message_template_create_spec(&$params) { $params['msg_title']['api.required'] = 1; - $params['is_active']['api.default'] = true; -/* $params['entity_id']['api.required'] = 1; + $params['is_active']['api.default'] = TRUE; + /* $params['entity_id']['api.required'] = 1; $params['entity_table']['api.default'] = "civicrm_contribution_recur"; $params['type']['api.default'] = "R"; -*/ + */ } /** diff --git a/api/v3/Note.php b/api/v3/Note.php index 30b684ccc6..a9b7cbc773 100644 --- a/api/v3/Note.php +++ b/api/v3/Note.php @@ -145,4 +145,3 @@ function &civicrm_api3_note_tree_get($params) { $noteTree = CRM_Core_BAO_Note::getNoteTree($params['id'], $params['max_depth'], $params['snippet']); return civicrm_api3_create_success($noteTree, $params); } - diff --git a/api/v3/OptionValue.php b/api/v3/OptionValue.php index 6e2eb8e1b9..4217ea1a76 100644 --- a/api/v3/OptionValue.php +++ b/api/v3/OptionValue.php @@ -92,4 +92,3 @@ function civicrm_api3_option_value_delete($params) { civicrm_api3_create_error('Could not delete OptionValue ' . $params['id']); } } - diff --git a/api/v3/Participant.php b/api/v3/Participant.php index 4f289460fc..3ad986fc68 100644 --- a/api/v3/Participant.php +++ b/api/v3/Participant.php @@ -128,7 +128,7 @@ function _civicrm_api3_participant_createlineitem(&$params, $participant){ 'qty' => $qty, 'participant_count' => 0, 'unit_price' => $dao->amount, - 'line_total' => $qty*$dao->amount, + 'line_total' => $qty * $dao->amount, 'version' => 3, ); civicrm_api('line_item', 'create', $lineItemparams); @@ -219,4 +219,3 @@ function civicrm_api3_participant_delete($params) { throw new Exception('Error while deleting participant'); } } - diff --git a/api/v3/ParticipantPayment.php b/api/v3/ParticipantPayment.php index d9f5cfda01..10bff1399a 100644 --- a/api/v3/ParticipantPayment.php +++ b/api/v3/ParticipantPayment.php @@ -107,11 +107,10 @@ function civicrm_api3_participant_payment_delete($params) { * Input parameters. * * @return array array of properties, if error an array with an error id and error message - * @example ParticipantPaymentGet + * @example ParticipantPaymentGet * {@getfields ParticipantPayment_get} * @access public */ function civicrm_api3_participant_payment_get($params) { return _civicrm_api3_basic_get('CRM_Event_DAO_ParticipantPayment', $params); } - diff --git a/api/v3/ParticipantStatusType.php b/api/v3/ParticipantStatusType.php index 0ca2c5430e..4b2edc72b8 100644 --- a/api/v3/ParticipantStatusType.php +++ b/api/v3/ParticipantStatusType.php @@ -93,4 +93,3 @@ function civicrm_api3_participant_status_type_delete($params) { return civicrm_api3_create_error(TRUE); } - diff --git a/api/v3/PaymentProcessor.php b/api/v3/PaymentProcessor.php index 17513278ec..36b5b6ec9c 100644 --- a/api/v3/PaymentProcessor.php +++ b/api/v3/PaymentProcessor.php @@ -89,4 +89,3 @@ function civicrm_api3_payment_processor_delete($params) { function civicrm_api3_payment_processor_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/Phone.php b/api/v3/Phone.php index b09f29292f..46407c48ad 100644 --- a/api/v3/Phone.php +++ b/api/v3/Phone.php @@ -86,4 +86,3 @@ function civicrm_api3_phone_delete($params) { * Could have been implemented here in this file too, but we moved it to illustrate the feature with a real usage. * */ - diff --git a/api/v3/Phone/Get.php b/api/v3/Phone/Get.php index 93a7845f85..f5d4af72a7 100644 --- a/api/v3/Phone/Get.php +++ b/api/v3/Phone/Get.php @@ -18,4 +18,3 @@ function civicrm_api3_phone_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/Pledge.php b/api/v3/Pledge.php index 2ab36addc5..1bebdf83e0 100644 --- a/api/v3/Pledge.php +++ b/api/v3/Pledge.php @@ -199,4 +199,3 @@ function _civicrm_api3_pledge_format_params(&$values, $create = FALSE) { $values['scheduled_date'] = $values['start_date']; } } - diff --git a/api/v3/PledgePayment.php b/api/v3/PledgePayment.php index 3bb811d26d..ec3e0853af 100644 --- a/api/v3/PledgePayment.php +++ b/api/v3/PledgePayment.php @@ -69,11 +69,10 @@ function civicrm_api3_pledge_payment_create($params) { $dao = CRM_Pledge_BAO_PledgePayment::add($paymentParams); if(empty($dao->pledge_id)){ - $dao->find(True); + $dao->find(TRUE); } _civicrm_api3_object_to_array($dao, $result[$dao->id]); - //update pledge status CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($dao->pledge_id); @@ -107,7 +106,7 @@ function _civicrm_api3_pledge_payment_create_spec(&$params) { function civicrm_api3_pledge_payment_delete($params) { if (CRM_Pledge_BAO_PledgePayment::del($params['id'])) { - return civicrm_api3_create_success(array('id' => $params['id']), $params,'pledge_payment','delete'); + return civicrm_api3_create_success(array('id' => $params['id']), $params, 'pledge_payment', 'delete'); } else { return civicrm_api3_create_error('Could not delete payment'); @@ -128,7 +127,6 @@ function civicrm_api3_pledge_payment_delete($params) { */ function civicrm_api3_pledge_payment_get($params) { - return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } @@ -155,4 +153,3 @@ function updatePledgePayments($pledgeId, $paymentStatusId, $paymentIds) { function civicrm_api3_pledge_payment_get_spec(&$params) { $params['option.create_new'] = array('title' => "Create new field rather than update an unpaid payment"); } - diff --git a/api/v3/Profile.php b/api/v3/Profile.php index 8a7084b80a..713a21cd25 100644 --- a/api/v3/Profile.php +++ b/api/v3/Profile.php @@ -54,7 +54,7 @@ * Note that if contact_id is empty an array of defaults is returned */ function civicrm_api3_profile_get($params) { - $nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE; + $nonStandardLegacyBehaviour = is_numeric($params['profile_id']) ? TRUE : FALSE; if(!empty($params['check_permissions']) && !empty($params['contact_id']) && !1 === civicrm_api3('contact', 'getcount', array('contact_id' => $params['contact_id'], 'check_permissions' => 1))) { throw new API_Exception('permission denied'); } @@ -86,39 +86,38 @@ function civicrm_api3_profile_get($params) { CRM_Core_Permission::EDIT ); + if ($isContactActivityProfile) { + civicrm_api3_verify_mandatory($params, NULL, array('activity_id')); - if ($isContactActivityProfile) { - civicrm_api3_verify_mandatory($params, NULL, array('activity_id')); - - $errors = CRM_Profile_Form::validateContactActivityProfile($params['activity_id'], + $errors = CRM_Profile_Form::validateContactActivityProfile($params['activity_id'], $params['contact_id'], $params['profile_id'] - ); - if (!empty($errors)) { - throw new API_Exception(array_pop($errors)); - } - - $contactFields = $activityFields = array(); - foreach ($profileFields as $fieldName => $field) { - if (CRM_Utils_Array::value('field_type', $field) == 'Activity') { - $activityFields[$fieldName] = $field; + ); + if (!empty($errors)) { + throw new API_Exception(array_pop($errors)); } - else { - $contactFields[$fieldName] = $field; + + $contactFields = $activityFields = array(); + foreach ($profileFields as $fieldName => $field) { + if (CRM_Utils_Array::value('field_type', $field) == 'Activity') { + $activityFields[$fieldName] = $field; + } + else { + $contactFields[$fieldName] = $field; // we should return 'Primary' with & without capitalisation. it is more consistent with api to not // capitalise, but for form support we need it for now. Hopefully we can move away from it $contactFields[strtolower($fieldName)] = $field; } } - $ufGroupBAO->setProfileDefaults($params['contact_id'], $contactFields, $values[$profileID], TRUE); + $ufGroupBAO->setProfileDefaults($params['contact_id'], $contactFields, $values[$profileID], TRUE); - if ($params['activity_id']) { - $ufGroupBAO->setComponentDefaults($activityFields, $params['activity_id'], 'Activity', $values[$profileID], TRUE); + if ($params['activity_id']) { + $ufGroupBAO->setComponentDefaults($activityFields, $params['activity_id'], 'Activity', $values[$profileID], TRUE); + } } - } - elseif(!empty($params['contact_id'])) { - $ufGroupBAO->setProfileDefaults($params['contact_id'], $profileFields, $values[$profileID], TRUE); + elseif(!empty($params['contact_id'])) { + $ufGroupBAO->setProfileDefaults($params['contact_id'], $profileFields, $values[$profileID], TRUE); foreach ($values[$profileID] as $fieldName => $field){ // we should return 'Primary' with & without capitalisation. it is more consistent with api to not // capitalise, but for form support we need it for now. Hopefully we can move away from it @@ -316,12 +315,12 @@ function _civicrm_api3_profile_submit_spec(&$params, $apirequest) { //@todo get_options should take an array - @ the moment it is only takes 'all' - which is supported // by other getfields fn // we don't resolve state, country & county for performance reasons - $resolveOptions = CRM_Utils_Array::value('get_options',$apirequest['params']) == 'all' ? True : False; + $resolveOptions = CRM_Utils_Array::value('get_options', $apirequest['params']) == 'all' ? TRUE : FALSE; $profileID = _civicrm_api3_profile_getProfileID($apirequest['params']['profile_id']); $params = _civicrm_api3_buildprofile_submitfields($profileID, $resolveOptions, CRM_Utils_Array::value('cache_clear', $params)); } elseif (isset($apirequest['params']['cache_clear'])) { - _civicrm_api3_buildprofile_submitfields(FALSE, FALSE, True); + _civicrm_api3_buildprofile_submitfields(FALSE, FALSE, TRUE); } $params['profile_id']['api.required'] = TRUE; $params['profile_id']['title'] = 'Profile ID'; @@ -408,7 +407,7 @@ function _civicrm_api3_profile_getbillingpseudoprofile(&$params) { if(empty($params['contact_id'])) { $config = CRM_Core_Config::singleton(); - $blanks = array( + $blanks = array( 'billing_first_name' => '', 'billing_middle_name' => '', 'billing_last_name' => '', @@ -426,11 +425,11 @@ function _civicrm_api3_profile_getbillingpseudoprofile(&$params) { $addressFields = array('street_address', 'city', 'state_province_id', 'country_id', 'postal_code'); $result = civicrm_api3('contact', 'getsingle', array( 'id' => $params['contact_id'], - 'api.address.get.1' => array('location_type_id' => 'Billing', 'return' => $addressFields), + 'api.address.get.1' => array('location_type_id' => 'Billing', 'return' => $addressFields), // getting the is_billing required or not is an extra db call but probably cheap enough as this isn't an import api - 'api.address.get.2' => array('is_billing' => True, 'return' => $addressFields), - 'api.email.get.1' => array('location_type_id' => 'Billing',), - 'api.email.get.2' => array('is_billing' => True,), + 'api.address.get.2' => array('is_billing' => TRUE, 'return' => $addressFields), + 'api.email.get.1' => array('location_type_id' => 'Billing'), + 'api.email.get.2' => array('is_billing' => TRUE), 'return' => 'api.email.get, api.address.get, api.address.getoptions, country, state_province, email, first_name, last_name, middle_name, ' . implode($addressFields, ','), ) ); @@ -443,12 +442,12 @@ function _civicrm_api3_profile_getbillingpseudoprofile(&$params) { if(!empty($result['api.address.get.1']['count'])) { foreach ($addressFields as $fieldname) { - $values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result['api.address.get.1']['values'][0][$fieldname]) ? $result['api.address.get.1']['values'][0][$fieldname] : ''; + $values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result['api.address.get.1']['values'][0][$fieldname]) ? $result['api.address.get.1']['values'][0][$fieldname] : ''; } } elseif(!empty($result['api.address.get.2']['count'])) { foreach ($addressFields as $fieldname) { - $values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result['api.address.get.2']['values'][0][$fieldname]) ? $result['api.address.get.2']['values'][0][$fieldname] : ''; + $values['billing_' . $fieldname . '-' . $locationTypeID] = isset($result['api.address.get.2']['values'][0][$fieldname]) ? $result['api.address.get.2']['values'][0][$fieldname] : ''; } } else{ @@ -556,12 +555,12 @@ function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour = foreach ($entityFields as $entityfield => $realName) { $fieldName = strtolower($entityfield); if(!strstr($fieldName, '-')) { - if(strtolower($realName) != $fieldName) { - // we want to keep the '-' pattern for locations but otherwise - // we are going to make the api-standard field the main / preferred name but support the db name - // in future naming the fields in the DB to reflect the way the rest of the api / BAO / metadata works would - // reduce code - $fieldName = strtolower($realName); + if(strtolower($realName) != $fieldName) { + // we want to keep the '-' pattern for locations but otherwise + // we are going to make the api-standard field the main / preferred name but support the db name + // in future naming the fields in the DB to reflect the way the rest of the api / BAO / metadata works would + // reduce code + $fieldName = strtolower($realName); } if(isset($entityGetFieldsResult[$realName]['uniqueName'])) { // we won't alias the field name on here are we are using uniqueNames for the possibility of needing to differentiate @@ -577,7 +576,7 @@ function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour = } $profileFields[$profileID][$fieldName] = array_merge($entityGetFieldsResult[$realName], $profileFields[$profileID][$entityfield]); if(!isset($profileFields[$profileID][$fieldName]['api.aliases'])) { - $profileFields[$profileID][$fieldName]['api.aliases'] = array(); + $profileFields[$profileID][$fieldName]['api.aliases'] = array(); } if($optionsBehaviour && !empty($entityGetFieldsResult[$realName]['pseudoconstant'])) { if($optionsBehaviour > 1 || !in_array($realName, array('state_province_id', 'county_id', 'country_id'))) { diff --git a/api/v3/Relationship.php b/api/v3/Relationship.php index 97867e07ea..6a685598d7 100644 --- a/api/v3/Relationship.php +++ b/api/v3/Relationship.php @@ -138,7 +138,7 @@ function civicrm_api3_relationship_get($params) { return array('count' => $relationships); } foreach ($relationships as $relationshipId => $values) { - _civicrm_api3_custom_data_get($relationships[$relationshipId], 'Relationship', $relationshipId, NULL, CRM_Utils_Array::value('relationship_type_id',$values)); + _civicrm_api3_custom_data_get($relationships[$relationshipId], 'Relationship', $relationshipId, NULL, CRM_Utils_Array::value('relationship_type_id', $values)); } return civicrm_api3_create_success($relationships, $params); } diff --git a/api/v3/RelationshipType.php b/api/v3/RelationshipType.php index c1d76e19df..b45e5e0723 100644 --- a/api/v3/RelationshipType.php +++ b/api/v3/RelationshipType.php @@ -116,4 +116,3 @@ function civicrm_api3_relationship_type_get($params) { function civicrm_api3_relationship_type_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/ReportTemplate.php b/api/v3/ReportTemplate.php index a90112a972..e59dc6829b 100644 --- a/api/v3/ReportTemplate.php +++ b/api/v3/ReportTemplate.php @@ -124,7 +124,7 @@ function _civicrm_api3_report_template_getrows($params) { $reportInstance->preProcess(); $reportInstance->setDefaultValues(FALSE); $reportInstance->setParams(array_merge($reportInstance->getDefaultValues(), $params)); - $options = _civicrm_api3_get_options_from_params($params, TRUE,'report_template','get'); + $options = _civicrm_api3_get_options_from_params($params, TRUE, 'report_template', 'get'); $reportInstance->setLimitValue($options['limit']); $reportInstance->setOffsetValue($options['offset']); $reportInstance->beginPostProcessCommon(); diff --git a/api/v3/Setting.php b/api/v3/Setting.php index aa62527a07..4872fea4a0 100644 --- a/api/v3/Setting.php +++ b/api/v3/Setting.php @@ -56,10 +56,10 @@ function civicrm_api3_setting_getfields($params) { $params['filters']['name'] = $params['name']; } $result = CRM_Core_BAO_Setting::getSettingSpecification( - CRM_Utils_Array::value('component_id',$params), + CRM_Utils_Array::value('component_id', $params), CRM_Utils_Array::value('filters', $params, array()), - CRM_Utils_Array::value('domain_id', $params, null), - CRM_Utils_Array::value('profile', $params, null) + CRM_Utils_Array::value('domain_id', $params, NULL), + CRM_Utils_Array::value('profile', $params, NULL) ); // find any supplemental information if (!empty($params['action'])){ @@ -86,7 +86,7 @@ function _civicrm_api3_setting_getfields_spec(&$params) { * Note that is not in place as yet */ function civicrm_api3_setting_getdefaults(&$params){ - $settings = civicrm_api3('setting','getfields', $params); + $settings = civicrm_api3('setting', 'getfields', $params); $domains = _civicrm_api3_setting_getDomainArray($params); $defaults = array(); foreach ($domains as $domainID){ @@ -105,7 +105,7 @@ function civicrm_api3_setting_getdefaults(&$params){ print_r($noDefaults); } } - return civicrm_api3_create_success($defaults,$params,'setting','getfields'); + return civicrm_api3_create_success($defaults, $params, 'setting', 'getfields'); } /** * Metadata for setting create function @@ -126,8 +126,8 @@ function _civicrm_api3_setting_getdefaults_spec(&$params) { * Revert settings to defaults */ function civicrm_api3_setting_revert(&$params){ - $defaults = civicrm_api('setting','getdefaults', $params); - $fields = civicrm_api('setting','getfields', $params); + $defaults = civicrm_api('setting', 'getdefaults', $params); + $fields = civicrm_api('setting', 'getfields', $params); $fields = $fields['values']; $domains = _civicrm_api3_setting_getDomainArray($params); $result = array(); @@ -162,7 +162,7 @@ function _civicrm_api3_setting_revert_spec(&$params) { * Revert settings to defaults */ function civicrm_api3_setting_fill(&$params){ - $defaults = civicrm_api3('setting','getdefaults', $params); + $defaults = civicrm_api3('setting', 'getdefaults', $params); $domains = _civicrm_api3_setting_getDomainArray($params); $result = array(); foreach ($domains as $domainID){ @@ -170,7 +170,7 @@ function civicrm_api3_setting_fill(&$params){ 'version' => $params['version'], 'domain_id' => $domainID ); - $existing = civicrm_api3('setting','get', $apiArray); + $existing = civicrm_api3('setting', 'get', $apiArray); $valuesToFill = array_diff_key($defaults['values'][$domainID], $existing['values'][$domainID]); if(!empty($valuesToFill)){ $result = array_merge($result, civicrm_api('setting', 'create', $valuesToFill + $apiArray)); @@ -208,7 +208,7 @@ function _civicrm_api3_setting_fill_spec(&$params) { function civicrm_api3_setting_create($params) { $domains = _civicrm_api3_setting_getDomainArray($params); $result = CRM_Core_BAO_Setting::setItems($params, $domains); - return civicrm_api3_create_success($result,$params,'setting','create'); + return civicrm_api3_create_success($result, $params, 'setting', 'create'); } /** @@ -224,11 +224,10 @@ function _civicrm_api3_setting_create_spec(&$params) { 'description' => 'if you do not pass in a domain id this will default to the current domain an array or "all" are acceptable values for multiple domains' ); - $params['group'] = array( + $params['group'] = array( 'title' => 'Setting Group', 'description' => 'if you know the group defining it will make the api more efficient' - ) - ; + ); } /** @@ -244,8 +243,8 @@ function _civicrm_api3_setting_create_spec(&$params) { */ function civicrm_api3_setting_get($params) { $domains = _civicrm_api3_setting_getDomainArray($params); - $result = $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, array())); - return civicrm_api3_create_success($result, $params,'setting','get'); + $result = $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, array())); + return civicrm_api3_create_success($result, $params, 'setting', 'get'); } /** * Metadata for setting create function @@ -262,8 +261,7 @@ function _civicrm_api3_setting_get_spec(&$params) { $params['group'] = array( 'title' => 'Setting Group', 'description' => 'if you know the group defining it will make the api more efficient' - ) - ; + ); } /** * Returns value for specific parameter. Function requires more fields than 'get' but is intended for @@ -341,7 +339,7 @@ function _civicrm_api3_setting_getDomainArray(&$params){ } if($params['domain_id'] == 'all'){ - $domainAPIResult = civicrm_api('domain','get',array('version' => 3, 'return' => 'id')); + $domainAPIResult = civicrm_api('domain', 'get', array('version' => 3, 'return' => 'id')); if (isset($domainAPIResult['values'])) { $params['domain_id'] = array_keys($domainAPIResult['values']); } @@ -357,4 +355,3 @@ function _civicrm_api3_setting_getDomainArray(&$params){ } return $domains; } - diff --git a/api/v3/Survey.php b/api/v3/Survey.php index 33a8cff1fa..7aaa65cf98 100644 --- a/api/v3/Survey.php +++ b/api/v3/Survey.php @@ -95,4 +95,3 @@ function civicrm_api3_survey_get($params) { function civicrm_api3_survey_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/SurveyRespondant.php b/api/v3/SurveyRespondant.php index ececf93cfb..4e8f08217e 100644 --- a/api/v3/SurveyRespondant.php +++ b/api/v3/SurveyRespondant.php @@ -66,7 +66,7 @@ function civicrm_api3_survey_respondant_get(&$params) { $interviewerID = NULL; if (array_key_exists('interviewer_id', $params)) { $interviewerID = $params['interviewer_id']; -} + } $statusIds = array(); if (array_key_exists('status_id', $params)) { @@ -94,4 +94,3 @@ function &civicrm_api3_survey_respondant_count($params) { } return ($signaturesCount); } - diff --git a/api/v3/System.php b/api/v3/System.php index b456f94b78..0ef32ced58 100644 --- a/api/v3/System.php +++ b/api/v3/System.php @@ -174,4 +174,3 @@ function civicrm_api3_system_get($params) { ); return civicrm_api3_create_success($returnValues, $params, 'System', 'get'); } - diff --git a/api/v3/SystemLog.php b/api/v3/SystemLog.php index 65408a71b9..7696629872 100644 --- a/api/v3/SystemLog.php +++ b/api/v3/SystemLog.php @@ -43,7 +43,7 @@ * @return array */ function civicrm_api3_system_log_delete($params) { - return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, True, 'SystemLog'); + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'SystemLog'); } /** @@ -64,8 +64,8 @@ function civicrm_api3_system_log_create($params) { * @return array */ function _civicrm_api3_system_log_create_spec(&$params) { - require_once('api/v3/System.php'); - _civicrm_api3_system_log_spec($params); + require_once 'api/v3/System.php'; + _civicrm_api3_system_log_spec($params); } /** @@ -74,6 +74,5 @@ function _civicrm_api3_system_log_create_spec(&$params) { * @return array */ function civicrm_api3_system_log_get($params) { - return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, True, 'SystemLog'); + return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'SystemLog'); } - diff --git a/api/v3/Tag.php b/api/v3/Tag.php index 5af6853eb9..16029000e6 100644 --- a/api/v3/Tag.php +++ b/api/v3/Tag.php @@ -98,4 +98,3 @@ function civicrm_api3_tag_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/UFField.php b/api/v3/UFField.php index b18ad19f95..685d87d627 100644 --- a/api/v3/UFField.php +++ b/api/v3/UFField.php @@ -179,4 +179,3 @@ function _civicrm_api3_uf_field_delete_spec(&$params) { // legacy support for field_id $params['id']['api.aliases'] = array('field_id'); } - diff --git a/api/v3/UFGroup.php b/api/v3/UFGroup.php index 114ad3b4eb..37dc28b788 100644 --- a/api/v3/UFGroup.php +++ b/api/v3/UFGroup.php @@ -95,4 +95,3 @@ function civicrm_api3_uf_group_get($params) { function civicrm_api3_uf_group_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/UFJoin.php b/api/v3/UFJoin.php index df86d5744b..43b5ea9ff9 100644 --- a/api/v3/UFJoin.php +++ b/api/v3/UFJoin.php @@ -83,4 +83,3 @@ function _civicrm_api3_uf_join_create_spec(&$params) { function civicrm_api3_uf_join_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/UFMatch.php b/api/v3/UFMatch.php index 88d7b7fc0e..d0ccfe9bee 100644 --- a/api/v3/UFMatch.php +++ b/api/v3/UFMatch.php @@ -96,4 +96,3 @@ function _civicrm_api3_uf_match_create_spec(&$params) { function civicrm_api3_uf_match_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - diff --git a/api/v3/Website.php b/api/v3/Website.php index 9b77894231..96af33cfbc 100644 --- a/api/v3/Website.php +++ b/api/v3/Website.php @@ -54,9 +54,9 @@ function civicrm_api3_website_create($params) { //DO NOT USE THIS FUNCTION AS THE BASIS FOR A NEW API http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards $websiteBAO = CRM_Core_BAO_Website::add($params); - $values = array(); - _civicrm_api3_object_to_array($websiteBAO, $values[$websiteBAO->id]); - return civicrm_api3_create_success($values, $params, 'website', 'get'); + $values = array(); + _civicrm_api3_object_to_array($websiteBAO, $values[$websiteBAO->id]); + return civicrm_api3_create_success($values, $params, 'website', 'get'); } /** @@ -115,4 +115,3 @@ function civicrm_api3_website_delete($params) { function civicrm_api3_website_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'website'); } - diff --git a/api/v3/WordReplacement.php b/api/v3/WordReplacement.php index 4a906a1b45..d89793b169 100644 --- a/api/v3/WordReplacement.php +++ b/api/v3/WordReplacement.php @@ -44,8 +44,8 @@ */ function civicrm_api3_word_replacement_get($params) { $bao = new CRM_Core_BAO_WordReplacement(); - _civicrm_api3_dao_set_filter($bao, $params, true, 'WordReplacement'); - $wordReplacements = _civicrm_api3_dao_to_array($bao, $params, true,'WordReplacement'); + _civicrm_api3_dao_set_filter($bao, $params, TRUE, 'WordReplacement'); + $wordReplacements = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'WordReplacement'); return civicrm_api3_create_success($wordReplacements, $params, 'word_replacement', 'get', $bao); } diff --git a/api/v3/utils.php b/api/v3/utils.php index d60e34a7d4..67fd1ba35a 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -58,8 +58,7 @@ function _civicrm_api3_initialize() { * @return null or throws error if there the required fields not present * @ */ -function civicrm_api3_verify_one_mandatory($params, $daoName = NULL, $keyoptions = array( - )) { +function civicrm_api3_verify_one_mandatory($params, $daoName = NULL, $keyoptions = array()) { $keys = array(array()); foreach ($keyoptions as $key) { $keys[0][] = $key; @@ -128,7 +127,7 @@ function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = array() } } if (!empty($unmatched)) { - throw new API_Exception("Mandatory key(s) missing from params array: " . implode(", ", $unmatched),"mandatory_missing",array("fields"=>$unmatched)); + throw new API_Exception("Mandatory key(s) missing from params array: " . implode(", ", $unmatched), "mandatory_missing", array("fields" => $unmatched)); } } @@ -404,7 +403,7 @@ function _civicrm_api3_separate_values(&$values) { * @param array $values */ function _civicrm_api3_filter_fields_for_bao($entity, &$params, &$values){ - $fields = civicrm_api($entity,'getfields', array('version' => 3,'action' => 'create')); + $fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'create')); $fields = $fields['values']; _civicrm_api3_store_values($fields, $params, $values); } @@ -487,7 +486,7 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti $$varToFilter = array_intersect_key($$varToFilter, $fields['values']); } } - $options = array_merge($options,$additional_options); + $options = array_merge($options, $additional_options); $sort = CRM_Utils_Array::value('sort', $options, NULL); $offset = CRM_Utils_Array::value('offset', $options, NULL); $limit = CRM_Utils_Array::value('limit', $options, NULL); @@ -512,14 +511,14 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti } - $skipPermissions = !empty($params['check_permissions']) ? 0 :1; + $skipPermissions = !empty($params['check_permissions']) ? 0 : 1; list($entities, $options) = CRM_Contact_BAO_Query::apiQuery( $newParams, $returnProperties, NULL, $sort, - $offset , + $offset, $limit, $smartGroupCache, $getCount, @@ -640,7 +639,7 @@ function _civicrm_api3_dao_set_filter(&$dao, $params, $unique = TRUE, $entity) { if (!empty($options['return']) && is_array($options['return']) && empty($options['is_count'])) { $dao->selectAdd(); $options['return']['id'] = TRUE;// ensure 'id' is included - $allfields = _civicrm_api3_get_unique_name_array($dao); + $allfields = _civicrm_api3_get_unique_name_array($dao); $returnMatched = array_intersect(array_keys($options['return']), $allfields); foreach ($returnMatched as $returnValue) { $dao->selectAdd($returnValue); @@ -740,16 +739,16 @@ function _civicrm_api3_get_options_from_params(&$params, $queryObject = FALSE, $ $returnProperties = array_fill_keys($returnProperties, 1); } } - if ($entity && $action =='get') { + if ($entity && $action == 'get') { if (!empty($returnProperties['id'])) { $returnProperties[$entity . '_id'] = 1; unset($returnProperties['id']); } switch (trim(strtolower($sort))){ - case 'id': - case 'id desc': - case 'id asc': - $sort = str_replace('id', $entity . '_id',$sort); + case 'id': + case 'id desc': + case 'id asc': + $sort = str_replace('id', $entity . '_id', $sort); } } @@ -773,7 +772,7 @@ function _civicrm_api3_get_options_from_params(&$params, $queryObject = FALSE, $ $inputParams = array(); $legacyreturnProperties = array(); $otherVars = array( - 'sort', 'offset', 'rowCount', 'options','return', + 'sort', 'offset', 'rowCount', 'options', 'return', ); foreach ($params as $n => $v) { if (substr($n, 0, 7) == 'return.') { @@ -782,7 +781,8 @@ function _civicrm_api3_get_options_from_params(&$params, $queryObject = FALSE, $ elseif ($n == 'id') { $inputParams[$entity. '_id'] = $v; } - elseif (in_array($n, $otherVars)) {} + elseif (in_array($n, $otherVars)) { + } else { $inputParams[$n] = $v; if ($v && !is_array($v) && stristr($v, 'SELECT')) { @@ -806,10 +806,10 @@ function _civicrm_api3_get_options_from_params(&$params, $queryObject = FALSE, $ */ function _civicrm_api3_apply_options_to_dao(&$params, &$dao, $entity) { - $options = _civicrm_api3_get_options_from_params($params,FALSE,$entity); + $options = _civicrm_api3_get_options_from_params($params, FALSE, $entity); if(!$options['is_count']) { if(!empty($options['limit'])) { - $dao->limit((int)$options['offset'], (int)$options['limit']); + $dao->limit((int) $options['offset'], (int) $options['limit']); } if (!empty($options['sort'])) { $dao->orderBy($options['sort']); @@ -825,9 +825,9 @@ function _civicrm_api3_build_fields_array(&$bao, $unique = TRUE) { $fields = $bao->fields(); if ($unique) { if (empty($fields['id'])){ - $entity = _civicrm_api_get_entity_name_from_dao($bao); - $fields['id'] = $fields[$entity . '_id']; - unset($fields[$entity . '_id']); + $entity = _civicrm_api_get_entity_name_from_dao($bao); + $fields['id'] = $fields[$entity . '_id']; + unset($fields[$entity . '_id']); } return $fields; } @@ -848,7 +848,7 @@ function _civicrm_api3_build_fields_array(&$bao, $unique = TRUE) { function _civicrm_api3_get_unique_name_array(&$bao) { $fields = $bao->fields(); foreach ($fields as $field => $values) { - $uniqueFields[$field] = CRM_Utils_Array::value('name',$values, $field); + $uniqueFields[$field] = CRM_Utils_Array::value('name', $values, $field); } return $uniqueFields; } @@ -903,7 +903,6 @@ function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, } } - return $result; } @@ -985,7 +984,7 @@ function _civicrm_api3_custom_format_params($params, &$values, $extends, $entity foreach ($params as $key => $value) { list($customFieldID, $customValueID) = CRM_Core_BAO_CustomField::getKeyID($key, TRUE); - if ($customFieldID && (!IS_NULL($value))) { + if ($customFieldID && (!is_null($value))) { if ($checkCheckBoxField && !empty($fields['custom_' . $customFieldID]) && $fields['custom_' . $customFieldID]['html_type'] == 'CheckBox') { formatCheckBoxField($value, 'custom_' . $customFieldID, $entity); } @@ -1192,7 +1191,7 @@ function _civicrm_api3_basic_get($bao_name, &$params, $returnAsSuccess = TRUE, $ $bao = new $bao_name(); _civicrm_api3_dao_set_filter($bao, $params, TRUE, $entity); if ($returnAsSuccess) { - return civicrm_api3_create_success(_civicrm_api3_dao_to_array($bao, $params, FALSE, $entity), $params, $entity, 'get'); + return civicrm_api3_create_success(_civicrm_api3_dao_to_array($bao, $params, FALSE, $entity), $params, $entity, 'get'); } else { return _civicrm_api3_dao_to_array($bao, $params, FALSE, $entity, 'get'); @@ -1392,7 +1391,7 @@ function _civicrm_api3_custom_data_get(&$returnArray, $entity, $entity_id, $grou * ErrorMode do intensive post fail checks?. * @throws Exception */ -function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $errorMode = False) { +function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $errorMode = FALSE) { $fields = array_intersect_key($fields, $params); foreach ($fields as $fieldName => $fieldInfo) { switch (CRM_Utils_Array::value('type', $fieldInfo)) { @@ -1408,7 +1407,7 @@ function _civicrm_api3_validate_fields($entity, $action, &$params, $fields, $err _civicrm_api3_validate_date($params, $fieldName, $fieldInfo); break; - case 32://blob + case 32://blob _civicrm_api3_validate_html($params, $fieldName, $fieldInfo); break; @@ -1797,7 +1796,7 @@ function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $ent if (!is_numeric($params[$fieldName]) && is_scalar($params[$fieldName])) { $realContactId = _civicrm_api3_resolve_contactID($params[$fieldName]); if ('unknown-user' === $realContactId) { - throw new API_Exception("\"$fieldName\" \"{$params[$fieldName]}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName,"type"=>"integer")); + throw new API_Exception("\"$fieldName\" \"{$params[$fieldName]}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName, "type" => "integer")); } elseif (is_numeric($realContactId)) { $params[$fieldName] = $realContactId; } @@ -1817,7 +1816,7 @@ function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $ent if(is_string($params[$fieldName]) && !empty($fieldInfo['maxlength']) && strlen($params[$fieldName]) > $fieldInfo['maxlength'] ){ throw new API_Exception( $params[$fieldName] . " is " . strlen($params[$fieldName]) . " characters - longer than $fieldName length" . $fieldInfo['maxlength'] . ' characters', - 2100, array('field' => $fieldName, "max_length"=>$fieldInfo['maxlength']) + 2100, array('field' => $fieldName, "max_length" => $fieldInfo['maxlength']) ); } } @@ -1864,7 +1863,7 @@ function _civicrm_api3_resolve_contactID($contactIdExpr) { function _civicrm_api3_validate_html(&$params, &$fieldName, $fieldInfo) { if ($value = CRM_Utils_Array::value($fieldName, $params)) { if (!CRM_Utils_Rule::xssString($value)) { - throw new API_Exception(ts('Illegal characters in input (potential scripting attack)'), array("field"=>$fieldName,"error_code"=>"xss")); + throw new API_Exception(ts('Illegal characters in input (potential scripting attack)'), array("field" => $fieldName, "error_code" => "xss")); } } } -- 2.25.1