// CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); // No, force-commits transaction
// CRM_Core_DAO::singleValueQuery("DELETE FROM civicrm_acl_contact_cache"); // Transaction-safe
if (CRM_Core_Transaction::isActive()) {
- CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function(){
+ CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, function() {
CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache");
});
}
$roleObj = $wp_roles->get_role($role);
//Remove all civicrm capabilities for the role, as there may be some capabilities checkbox unticked
- foreach ($permissionsArray as $key => $capability){
+ foreach ($permissionsArray as $key => $capability) {
$roleObj->remove_cap($key);
}
*
* @return array civicrm permissions
*/
- public static function getPermissionArray(){
+ public static function getPermissionArray() {
global $civicrm_root;
$permissions = CRM_Core_Permission::basicPermissions();
);
$readOnlyFields['assignee_display_name'] = ts('Assigned to');
if (!empty($contactDetails)) {
- foreach ($contactDetails as $key => $value){
+ foreach ($contactDetails as $key => $value) {
$assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key);
foreach ($assignee as $keys => $values) {
$assigneeContact[] = CRM_Contact_BAO_Contact::displayname($values);
'1' => 1) + $cRSearchFields;
// we can handle all the ones defined in the metadata here. Others to be converted
- foreach ($this->_settings as $setting => $group){
+ foreach ($this->_settings as $setting => $group) {
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
$this->_defaults[$setting] = civicrm_api('setting', 'getvalue', array(
'version' => 3,
)
);
- foreach ($this->_settings as $setting => $group){
+ foreach ($this->_settings as $setting => $group) {
$settingMetaData = civicrm_api('setting', 'getfields', array('version' => 3, 'name' => $setting));
$props = $settingMetaData['values'][$setting];
- if (isset($props['quick_form_type'])){
+ if (isset($props['quick_form_type'])) {
$add = 'add' . $props['quick_form_type'];
- if ($add == 'addElement'){
+ if ($add == 'addElement') {
$this->$add(
$props['html_type'],
$setting,
$this->$add($setting, ts($props['title']));
}
$this->assign("{$setting}_description", ts($props['description']));
- if ($setting == 'max_attachments'){
+ if ($setting == 'max_attachments') {
//temp hack @todo fix to get from metadata
$this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
}
- if ($setting == 'maxFileSize'){
+ if ($setting == 'maxFileSize') {
//temp hack
$this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
}
}
$settings = array_intersect_key($params, $this->_settings);
$result = civicrm_api('setting', 'create', $settings + array('version' => 3));
- foreach ($settings as $setting => $settingGroup){
+ foreach ($settings as $setting => $settingGroup) {
//@todo array_diff this
unset($params[$setting]);
}
return NULL;
}
$reportId = CRM_Campaign_BAO_Survey::getReportID($id);
- if ($reportId){
+ if ($reportId) {
CRM_Report_BAO_ReportInstance::del($reportId);
}
$dao = new CRM_Campaign_DAO_Survey();
foreach ($this->_contactIds as $contactId) {
//build the profile fields.
foreach ($this->_surveyFields as $name => $field) {
- if ($field){
+ if ($field) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $contactId);
}
}
// make sure you preserve specific form values like location type, is_primary_ is_billing, master_id
// CRM-10336: Also empty any fields from the existing address block if they don't exist in master (otherwise they will persist)
foreach ($values as $field => $submittedValue) {
- if (!in_array($field, $skipFields)){
+ if (!in_array($field, $skipFields)) {
if (isset($masterAddress->$field)) {
$values[$field] = $masterAddress->$field;
}
elseif ($groupType == 'Access') {
$value = CRM_Core_DAO::VALUE_SEPARATOR . '1' . CRM_Core_DAO::VALUE_SEPARATOR;
}
- elseif (!empty($groupType)){
+ elseif (!empty($groupType)) {
// ie we have been given the group key
$value = CRM_Core_DAO::VALUE_SEPARATOR . $groupType . CRM_Core_DAO::VALUE_SEPARATOR;
}
$relationshipId = CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params));
//CRM-9015 - the hooks are called here & in add (since add doesn't call create)
// but in future should be tidied per ticket
- if (empty($relationshipId)){
+ if (empty($relationshipId)) {
$hook = 'create';
$action = CRM_Core_Action::ADD;
}
$dateFields = array('end_date', 'start_date');
- foreach (self::getdefaults() as $defaultField => $defaultValue){
- if (isset($params[$defaultField])){
- if (in_array($defaultField, $dateFields)){
+ foreach (self::getdefaults() as $defaultField => $defaultValue) {
+ if (isset($params[$defaultField])) {
+ if (in_array($defaultField, $dateFields)) {
$relationship->$defaultField = CRM_Utils_Date::format(CRM_Utils_Array::value($defaultField, $params));
- if (!$relationship->$defaultField){
+ if (!$relationship->$defaultField) {
$relationship->$defaultField = 'NULL';
}
}
$relationship->$defaultField = $params[$defaultField];
}
}
- elseif(!$relationshipId){
+ elseif(!$relationshipId) {
$relationship->$defaultField = $defaultValue;
}
}
*/
$dateFields = array('end_date', 'start_date');
- foreach ($dateFields as $dateField){
+ foreach ($dateFields as $dateField) {
if (array_key_exists($dateField, $params)) {
- if (empty($params[$dateField]) || $params[$dateField] == 'null'){
+ if (empty($params[$dateField]) || $params[$dateField] == 'null') {
//this is most likely coming from an api call & probably loaded
// from the DB to deal with some of the
// other myriad of excessive checks still in place both in
$queryString .= " AND $dateField IS NULL";
continue;
}
- elseif (is_array($params[$dateField])){
+ elseif (is_array($params[$dateField])) {
$queryString .= " AND $dateField = " .
CRM_Utils_Type::escape(CRM_Utils_Date::format($params[$dateField]), 'Date');
}
'account_relationship = 7'
);
$productFinancialType = array_intersect($costFinancialType, $premiumFinancialType);
- foreach ($financialType as $key => $financialTypeName ){
+ foreach ($financialType as $key => $financialTypeName ) {
if (!in_array( $key, $productFinancialType)) {
unset( $financialType[$key] );
}
}
- if (count( $financialType ) ){
+ if (count( $financialType ) ) {
$this->assign( 'financialType', $financialType );
}
$this->add(
'account_relationship = 7'
);
$productFinancialType = array_intersect($costFinancialType, $premiumFinancialType);
- foreach ($financialType as $key => $financialTypeName ){
+ foreach ($financialType as $key => $financialTypeName ) {
if (!in_array( $key, $productFinancialType)) {
unset( $financialType[$key] );
}
}
- if (count( $financialType ) ){
+ if (count( $financialType ) ) {
$this->assign( 'financialType', $financialType );
}
$this->add(
$params[$this->_activeFields[$i]->_name] = array();
}
$params[$this->_activeFields[$i]->_name][$i][$this->_activeFields[$i]->_softCreditField] = $this->_activeFields[$i]->_value;
- if (isset($this->_activeFields[$i]->_softCreditType)){
+ if (isset($this->_activeFields[$i]->_softCreditType)) {
$params[$this->_activeFields[$i]->_name][$i]['soft_credit_type_id'] = $this->_activeFields[$i]->_softCreditType;
}
}
//Delete all existing soft Contribution from contribution_soft table for pcp_id is_null
$existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit['contribution_id']);
- if (isset($existingSoftCredit['soft_credit']) && !empty($existingSoftCredit['soft_credit'])){
- foreach ($existingSoftCredit['soft_credit'] as $key => $existingSoftCreditValues){
+ if (isset($existingSoftCredit['soft_credit']) && !empty($existingSoftCredit['soft_credit'])) {
+ foreach ($existingSoftCredit['soft_credit'] as $key => $existingSoftCreditValues) {
if (!empty($existingSoftCreditValues['soft_credit_id'])) {
$deleteParams = array(
'id' => $existingSoftCreditValues['soft_credit_id'],
$dao->id
);
//Financial Type
- if (!empty( $dao->financial_type_id ) ){
+ if (!empty( $dao->financial_type_id ) ) {
require_once 'CRM/Core/DAO.php';
$premiums[$dao->id]['financial_type_id'] = CRM_Core_DAO::getFieldValue( 'CRM_Financial_DAO_FinancialType', $dao->financial_type_id, 'name' );
}
unset(self::$_tasks[1]);
}
//CRM-12920 - check for edit permission
- if (!CRM_Core_Permission::check('edit contributions') ){
+ if (!CRM_Core_Permission::check('edit contributions') ) {
unset(self::$_tasks[4], self::$_tasks[6]);
}
if ($count > 2) {
break;
}
- if (count($first_names) == 1){
+ if (count($first_names) == 1) {
$family = $first_names[current(array_keys($first_names))]['addressee_display'];
}
else {
$sql = "UPDATE $table SET is_primary = 0 WHERE contact_id = %1";
$sqlParams = array(1 => array($contactId, 'Integer'));
// we don't want to create unecessary entries in the log_ tables so exclude the one we are working on
- if (!empty($params['id'])){
+ if (!empty($params['id'])) {
$sql .= " AND id <> %2";
$sqlParams[2] = array($params['id'], 'Integer');
}
* @param array $locations
*
*/
- public static function sortPrimaryFirst(&$locations){
+ public static function sortPrimaryFirst(&$locations) {
uasort($locations, 'self::primaryComparison');
}
* @param array $location2
* @return number
*/
- public static function primaryComparison($location1, $location2){
+ public static function primaryComparison($location1, $location2) {
$l1 = CRM_Utils_Array::value('is_primary', $location1);
$l2 = CRM_Utils_Array::value('is_primary', $location2);
if ($l1 == $l2) {
SET is_bulkmail = 0
WHERE contact_id = {$params['contact_id']}
";
- if ($hook == 'edit'){
+ if ($hook == 'edit') {
$sql .= " AND id <> {$params['id']}";
}
CRM_Core_DAO::executeQuery($sql);
$sqlParams = array(1 => array($entity_id, 'Integer'), 2 => array($entity_table, 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
- while ($dao->fetch()){
+ while ($dao->fetch()) {
$result[$dao->financial_trxn_id][$dao->id] = $dao->amount;
}
if (!empty($result)) {
* @return object
*/
public static function add(&$params, $ids = array()) {
- if (empty($params['id'])){
+ if (empty($params['id'])) {
$params['id'] = CRM_Utils_Array::value('optionGroup', $ids);
}
* @return object
*/
public static function create($params) {
- if (empty($params['id'])){
+ if (empty($params['id'])) {
self::setDefaults($params);
}
$ids = array();
*
* @param array $params
*/
- public static function setDefaults(&$params){
- if (CRM_Utils_Array::value('label', $params, NULL) === NULL){
+ public static function setDefaults(&$params) {
+ if (CRM_Utils_Array::value('label', $params, NULL) === NULL) {
$params['label'] = $params['name'];
}
- if (CRM_Utils_Array::value('name', $params, NULL) === NULL){
+ if (CRM_Utils_Array::value('name', $params, NULL) === NULL) {
$params['name'] = $params['label'];
}
- if (CRM_Utils_Array::value('weight', $params, NULL) === NULL){
+ if (CRM_Utils_Array::value('weight', $params, NULL) === NULL) {
$params['weight'] = self::getDefaultWeight($params);
}
- if (CRM_Utils_Array::value('value', $params, NULL) === NULL){
+ if (CRM_Utils_Array::value('value', $params, NULL) === NULL) {
$params['value'] = self::getDefaultValue($params);
}
}
*
* @return int
*/
- public static function getDefaultWeight($params){
+ public static function getDefaultWeight($params) {
return (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue',
array('option_group_id' => $params['option_group_id']));
}
* more complex decision making
* @param array $params
*/
- public static function getDefaultValue($params){
+ public static function getDefaultValue($params) {
$bao = new CRM_Core_BAO_OptionValue();
$bao->option_group_id = $params['option_group_id'];
- if (isset($params['domain_id'])){
+ if (isset($params['domain_id'])) {
$bao->domain_id = $params['domain_id'];
}
$bao->selectAdd();
* Allow key o be cleared
* @param string $cacheKey
*/
- public static function flushCache($cacheKey){
+ public static function flushCache($cacheKey) {
unset(self::$_cache[$cacheKey]);
$globalCache = CRM_Utils_Cache::singleton();
$globalCache->delete($cacheKey);
$fields = $result = array();
$fieldsToGet = self::validateSettingsInput(array_flip($settingsToReturn), $fields, FALSE);
foreach ($domains as $domainID) {
- if ($domainID != CRM_Core_Config::domainID()){
+ if ($domainID != CRM_Core_Config::domainID()) {
$reloadConfig = TRUE;
CRM_Core_BAO_Domain::setDomain($domainID);
}
$config = CRM_Core_Config::singleton($reloadConfig, $reloadConfig);
$result[$domainID] = array();
foreach ($fieldsToGet as $name => $value) {
- if (!empty($fields['values'][$name]['prefetch'])){
+ if (!empty($fields['values'][$name]['prefetch'])) {
if (isset($params['filters']) && isset($params['filters']['prefetch'])
- && $params['filters']['prefetch'] == 0){
+ && $params['filters']['prefetch'] == 0) {
// we are filtering out the prefetches from the return array
// so we will skip
continue;
}
$configKey = CRM_Utils_Array::value('config_key', $fields['values'][$name], $name);
- if (isset($config->$configKey)){
+ if (isset($config->$configKey)) {
$setting = $config->$configKey;
}
}
}
foreach ($domains as $domainID) {
- if ($domainID != CRM_Core_Config::domainID()){
+ if ($domainID != CRM_Core_Config::domainID()) {
$reloadConfig = TRUE;
CRM_Core_BAO_Domain::setDomain($domainID);
}
$result[$domainID] = array();
foreach ($fieldsToSet as $name => $value) {
- if (empty($fields['values'][$name]['config_only'])){
+ if (empty($fields['values'][$name]['config_only'])) {
CRM_Core_BAO_Setting::_setItem(
$fields['values'][$name],
$value,
$domainID
);
}
- if (!empty($fields['values'][$name]['prefetch'])){
- if (!empty($fields['values'][$name]['config_key'])){
+ if (!empty($fields['values'][$name]['prefetch'])) {
+ if (!empty($fields['values'][$name]['config_key'])) {
$name = $fields['values'][$name]['config_key'];
}
$config_keys[$name] = $value;
}
$result[$domainID][$name] = $value;
}
- if ($reloadConfig){
+ if ($reloadConfig) {
CRM_Core_Config::singleton($reloadConfig, $reloadConfig);
}
- if (!empty($config_keys)){
+ if (!empty($config_keys)) {
CRM_Core_BAO_ConfigSetting::create($config_keys);
}
- if ($reloadConfig){
+ if ($reloadConfig) {
CRM_Core_BAO_Domain::resetDomain();
}
}
* @fieldSpec array Metadata for given field (drawn from the xml)
*/
public static function validateSetting(&$value, $fieldSpec) {
- if ($fieldSpec['type'] == 'String' && is_array($value)){
+ if ($fieldSpec['type'] == 'String' && is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,$value) . CRM_Core_DAO::VALUE_SEPARATOR;
}
if (empty($fieldSpec['validate_callback'])) {
$spec = self::getSettingSpecification(NULL, array('name' => $name), $domainID);
$configKey = CRM_Utils_Array::value('config_key', $spec[$name], CRM_Utils_Array::value('legacy_key', $spec[$name], $name));
//if the key is set to config_only we don't need to do anything
- if (empty($spec[$name]['config_only'])){
+ if (empty($spec[$name]['config_only'])) {
if (!empty($values[$configKey])) {
civicrm_api('setting', 'create', array('version' => 3, $name => $values[$configKey], 'domain_id' => $domainID));
}
);
$field['html'] = array();
foreach ($validOptions as $htmlOption) {
- if (!empty($fieldXML->html->$htmlOption)){
+ if (!empty($fieldXML->html->$htmlOption)) {
$field['html'][$htmlOption] = $this->value($htmlOption, $fieldXML->html);
}
}
}
$field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML);
- if (!empty($field['pseudoconstant'])){
+ if (!empty($field['pseudoconstant'])) {
//ok this is a bit long-winded but it gets there & is consistent with above approach
$field['pseudoconstant'] = array();
$validOptions = array(
'callback',
);
foreach ($validOptions as $pseudoOption) {
- if (!empty($fieldXML->pseudoconstant->$pseudoOption)){
+ if (!empty($fieldXML->pseudoconstant->$pseudoOption)) {
$field['pseudoconstant'][$pseudoOption] = $this->value($pseudoOption, $fieldXML->pseudoconstant);
}
}
*/
public static function schemaRequiresRebuilding($tables = array("civicrm_contact")) {
$show = array();
- foreach ($tables as $tableName){
+ foreach ($tables as $tableName) {
if (!array_key_exists($tableName, $show)) {
$query = "SHOW CREATE TABLE $tableName";
$dao = CRM_Core_DAO::executeQuery($query);
}
$result = preg_match("/\bCONSTRAINT\b\s/i", $show[$tableName]) ? TRUE : FALSE;
- if ($result == TRUE){
+ if ($result == TRUE) {
continue;
}
else {
* @todo standardise the format which dates are passed to the BAO layer in & remove date
* handling from BAO
*/
- public function convertDateFieldsToMySQL(&$params){
- foreach ($this->_dateFields as $fieldName => $specs){
- if (!empty($params[$fieldName])){
+ public function convertDateFieldsToMySQL(&$params) {
+ foreach ($this->_dateFields as $fieldName => $specs) {
+ if (!empty($params[$fieldName])) {
$params[$fieldName] = CRM_Utils_Date::isoToMysql(
CRM_Utils_Date::processDate(
$params[$fieldName],
);
}
else{
- if (isset($specs['default'])){
+ if (isset($specs['default'])) {
$params[$fieldName] = date('YmdHis', strtotime($specs['default']));
}
}
* @param $name
* @param array $params
*/
- public static function flush($name, $params = array()){
+ public static function flush($name, $params = array()) {
$defaults = array(
'flip' => FALSE,
'grouping' => FALSE,
* the date we entered to be respected
*/
$minDate = date_create('now', new DateTimeZone(self::TIMEZONE));
- if (strtotime($startDate->format('Y-m-d')) < strtotime($minDate->format('Y-m-d'))){
+ if (strtotime($startDate->format('Y-m-d')) < strtotime($minDate->format('Y-m-d'))) {
$startDate->setTimezone(new DateTimeZone(self::TIMEZONE));
}
$contRecur = CRM_Core_DAO::executeQuery($sql);
$contRecur->fetch();
$ids['contributionRecur'] = $contRecur->id;
- if ($ids['contact'] != $contRecur->contact_id){
+ if ($ids['contact'] != $contRecur->contact_id) {
CRM_Core_Error::debug_log_message("Recurring contribution appears to have been re-assigned from id {$ids['contact']} to {$contRecur->contact_id}
Continuing with {$contRecur->contact_id}
");
$values['receipt_from_name'] = $domainValues[0];
$values['receipt_from_email'] = $domainValues[1];
}
- if ($recurContrib && $recurContrib->id){
+ if ($recurContrib && $recurContrib->id) {
//CRM-13273 - is_email_receipt setting on recurring contribution should take precedence over contribution page setting
$values['is_email_receipt'] = $recurContrib->is_email_receipt;
}
// we have a pledge now we need to get the oldest unpaid payment
$paymentDetails = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeId);
- if (empty($paymentDetails['id'])){
+ if (empty($paymentDetails['id'])) {
// we can assume this pledge is now completed
// return now so we don't create a core error & roll back
return;
*
* @return bool
*/
- public static function buildPaymentForm($form, $processor, $isBillingDataOptional){
+ public static function buildPaymentForm($form, $processor, $isBillingDataOptional) {
//if the form has address fields assign to the template so the js can decide what billing fields to show
$profileAddressFields = $form->get('profileAddressFields');
if (!empty($profileAddressFields)) {
/**
* Skip remaining logic in the current iteration of a loop.
*/
-function smarty_compiler_continue($contents, &$smarty){
+function smarty_compiler_continue($contents, &$smarty) {
return 'continue;';
}
'communication_style_id' => $value,
);
- if (!empty($contact['preferred_communication_method'])){
+ if (!empty($contact['preferred_communication_method'])) {
// api 3 returns pref_comm_method as an array, which breaks the lookup; so we reconstruct
$prefCommList = is_array($specialValues[$moniker]['preferred_communication_method']) ? implode(CRM_Core_DAO::VALUE_SEPARATOR, $specialValues[$moniker]['preferred_communication_method']) : $specialValues[$moniker]['preferred_communication_method'];
$specialValues[$moniker]['preferred_communication_method'] = CRM_Core_DAO::VALUE_SEPARATOR . $prefCommList . CRM_Core_DAO::VALUE_SEPARATOR;
//create discount priceset
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
if (!empty($discountFieldIDs[$j])) {
- foreach ($discountFieldIDs[$j] as $fID){
+ foreach ($discountFieldIDs[$j] as $fID) {
CRM_Price_BAO_PriceFieldValue::setIsActive($fID, '0');
}
}
CRM_Event_BAO_Participant::changeFeeSelections($params, $this->_participantId, $this->_contributionId, $feeBlock, $lineItems, $this->_paidAmount, $params['priceSetId']);
$this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount');
// email sending
- if (CRM_Utils_Array::value('send_receipt', $params)){
+ if (CRM_Utils_Array::value('send_receipt', $params)) {
$fetchParticipantVals = array('id' => $this->_participantId);
CRM_Event_BAO_Participant::getValues($fetchParticipantVals, $participantDetails, CRM_Core_DAO::$_nullArray);
$participantParams = array_merge($params, $participantDetails[$this->_participantId]);
unset(self::$_tasks[1]);
}
//CRM-12920 - check for edit permission
- if (!CRM_Core_Permission::check('edit event participants') ){
+ if (!CRM_Core_Permission::check('edit event participants') ) {
unset(self::$_tasks[4], self::$_tasks[5], self::$_tasks[15]);
}
}
* @param array_type $processor2
* @return number
*/
- public static function defaultComparison($processor1, $processor2){
+ public static function defaultComparison($processor1, $processor2) {
$p1 = CRM_Utils_Array::value('is_default', $processor1);
$p2 = CRM_Utils_Array::value('is_default', $processor2);
if ($p1 == $p2) {
)
);
- if (!empty($result)){
+ if (!empty($result)) {
foreach ($result as $id => $name) {
$selectedArray = array();
if ($id == $defaultId) {
if (!empty($result)) {
foreach ($result as $id => $name) {
if (in_array($id, $financialAccountType[$financialAccountTypeId]) && $_GET['_value'] != 'select') {
- if ($countResult != 1){
+ if ($countResult != 1) {
$elements[] = array(
'name' => $name,
'value' => $id,
);
}
}
- elseif ($_GET['_value'] == 'select'){
+ elseif ($_GET['_value'] == 'select') {
$elements[] = array(
'name' => $name,
'value' => $id,
$params['entity_table'] = 'civicrm_financial_type';
CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, CRM_Core_DAO::$_nullArray, $financialAccountIds);
- foreach ($financialAccountIds as $key => $values){
+ foreach ($financialAccountIds as $key => $values) {
if (!empty($financialAccounts[$values['financial_account_id']])) {
$financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value(
$values['financial_account_id'], $financialAccounts );
$grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
if (empty($params['skipRecentView'])) {
- if (!isset($grant->contact_id) || !isset($grant->grant_type_id)){
+ if (!isset($grant->contact_id) || !isset($grant->grant_type_id)) {
$grant->find(TRUE);
}
$title = CRM_Contact_BAO_Contact::displayName($grant->contact_id) . ' - ' . ts('Grant') . ': ' . $grantTypes[$grant->grant_type_id];
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
$ssID = $this->get('ssID');
$this->assign('ssid', $ssID);
$this->_searchBasedMailing = CRM_Contact_Form_Search::isSearchContext($this->get('context'));
- if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID){
+ if (CRM_Contact_Form_Search::isSearchContext($this->get('context')) && !$ssID) {
$params = array();
$result = CRM_Core_BAO_PrevNextCache::getSelectedContacts();
$this->assign("value", $result);
* @return CRM_Member_BAO_MembershipStatus object
* @static
*/
- public static function create($params){
+ public static function create($params) {
$ids = array();
- if (!empty($params['id'])){
+ if (!empty($params['id'])) {
$ids['membershipStatus'] = $params['id'];
}
else{
// Check if we are on or after rollover day of the month - CRM-10585
// If so, set fixed_period_rollover TRUE so we increment end_date month below.
$dateParts = explode('-', $actualStartDate);
- if ($dateParts[2] >= $membershipTypeDetails['fixed_period_rollover_day']){
+ if ($dateParts[2] >= $membershipTypeDetails['fixed_period_rollover_day']) {
$fixed_period_rollover = TRUE;
}
* @param integer financial type id
*/
public static function updateAllPriceFieldValue($membershipTypeId, $params) {
- if (!empty($params['minimum_fee'])){
+ if (!empty($params['minimum_fee'])) {
$amount = $params['minimum_fee'];
}
else {
* - contact_id
* - soft_credit_contact_id
*/
- public function storeContactFields($formValues){
+ public function storeContactFields($formValues) {
// in a 'standalone form' (contact id not in the url) the contact will be in the form values
if (!empty($formValues['contact_id'])) {
$this->_contactID = $formValues['contact_id'];
$this->assign('currency', $config->defaultCurrencySymbol);
$invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
- if (isset($invoicing)){
+ if (isset($invoicing)) {
$this->assign('taxTerm', CRM_Utils_Array::value('tax_term', $invoiceSettings));
}
// build price set form.
}
$priceField = CRM_Price_BAO_PriceField::create($fieldParams);
}
- elseif (!$priceSetID){
+ elseif (!$priceSetID) {
$deletePriceSet = 1;
}
}
//assign contribution contact id to the field expected by recordMembershipContribution
- if ($this->_contributorContactID != $this->_contactID){
+ if ($this->_contributorContactID != $this->_contactID) {
$formValues['contribution_contact_id'] = $this->_contributorContactID;
- if (!empty($this->_params['soft_credit_type_id'])){
+ if (!empty($this->_params['soft_credit_type_id'])) {
$formValues['soft_credit'] = array(
'soft_credit_type_id' => $this->_params['soft_credit_type_id'],
'contact_id' => $this->_contactID,
$dat = ($dat < 10) ? '0' . $dat : $dat;
$params[$per] = $mon . $dat;
}
- else if($per == 'fixed_period_rollover_day' && !empty($params['month_fixed_period_rollover_day'])){
+ else if($per == 'fixed_period_rollover_day' && !empty($params['month_fixed_period_rollover_day'])) {
$params['fixed_period_rollover_day'] = $params['month_fixed_period_rollover_day']['d'];
unset($params['month_fixed_period_rollover_day']);
}
unset(self::$_tasks[1]);
}
//CRM-12920 - check for edit permission
- if (!CRM_Core_Permission::check('edit memberships') ){
+ if (!CRM_Core_Permission::check('edit memberships') ) {
unset(self::$_tasks[5]);
}
}
$taxAmount = CRM_Contribute_BAO_Contribution_Utils::calculateTaxAmount($customOption[$id]['amount'], $customOption[$id]['tax_rate']);
$customOption[$id]['tax_amount'] = $taxAmount['tax_amount'];
}
- if (!empty($values['financial_type_id'])){
+ if (!empty($values['financial_type_id'])) {
$customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
}
// update enable/disable links depending on price_field properties.
// pass record id param to view url for multi record view
if ($multiRecordTableId && $newLinks) {
- if ($result->$multiRecordTableId){
+ if ($result->$multiRecordTableId) {
if ($newLinks[CRM_Core_Action::VIEW]['url'] == 'civicrm/profile/view') {
$newLinks[CRM_Core_Action::VIEW]['qs'] .= "&multiRecord=view&recordId=%%recordId%%&allFields=1";
$params['recordId'] = $result->$multiRecordTableId;
*
* @code
* $errorContainer = new CRM_Queue_ErrorPolicy();
- * $errorContainer->call(function(){
+ * $errorContainer->call(function() {
* ...include some files, do some work, etc...
* });
* @endcode
$instanceID = $form->getVar('_id');
$navigationDefaults = array();
- if (!isset($defaults['permission'])){
+ if (!isset($defaults['permission'])) {
$permissions = array_flip(CRM_Core_Permission::basicPermissions( ));
$defaults['permission'] = $permissions['CiviReport: access CiviReport'];
}
if (!empty($params['is_navigation'])) {
$params['navigation'] = $form->_navigation;
}
- elseif ($instanceID){
+ elseif ($instanceID) {
//delete navigation if exists
$navId = CRM_Core_DAO::getFieldValue('CRM_Report_DAO_ReportInstance', $instanceID, 'navigation_id', 'id');
if ($navId) {
class CRM_SMS_Page_Callback
{
- public function run(){
+ public function run() {
$provider = CRM_SMS_Provider::singleton($_REQUEST);
- if (array_key_exists('status',$_REQUEST)){
+ if (array_key_exists('status',$_REQUEST)) {
$provider->callback();
}
else {
$loaded = TRUE;
CRM_Core_Resources::singleton()
- ->addSettingsFactory(function(){
+ ->addSettingsFactory(function() {
return array(
'PseudoConstant' => array(
'locationType' => CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'),
$postUpgradeMessage .= '<br /><br /><strong>' . ts('Your database contains %1 financial transaction records with no payment instrument (Paid By is empty). If you use the Accounting Batches feature this may result in unbalanced transactions. If you do not use this feature, you can ignore the condition (although you will be required to select a Paid By value for new transactions). <a href="%2" target="_blank">You can review steps to correct transactions with missing payment instruments on the wiki.</a>', array(1 => $dao->N, 2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Transactions+Missing+a+Payment+Instrument+-+4.4.3+Upgrades')) . '</strong>';
}
}
- if ($rev == '4.4.6'){
+ if ($rev == '4.4.6') {
$postUpgradeMessage .= '<br /><br /><strong>'. ts('Your contact image urls have been upgraded. If your contact image urls did not follow the standard format for image Urls they have not been upgraded. Please check the log to see image urls that were not upgraded.');
}
}
/**
* @param $rev
*/
- public function upgrade_4_4_6($rev){
+ public function upgrade_4_4_6($rev) {
$sql = "SELECT count(*) AS count FROM INFORMATION_SCHEMA.STATISTICS where ".
"TABLE_SCHEMA = database() AND INDEX_NAME = 'index_image_url' AND TABLE_NAME = 'civicrm_contact';";
$dao = CRM_Core_DAO::executeQuery($sql);
$this->addTask(ts('Update saved search information'), 'changeSavedSearch');
}
- public static function upgradeImageUrls(CRM_Queue_TaskContext $ctx, $startId, $endId){
+ public static function upgradeImageUrls(CRM_Queue_TaskContext $ctx, $startId, $endId) {
$dao = self::findContactImageUrls($startId, $endId);
$failures = array();
- while ($dao->fetch()){
+ while ($dao->fetch()) {
$imageURL = $dao->image_url;
$baseurl = CIVICRM_UF_BASEURL;
$baselen = strlen($baseurl);
- if (substr($imageURL, 0, $baselen) == $baseurl){
+ if (substr($imageURL, 0, $baselen) == $baseurl) {
$photo = basename($dao->image_url);
$config = CRM_Core_Config::singleton();
$fullpath = $config->customFileUploadDir.$photo;
- if (file_exists($fullpath)){
+ if (file_exists($fullpath)) {
// For anyone who upgraded 4.4.6 release (eg 4.4.0=>4.4.6), the $newImageUrl incorrectly used backend URLs.
// For anyone who skipped 4.4.6 (eg 4.4.0=>4.4.7), the $newImageUrl correctly uses frontend URLs
self::setContactImageUrl($dao->id,
";
$params = array(1 => array($dbUf['database'], 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, FALSE);
- foreach ($tables as $columnName => $value){
+ foreach ($tables as $columnName => $value) {
if ($value['tableName'] == 'civicrm_membership_type' || $value['tableName'] == 'civicrm_contribution_recur') {
$foreignKeyExists = CRM_Core_DAO::checkConstraintExists($value['tableName'], $value['fkey']);
$fKey = $value['fkey'];
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
if ($rev == '4.2.alpha1') {
$tables = array('civicrm_contribution_page', 'civicrm_event', 'civicrm_group', 'civicrm_contact');
- if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)){
+ if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)) {
$errors = ts("The upgrade has identified some schema integrity issues in the database. It seems some of your constraints are missing. You will have to rebuild your schema before re-trying the upgrade. Please refer to %1.", array(1 => CRM_Utils_System::docURL2("Ensuring Schema Integrity on Upgrades", FALSE, "Ensuring Schema Integrity on Upgrades", NULL, NULL, "wiki")));
CRM_Core_Error::fatal($errors);
return FALSE;
'civicrm_event' => 'FK_civicrm_event_payment_processor_id',
'civicrm_group' => 'FK_civicrm_group_saved_search_id',
);
- foreach ($tables as $tableName => $fKey){
+ foreach ($tables as $tableName => $fKey) {
$foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName, $fKey);
- if ($foreignKeyExists){
+ if ($foreignKeyExists) {
CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP FOREIGN KEY {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP INDEX {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
}
}
}
- public function convertContribution(){
+ public function convertContribution() {
$minContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
$maxContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
for ($startId = $minContributionId; $startId <= $maxContributionId; $startId += self::BATCH_SIZE) {
//CRM-12273
//check if price_set_id is exist, if not use the default contribution amount
- if (isset($result->price_set_id)){
+ if (isset($result->price_set_id)) {
$priceSetId = $result->price_set_id;
}
else{
$defaultPriceSets = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
foreach ($defaultPriceSets as $key => $pSet) {
- if ($pSet['name'] == 'contribution_amount'){
+ if ($pSet['name'] == 'contribution_amount') {
$priceSetId = $pSet['setID'];
}
}
continue;
}
- if ($name == 'phone_ext'){
+ if ($name == 'phone_ext') {
$block = 'Phone';
}
$pdf = new TCPDF($orientation, 'pt', $paper_size_arr);
$pdf->Open();
- if (is_readable($stationery_path)){
+ if (is_readable($stationery_path)) {
$pdf->SetStationery( $stationery_path );
}
$tpl = 'CRM/'.$entity.'/Page/Inline/'.$tplfile.'.tpl';
$smarty = CRM_Core_Smarty::singleton( );
CRM_Utils_System::setTitle( "$entity::$tplfile inline $tpl" );
- if (!$smarty->template_exists($tpl) ){
+ if (!$smarty->template_exists($tpl) ) {
header("Status: 404 Not Found");
die ("Can't find the requested template file templates/$tpl");
}
public function authenticate($name, $pass, $loadCMSBootstrap = FALSE) {
require_once str_replace('_', DIRECTORY_SEPARATOR, $this->ufClass) . '.php';
- if ($this->ufClass == 'CRM_Utils_System_Joomla'){
+ if ($this->ufClass == 'CRM_Utils_System_Joomla') {
$loadCMSBootstrap = TRUE;
}
*
* FIXME: Document values accepted/required by $params
*/
- public function userLoginFinalize($params = array()){
+ public function userLoginFinalize($params = array()) {
}
/**
* Set timezone in mysql so that timestamp fields show the correct time
*/
- public function setMySQLTimeZone(){
+ public function setMySQLTimeZone() {
$timeZoneOffset = $this->getTimeZoneOffset();
- if ($timeZoneOffset){
+ if ($timeZoneOffset) {
$sql = "SET time_zone = '$timeZoneOffset'";
CRM_Core_DAO::executequery($sql);
}
*
* @return string|false|null
*/
- public function getTimeZoneOffset(){
+ public function getTimeZoneOffset() {
$timezone = $this->getTimeZoneString();
if ($timezone) {
$tzObj = new DateTimeZone($timezone);
$form_state['input']['pass'] = array('pass1' => $params['cms_pass'], 'pass2' => $params['cms_pass']);
}
- if (!empty($params['notify'])){
+ if (!empty($params['notify'])) {
$form_state['input']['notify'] = $params['notify'];
}
*
* FIXME: Document values accepted/required by $params
*/
- public function userLoginFinalize($params = array()){
+ public function userLoginFinalize($params = array()) {
user_login_finalize($params);
}
* @param int $drupalID
* Drupal User ID.
*/
- public function og_membership_create($ogID, $drupalID){
+ public function og_membership_create($ogID, $drupalID) {
if (function_exists('og_entity_query_alter')) {
// sort-of-randomly chose a function that only exists in the // 7.x-2.x branch
//
* @param int $drupalID
* Drupal User ID.
*/
- public function og_membership_create($ogID, $drupalID){
+ public function og_membership_create($ogID, $drupalID) {
og_save_subscription( $ogID, $drupalID, array( 'is_active' => 1 ) );
}
* - $siteName,
* - $siteRoot
*/
- public function getDefaultSiteSettings($dir){
+ public function getDefaultSiteSettings($dir) {
$config = CRM_Core_Config::singleton();
$siteName = $siteRoot = NULL;
$matches = array();
* FIXME: Document values accepted/required by $params
*
*/
- public function userLoginFinalize($params = array()){
+ public function userLoginFinalize($params = array()) {
user_login_finalize($params);
}
* - $siteName,
* - $siteRoot
*/
- public function getDefaultSiteSettings($dir){
+ public function getDefaultSiteSettings($dir) {
$config = CRM_Core_Config::singleton();
$url = preg_replace(
'|/administrator|',
function civicrm_api3($entity, $action, $params = array()) {
$params['version'] = 3;
$result = civicrm_api($entity, $action, $params);
- if (is_array($result) && !empty($result['is_error'])){
+ if (is_array($result) && !empty($result['is_error'])) {
throw new CiviCRM_API3_Exception($result['error_message'], CRM_Utils_Array::value('error_code', $result, 'undefined'), $result);
}
return $result;
* DAO being passed in.
* @return string
*/
-function _civicrm_api_get_entity_name_from_dao($bao){
+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));
}
}
else{
$values = call_user_func(array('CRM_Utils_PseudoConstant', 'getConstant'), $name);
- if (!empty($values)){
+ if (!empty($values)) {
return civicrm_api3_create_success($values, $params, 'constant');
}
}
* 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){
+function _civicrm_api3_contribution_create_legacy_support_45(&$params) {
//legacy soft credit handling - recommended approach is chaining
- if (!empty($params['soft_credit_to'])){
+ if (!empty($params['soft_credit_to'])) {
$params['soft_credit'][] = array(
'contact_id' => $params['soft_credit_to'],
'amount' => $params['total_amount'],
'soft_credit_type_id' => CRM_Core_OptionGroup::getDefaultValue("soft_credit_type")
);
}
- if (!empty($params['honor_contact_id'])){
+ if (!empty($params['honor_contact_id'])) {
$params['soft_credit'][] = array(
'contact_id' => $params['honor_contact_id'],
'amount' => $params['total_amount'],
$contribution_details = $query->store($dao);
$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'])){
+ if (isset($contribution[$dao->contribution_id]['financial_type_id'])) {
$contribution[$dao->contribution_id]['financial_type_id'] = $contribution[$dao->contribution_id]['financial_type_id'];
}
// format soft credit for backward compatibility
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $params['id'];
$contribution->find(TRUE);
- if (!$contribution->id == $params['id']){
+ if (!$contribution->id == $params['id']) {
throw new API_Exception('A valid contribution ID is required', 'invalid_data');
}
try {
- if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)){
+ if (!$contribution->loadRelatedObjects($input, $ids, FALSE, TRUE)) {
throw new API_Exception('failed to load related objects');
}
elseif ($contribution->contribution_status_id == CRM_Core_OptionGroup::getValue('contribution_status', 'Completed', 'name')) {
$input['is_test'] = $contribution->is_test;
$input['trxn_id'] = !empty($params['trxn_id']) ? $params['trxn_id'] : $contribution->trxn_id;
$input['amount'] = $contribution->total_amount;
- if (isset($params['is_email_receipt'])){
+ if (isset($params['is_email_receipt'])) {
$input['is_email_receipt'] = $params['is_email_receipt'];
}
// @todo required for base ipn but problematic as api layer handles this
/**
* Flush static caches in functions that might have stored available custom fields
*/
-function _civicrm_api3_custom_field_flush_static_caches(){
+function _civicrm_api3_custom_field_flush_static_caches() {
civicrm_api('custom_field', 'getfields', array('version' => 3, 'cache_clear' => 1));
CRM_Core_BAO_UFField::getAvailableFieldsFlat(TRUE);
}
$domains = _civicrm_api3_dao_to_array($bao, $params, TRUE, 'domain');
foreach ($domains as $domain) {
- if (!empty($domain['contact_id'])){
+ if (!empty($domain['contact_id'])) {
$values = array();
$locparams = array(
'contact_id' => $domain['contact_id']
* the core code or schema - this means we have to provide support for api calls (where possible)
* across schema changes.
*/
-function _civicrm_api3_event_create_legacy_support_42(&$params){
- if (!empty($params['payment_processor_id'])){
+function _civicrm_api3_event_create_legacy_support_42(&$params) {
+ if (!empty($params['payment_processor_id'])) {
$params['payment_processor'] = CRM_Core_DAO::VALUE_SEPARATOR . $params['payment_processor_id'] . CRM_Core_DAO::VALUE_SEPARATOR;
}
}
* the core code or schema - this means we have to provide support for api calls (where possible)
* across schema changes.
*/
-function _civicrm_api3_event_get_legacy_support_42(&$event, $event_id){
- if (!empty($event[$event_id]['payment_processor'])){
+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']);
- if (count($processors) == 3 ){
+ if (count($processors) == 3 ) {
$event[$event_id]['payment_processor_id'] = $processors[1];
}
}
$results = array();
// we will also clear pseudoconstants here - should potentially be moved to relevant BAO classes
CRM_Core_PseudoConstant::flush();
- if (!empty($apiRequest['params']['fieldname'])){
+ if (!empty($apiRequest['params']['fieldname'])) {
CRM_Utils_PseudoConstant::flushConstant($apiRequest['params']['fieldname']);
}
- if (!empty($apiRequest['params']['option_group_id'])){
+ if (!empty($apiRequest['params']['option_group_id'])) {
$optionGroupName = civicrm_api('option_group', 'getvalue', array('version' => 3, 'id' => $apiRequest['params']['option_group_id'], 'return' => 'name') );
- if (is_string($optionGroupName)){
+ if (is_string($optionGroupName)) {
CRM_Utils_PseudoConstant::flushConstant(_civicrm_api_get_camel_name($optionGroupName));
}
}
case 'getsingle':
case 'getcount':
$metadata = _civicrm_api_get_fields($apiRequest['entity'], $unique, $apiRequest['params']);
- if (empty($metadata['id'])){
+ if (empty($metadata['id'])) {
// if id is not set we will set it eg. 'id' from 'case_id', case_id will be an alias
if (!empty($metadata[strtolower($apiRequest['entity']) . '_id'])) {
$metadata['id'] = $metadata[$lcase_entity . '_id'];
* @param array $fieldsToResolve
* Anny field resolutions specifically requested.
*/
-function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fieldname, $fieldSpec, $fieldsToResolve){
+function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fieldname, $fieldSpec, $fieldsToResolve) {
if (empty($fieldSpec['pseudoconstant']) && empty($fieldSpec['option_group_id'])) {
return;
}
// @fixme
// tests show that contribution works better with create
// this is horrible but to make it work we'll just handle it separately
- if (strtolower($apiRequest['entity']) == 'contribution'){
+ if (strtolower($apiRequest['entity']) == 'contribution') {
return civicrm_api($apiRequest['entity'], 'create', $apiRequest['params']);
}
$seek = array($key_id => $apiRequest['params'][$key_id], 'version' => $apiRequest['version']);
* @param bool $count
* @throws Exception
*/
-function _civicrm_api3_mailing_contact_getresults($params, $count){
- if (empty($params['type'])){
+function _civicrm_api3_mailing_contact_getresults($params, $count) {
+ if (empty($params['type'])) {
//ie. because the api is an anomoly & passing in id is not valid
throw new Exception('This api call does not accept api as a parameter');
}
function civicrm_api3_option_value_delete($params) {
// we will get the option group id before deleting so we can flush pseudoconstants
$optionGroupID = civicrm_api('option_value', 'getvalue', array('version' => 3, 'id' => $params['id'], 'return' => 'option_group_id'));
- if (CRM_Core_BAO_OptionValue::del((int) $params['id'])){
+ if (CRM_Core_BAO_OptionValue::del((int) $params['id'])) {
civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1, 'option_group_id' => $optionGroupID));
return civicrm_api3_create_success();
}
$participantBAO = CRM_Event_BAO_Participant::create($params);
- if (empty($params['price_set_id']) && empty($params['id']) && !empty($params['fee_level'])){
+ if (empty($params['price_set_id']) && empty($params['id']) && !empty($params['fee_level'])) {
_civicrm_api3_participant_createlineitem($params, $participantBAO);
}
_civicrm_api3_object_to_array($participantBAO, $participant[$participantBAO->id]);
/**
* Create a default participant line item
*/
-function _civicrm_api3_participant_createlineitem(&$params, $participant){
+function _civicrm_api3_participant_createlineitem(&$params, $participant) {
// it is possible that a fee level contains information about multiple
// price field values.
}
$dao = CRM_Pledge_BAO_PledgePayment::add($paymentParams);
- if (empty($dao->pledge_id)){
+ if (empty($dao->pledge_id)) {
$dao->find(TRUE);
}
_civicrm_api3_object_to_array($dao, $result[$dao->id]);
*/
function civicrm_api3_price_field_value_create($params) {
$ids = array();
- if (!empty($params['id'])){
+ if (!empty($params['id'])) {
$ids['id'] = $params['id'];
}
}
elseif(!empty($params['contact_id'])) {
$ufGroupBAO->setProfileDefaults($params['contact_id'], $profileFields, $values[$profileID], TRUE);
- foreach ($values[$profileID] as $fieldName => $field){
+ 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
$values[$profileID][strtolower($fieldName)] = $field;
*
* @return string BAO Field Name
*/
-function _civicrm_api3_profile_translate_fieldnames_for_bao($fieldName){
+function _civicrm_api3_profile_translate_fieldnames_for_bao($fieldName) {
$fieldName = str_replace('url', 'URL', $fieldName);
return str_replace('primary', 'Primary', $fieldName);
}
*/
function civicrm_api3_setting_getfields($params) {
- if (!empty($params['action']) && strtolower($params['action']) == 'getvalue'){
+ if (!empty($params['action']) && strtolower($params['action']) == 'getvalue') {
$result = array(
'name' => array(
'title' => 'name of setting field',
);
return civicrm_api3_create_success($result, $params, 'setting', 'getfields');
}
- if (!empty($params['name'])){
+ if (!empty($params['name'])) {
//am of two minds about special handling for 'name' as opposed to other filters - but is does make most common
//usage really easy
$params['filters']['name'] = $params['name'];
CRM_Utils_Array::value('profile', $params, NULL)
);
// find any supplemental information
- if (!empty($params['action'])){
+ if (!empty($params['action'])) {
$specFunction = '_civicrm_api3_setting_' . strtolower($params['action']) . '_spec';
if (function_exists($specFunction)) {
$specFunction($result);
* as we will be creating the option for a function rather than an value to be in the defaults
* Note that is not in place as yet
*/
-function civicrm_api3_setting_getdefaults(&$params){
+function civicrm_api3_setting_getdefaults(&$params) {
$settings = civicrm_api3('setting', 'getfields', $params);
$domains = _civicrm_api3_setting_getDomainArray($params);
$defaults = array();
- foreach ($domains as $domainID){
+ foreach ($domains as $domainID) {
$defaults[$domainID] = array();
$noDefaults = array();
- foreach ($settings['values'] as $setting => $spec){
- if (array_key_exists('default', $spec) && !is_null($spec['default'])){
+ foreach ($settings['values'] as $setting => $spec) {
+ if (array_key_exists('default', $spec) && !is_null($spec['default'])) {
$defaults[$domainID][$setting] = $spec['default'];
}
else{
$noDefaults[$setting] = 1;
}
}
- if (!empty($params['debug'])){
+ if (!empty($params['debug'])) {
// we are only tracking 'noDefaults' to help us check the xml
print_r($noDefaults);
}
/**
* Revert settings to defaults
*/
-function civicrm_api3_setting_revert(&$params){
+function civicrm_api3_setting_revert(&$params) {
$defaults = civicrm_api('setting', 'getdefaults', $params);
$fields = civicrm_api('setting', 'getfields', $params);
$fields = $fields['values'];
$domains = _civicrm_api3_setting_getDomainArray($params);
$result = array();
- foreach ($domains as $domainID){
+ foreach ($domains as $domainID) {
$valuesToRevert = array_intersect_key($defaults['values'][$domainID], $fields);
- if (!empty($valuesToRevert)){
+ if (!empty($valuesToRevert)) {
$valuesToRevert['version'] = $params['version'];
$valuesToRevert['domain_id'] = $domainID;
// note that I haven't looked at how the result would appear with multiple domains in play
/**
* Revert settings to defaults
*/
-function civicrm_api3_setting_fill(&$params){
+function civicrm_api3_setting_fill(&$params) {
$defaults = civicrm_api3('setting', 'getdefaults', $params);
$domains = _civicrm_api3_setting_getDomainArray($params);
$result = array();
- foreach ($domains as $domainID){
+ foreach ($domains as $domainID) {
$apiArray = array(
'version' => $params['version'],
'domain_id' => $domainID
);
$existing = civicrm_api3('setting', 'get', $apiArray);
$valuesToFill = array_diff_key($defaults['values'][$domainID], $existing['values'][$domainID]);
- if (!empty($valuesToFill)){
+ if (!empty($valuesToFill)) {
$result = array_merge($result, civicrm_api('setting', 'create', $valuesToFill + $apiArray));
}
}
*/
function civicrm_api3_setting_getvalue($params) {
$config = CRM_Core_Config::singleton();
- if (isset($config->$params['name'])){
+ if (isset($config->$params['name'])) {
return $config->$params['name'];
}
return CRM_Core_BAO_Setting::getItem(
* using crm-editable will pass an id & default won't be applied
* we did talk about id being a pseudonym for domain_id in this api so applying it here
*/
-function _civicrm_api3_setting_getDomainArray(&$params){
- if (empty($params['domain_id']) && isset($params['id'])){
+function _civicrm_api3_setting_getDomainArray(&$params) {
+ if (empty($params['domain_id']) && isset($params['id'])) {
$params['domain_id'] = $params['id'];
}
- if ($params['domain_id'] == 'current_domain'){
+ if ($params['domain_id'] == 'current_domain') {
$params['domain_id'] = CRM_Core_Config::domainID();
}
- if ($params['domain_id'] == 'all'){
+ if ($params['domain_id'] == 'all') {
$domainAPIResult = civicrm_api('domain', 'get', array('version' => 3, 'return' => 'id'));
if (isset($domainAPIResult['values'])) {
$params['domain_id'] = array_keys($domainAPIResult['values']);
throw new Exception('All domains not retrieved - problem with Domain Get api call ' . $domainAPIResult['error_message']);
}
}
- if (is_array($params['domain_id'])){
+ if (is_array($params['domain_id'])) {
$domains = $params['domain_id'];
}
else{
* @param array $params
* Array or parameters determined by getfields.
*/
-function _civicrm_api3_system_flush_spec(&$params){
+function _civicrm_api3_system_flush_spec(&$params) {
$params['triggers'] = array('title' => 'rebuild triggers (boolean)');
$params['session'] = array('title' => 'refresh sessions (boolean)');
}
if (empty($item['id']) && !empty($item[$entity . "_id"])) {
$values[$key]['id'] = $item[$entity . "_id"];
}
- if (!empty($item['financial_type_id'])){
+ if (!empty($item['financial_type_id'])) {
//4.3 legacy handling
$values[$key]['contribution_type_id'] = $item['financial_type_id'];
}
- if (!empty($item['next_sched_contribution_date'])){
+ if (!empty($item['next_sched_contribution_date'])) {
// 4.4 legacy handling
$values[$key]['next_sched_contribution'] = $item['next_sched_contribution_date'];
}
* @param array $params
* @param array $values
*/
-function _civicrm_api3_filter_fields_for_bao($entity, &$params, &$values){
+function _civicrm_api3_filter_fields_for_bao($entity, &$params, &$values) {
$fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'create'));
$fields = $fields['values'];
_civicrm_api3_store_values($fields, $params, $values);
*
* @return
*/
-function _civicrm_api3_get_using_query_object($entity, $params, $additional_options = array(), $getCount = NULL){
+function _civicrm_api3_get_using_query_object($entity, $params, $additional_options = array(), $getCount = NULL) {
// Convert id to e.g. contact_id
if (empty($params[$entity . '_id']) && isset($params['id'])) {
CRM_Utils_Array::value('return', $options, array()),
CRM_Utils_Array::value('return', $additional_options, array())
);
- if (empty($returnProperties)){
+ if (empty($returnProperties)) {
$returnProperties = NULL;
}
- if (!empty($params['check_permissions'])){
+ if (!empty($params['check_permissions'])) {
// we will filter query object against getfields
$fields = civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'get'));
// we need to add this in as earlier in this function 'id' was unset in favour of $entity_id
$fields['values'][$entity . '_id'] = array();
$varsToFilter = array('returnProperties', 'inputParams');
- foreach ($varsToFilter as $varToFilter){
- if (!is_array($$varToFilter)){
+ foreach ($varsToFilter as $varToFilter) {
+ if (!is_array($$varToFilter)) {
continue;
}
//I was going to throw an exception rather than silently filter out - but
$limit = CRM_Utils_Array::value('limit', $options, NULL);
$smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params);
- if ($getCount){
+ if ($getCount) {
$limit = NULL;
$returnProperties = NULL;
}
$unmatchedFields,
array_flip($allfields)// but a match for the field keys
);
- foreach ($returnUniqueMatched as $uniqueVal){
+ foreach ($returnUniqueMatched as $uniqueVal) {
$dao->selectAdd($allfields[$uniqueVal]);
}
}
$fieldName = substr($filterField, 0, -4);
$dao->whereAdd("($fieldName >= $filterValue )");
}
- if ($filterField == 'is_current' && $filterValue == 1){
+ if ($filterField == 'is_current' && $filterValue == 1) {
$todayStart = date('Ymd000000', strtotime('now'));
$todayEnd = date('Ymd235959', strtotime('now'));
$dao->whereAdd("(start_date <= '$todayStart' OR start_date IS NULL) AND (end_date >= '$todayEnd' OR end_date IS NULL)");
- if (property_exists($dao, 'is_active')){
+ if (property_exists($dao, 'is_active')) {
$dao->whereAdd('is_active = 1');
}
}
$returnProperties[$entity . '_id'] = 1;
unset($returnProperties['id']);
}
- switch (trim(strtolower($sort))){
+ switch (trim(strtolower($sort))) {
case 'id':
case 'id desc':
case 'id asc':
function _civicrm_api3_build_fields_array(&$bao, $unique = TRUE) {
$fields = $bao->fields();
if ($unique) {
- if (empty($fields['id'])){
+ if (empty($fields['id'])) {
$entity = _civicrm_api_get_entity_name_from_dao($bao);
$fields['id'] = $fields[$entity . '_id'];
unset($fields[$entity . '_id']);
// Check our field length
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'])
);
function _civicrm_api3_validate_string(&$params, &$fieldName, &$fieldInfo, $entity) {
// If fieldname exists in params
$value = CRM_Utils_Array::value($fieldName, $params, '');
- if (!is_array($value)){
+ if (!is_array($value)) {
$value = (string) $value;
}
else{
* fully but the calls to the POST happen in more than one function
* keeping this as good example of data to bring back to life later
- public function testMainFunctionActions(){
+ public function testMainFunctionActions() {
$ids = $objects = array( );
$input['component'] = 'Contribute';
$postedParams = array(
'
public function whits() {
for (a in b) {
- mitts("wallaby", function(zoo){
+ mitts("wallaby", function(zoo) {
alert(zoo + ts("Hello"))
});
}
$backtrace = debug_backtrace();
$dir_name = dirname( __FILE__ );
$cwd_len = strlen( $dir_name ) + 1;
- foreach ($backtrace as $frame ){
+ foreach ($backtrace as $frame ) {
echo " ";
if ( array_key_exists( 'class', $frame ) ) {
echo " class {$frame['class']}";
$this->verifyText("xpath=//div[@id='custom-set-content-{$customFieldsetId}']/div/div[2]/div[2]", '12,345,678.98');
}
- public function testCustomDataChangeLog(){
+ public function testCustomDataChangeLog() {
$this->webtestLogin();
//enable logging
$this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[3]/div[2][contains(text(), '9876543210')]"));
}
- public function testBatchMerge(){
+ public function testBatchMerge() {
$this->webtestLogin();
// add contact1 and its duplicate
}
- public function testIndividualSearchPage(){
+ public function testIndividualSearchPage() {
$this->webtestLogin();
$this->openCiviPage("contribute/search", "reset=1");
parent::setUp();
}
- public function testPrefixGenderSuffix(){
+ public function testPrefixGenderSuffix() {
$this->webtestLogin();
// Create new group
*
* @return array|int
*/
- public function getOptionLabel($optionGroupName, $optionValue){
+ public function getOptionLabel($optionGroupName, $optionValue) {
$params = array(
'version' => 3,
'sequential' => 1,
$this->click("css=ul.ui-autocomplete li");
$this->waitForPageToLoad($this->getTimeoutMsec());
- foreach ($customDataParams['customFields'] as $key => $value){
+ foreach ($customDataParams['customFields'] as $key => $value) {
$this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-summary-row']/div[@class='crm-label'][contains(text(), '$key')]"));
$this->assertElementContainsText('address-block-1', "$value");
}
'state' => 'State',
'country' => 'Country',
);
- foreach ($customDataParams['headers'] as $key => $value){
+ foreach ($customDataParams['headers'] as $key => $value) {
$headers[$key] = $value;
}
*
* @return array
*/
- public function _createMultipleValueCustomField($customFieldName, $type){
+ public function _createMultipleValueCustomField($customFieldName, $type) {
$this->type('label', $customFieldName);
$this->select("data_type[0]", "value=0");
$this->select("data_type[1]", "value=".$type);
),
);
$i = 2;
- foreach ($options as $index => $values){
+ foreach ($options as $index => $values) {
$this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}");
// Because it tends to cause problems, all uses of sleep() must be justified in comments
// Sleep should never be used for wait for anything to load from the server
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input", $values['membership_num_terms']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input", $values['label']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input", $values['amount']);
- if ($i > 3){
+ if ($i > 3) {
$this->click('link=another choice');
}
$i++;
* @param $memTypeTitle1
* @param $term
*/
- public function _testMultilpeTermsMembershipRegistration($sid, $contactParams, $memTypeTitle1, $term){
+ public function _testMultilpeTermsMembershipRegistration($sid, $contactParams, $memTypeTitle1, $term) {
//build the membership dates.
require_once 'CRM/Core/Config.php';
require_once 'CRM/Utils/Array.php';
);
$i = 2;
- foreach ($options as $index => $values){
+ foreach ($options as $index => $values) {
$this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}");
$this->waitForElementPresent("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input");
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input", $values['membership_num_terms']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input", $values['label']);
$this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[6]/input", $values['amount']);
- if ($i > 3){
+ if ($i > 3) {
$this->click('link=another choice');
}
$i++;
* @param $term
* @param bool $renew
*/
- public function _testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, $term, $renew = FALSE){
- if ($renew){
+ public function _testMultilpeTermsMembershipRegistration($pageId, $contactParams, $memTypeTitle1, $term, $renew = FALSE) {
+ if ($renew) {
$this->openCiviPage('member/search', 'reset=1', 'member_end_date_high');
$this->type("sort_name", "{$contactParams['first_name']} {$contactParams['last_name']}");
$this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr");
$apiStdFunctions = $this->getAllAPIStdFunctions();
$this->assertGreaterThan(1, count($apiStdFunctions),"something has gone wrong getting the std functions in line " . __LINE__);
$params = 'string';
- foreach ($apiStdFunctions as $key => $function){
+ foreach ($apiStdFunctions as $key => $function) {
if ( in_array( $function, $this->_skipFunctionList ) ) {
continue;
}
try{
$result = civicrm_api3('contact', 'get', array());
}
- catch (CRM_Exception $e){
+ catch (CRM_Exception $e) {
$this->fail("This should have been a success test");
}
$this->assertTrue(is_array($result));
/**
* Test exception is thrown
*/
- public function testv3WrapperException(){
+ public function testv3WrapperException() {
try{
$result = civicrm_api3('contact', 'create', array('debug' => 1));
}
- catch (CiviCRM_API3_Exception $e){
+ catch (CiviCRM_API3_Exception $e) {
$this->assertEquals('mandatory_missing', $e->getErrorCode());
$this->assertEquals('Mandatory key(s) missing from params array: contact_type', $e->getMessage());
$extra = $e->getExtraParams();
/**
* Test custom field get works & return param works
*/
- public function testCustomFieldGetReturnOptions(){
+ public function testCustomFieldGetReturnOptions() {
$customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group'));
$customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id']));
/**
* Test custom field get works & return param works
*/
- public function testCustomFieldGetReturnArray(){
+ public function testCustomFieldGetReturnArray() {
$customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group'));
$customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id']));
/**
* Test custom field get works & return param works
*/
- public function testCustomFieldGetReturnTwoOptions(){
+ public function testCustomFieldGetReturnTwoOptions() {
$customGroup = $this->customGroupCreate(array('extends' => 'Individual', 'test_group'));
$customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id']));
*/
public function testCreateGetEventLegacyContributionTypeID() {
$contributionTypeArray = array('contribution_type_id' => 3);
- if (isset($this->_params[0]['financial_type_id'])){
+ if (isset($this->_params[0]['financial_type_id'])) {
//in case someone edits $this->_params & invalidates this test :-)
unset($this->_params[0]['financial_type_id']);
}
// put stuff here that should happen before all tests in this unit
}
- public static function tearDownAfterClass(){
+ public static function tearDownAfterClass() {
$tablesToTruncate = array(
'civicrm_contact',
'civicrm_contribution',
*
* @return array
*/
- public function getKnownUnworkablesUpdateSingle($entity, $key){
+ public function getKnownUnworkablesUpdateSingle($entity, $key) {
// can't update values are values for which updates don't result in the value being changed
$knownFailures = array(
'ActionSchedule' => array(
),
),
);
- if (empty($knownFailures[$entity]) || empty($knownFailures[$entity][$key])){
+ if (empty($knownFailures[$entity]) || empty($knownFailures[$entity][$key])) {
return array();
}
return $knownFailures[$entity][$key];
$this->assertNotEmpty($baoString, $entityName);
$this->assertNotEmpty($entityName, $entityName);
$fieldsGet = $fields = $this->callAPISuccess($entityName, 'getfields', array('action' => 'get'));
- if ($entityName != 'Pledge'){
+ if ($entityName != 'Pledge') {
$fields = $this->callAPISuccess($entityName, 'getfields', array('action' => 'create'));
}
$fields = $fields['values'];
$entity[$fieldName] = 2;
}
elseif (!empty($specs['FKClassName'])) {
- if ($specs['FKClassName'] == $baoString){
+ if ($specs['FKClassName'] == $baoString) {
$entity[$fieldName] = (string) $entity2['id'];
}
else{