From 33421d01345b2d4ad2c7c0253179530ef5e7b94e Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 8 Jan 2015 18:31:55 -0800 Subject: [PATCH] INFRA-132 - CRM/ - Fix misc oddball syntax --- CRM/Activity/BAO/ActivityTarget.php | 2 +- CRM/Contact/BAO/Group.php | 2 +- CRM/Contact/Form/Edit/Notes.php | 2 +- CRM/Contribute/Form/AdditionalInfo.php | 3 +- CRM/Contribute/Form/Contribution.php | 2 +- CRM/Core/BAO/Mapping.php | 2 +- CRM/Core/BAO/MessageTemplate.php | 2 +- CRM/Financial/Form/FinancialAccount.php | 2 +- CRM/Logging/Differ.php | 2 +- CRM/Upgrade/Headless.php | 1 - CRM/Upgrade/Incremental/php/FourThree.php | 73 ++++++++++++++--------- CRM/Utils/REST.php | 2 +- 12 files changed, 55 insertions(+), 40 deletions(-) diff --git a/CRM/Activity/BAO/ActivityTarget.php b/CRM/Activity/BAO/ActivityTarget.php index 97bb4ee482..dba9688d2e 100644 --- a/CRM/Activity/BAO/ActivityTarget.php +++ b/CRM/Activity/BAO/ActivityTarget.php @@ -59,7 +59,7 @@ class CRM_Activity_BAO_ActivityTarget extends CRM_Activity_DAO_ActivityContact { $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $target->copyValues($params); - $target->record_type_id = $targetID ; + $target->record_type_id = $targetID; return $target->save(); } diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 68dfe71cbd..848f5d1fa2 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -1222,7 +1222,7 @@ WHERE {$whereClause}"; if ($excludeHidden) { $clauses[] = 'groups.is_hidden = 0'; } - ; + $clauses[] = self::getPermissionClause(); diff --git a/CRM/Contact/Form/Edit/Notes.php b/CRM/Contact/Form/Edit/Notes.php index a5494df693..a827078176 100644 --- a/CRM/Contact/Form/Edit/Notes.php +++ b/CRM/Contact/Form/Edit/Notes.php @@ -32,7 +32,7 @@ * $Id$ * */ -Class CRM_Contact_Form_Edit_Notes { +class CRM_Contact_Form_Edit_Notes { /** * This function is to build form elements diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index f59759cb79..ec0dc8ef0b 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -377,8 +377,7 @@ class CRM_Contribute_Form_AdditionalInfo { $params['product_name'] = $productDAO->name; $params['product_sku'] = $productDAO->sku; - if (empty($params['product_option']) && !empty($form->_options -[$params['product_name'][0]])) { + if (empty($params['product_option']) && !empty($form->_options[$params['product_name'][0]])) { $params['product_option'] = $form->_options[$params['product_name'][0]][$params['product_name'][1]]; } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index ea33e63a00..affb8d2e2d 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1112,7 +1112,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $lineItems[$itemId]['tax_rate'] = $financialItemsId[$submittedValues['financial_type_id']]; } else { - $lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = "" ; + $lineItems[$itemId]['tax_rate'] = $lineItems[$itemId]['tax_amount'] = ""; $submittedValues['tax_amount'] = 'null'; } if ($lineItems[$itemId]['tax_rate']) { diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index 6d68b1384e..14d409a344 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -598,7 +598,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { // FIX ME: For now let's not expose custom data related to relationship $relationshipCustomFields = array(); //$relationshipCustomFields = self::getRelationTypeCustomGroupData( $id ); - //asort( $relationshipCustomFields ) ; + //asort($relationshipCustomFields); $relationshipType = new CRM_Contact_BAO_RelationshipType(); $relationshipType->id = $id; diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 121a4648e7..4786e100a7 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -508,7 +508,7 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { if (empty($params['attachments'])) { $params['attachments'] = array(); } - $params['attachments'][] = CRM_Utils_Mail::appendPDF('Invoice.pdf', $pdfHtml, $format) ; + $params['attachments'][] = CRM_Utils_Mail::appendPDF('Invoice.pdf', $pdfHtml, $format); } $pdf_filename = ''; if ($config->doNotAttachPDFReceipt && diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index fdfb277576..5226064acc 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -148,7 +148,7 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { $errorMsg['tax_rate'] = ts('Please enter value for tax rate'); } } - if ((CRM_Utils_Array::value('tax_rate', $values) != NULL)) { + if ((CRM_Utils_Array::value('tax_rate', $values) != NULL)) { if ($values['tax_rate'] < 0 || $values['tax_rate'] >= 100) { $errorMsg['tax_rate'] = ts('Tax Rate Should be between 0 - 100'); } diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 03f9a66f15..8720a276fa 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -217,7 +217,7 @@ WHERE lt.log_conn_id = %1 AND // hack: case_type_id column is a varchar with separator. For proper mapping to type labels, // we need to make sure separators are trimmed if ($diff == 'case_type_id') { - foreach (array('original', 'changed') as $var) { + foreach (array('original', 'changed') as $var) { if (!empty($$var[$diff])) { $holder =& $$var; $val = explode(CRM_Case_BAO_Case::VALUE_SEPARATOR, $holder[$diff]); diff --git a/CRM/Upgrade/Headless.php b/CRM/Upgrade/Headless.php index a56de4a8be..52db1bc9a0 100644 --- a/CRM/Upgrade/Headless.php +++ b/CRM/Upgrade/Headless.php @@ -35,7 +35,6 @@ class CRM_Upgrade_Headless { * * @param bool $enablePrint * - * @throws * @throws Exception * @return array, with keys: * - message: string, HTML-ish blob diff --git a/CRM/Upgrade/Incremental/php/FourThree.php b/CRM/Upgrade/Incremental/php/FourThree.php index f6cc5ef714..c56e650680 100644 --- a/CRM/Upgrade/Incremental/php/FourThree.php +++ b/CRM/Upgrade/Incremental/php/FourThree.php @@ -65,7 +65,10 @@ class CRM_Upgrade_Incremental_php_FourThree { $count = CRM_Core_DAO::singleValueQuery($sql, array(), TRUE, FALSE); if ($count > 0) { - $error = ts("There is a data integrity issue with this CiviCRM database. It contains %1 contribution records which are linked to contact records that have been deleted. You will need to correct this manually before you can run the upgrade. Use the following MySQL query to identify the problem records: %2 These records will need to be deleted or linked to an existing contact record.", array(1 => $count, 2 => 'SELECT ct.* FROM civicrm_contribution ct LEFT JOIN civicrm_contact c ON ct.contact_id = c.id WHERE c.id IS NULL;')); + $error = ts("There is a data integrity issue with this CiviCRM database. It contains %1 contribution records which are linked to contact records that have been deleted. You will need to correct this manually before you can run the upgrade. Use the following MySQL query to identify the problem records: %2 These records will need to be deleted or linked to an existing contact record.", array( + 1 => $count, + 2 => 'SELECT ct.* FROM civicrm_contribution ct LEFT JOIN civicrm_contact c ON ct.contact_id = c.id WHERE c.id IS NULL;', + )); CRM_Core_Error::fatal($error); return FALSE; } @@ -161,12 +164,12 @@ WHERE entity_value = '' OR entity_value IS NULL $reminder = array(); $list = ''; while ($dao->fetch()) { - $reminder[$dao->id] = $dao->title; - $list .= "
  • {$dao->title}
  • "; + $reminder[$dao->id] = $dao->title; + $list .= "
  • {$dao->title}
  • "; } if (!empty($reminder)) { $list = "
    "; - $postUpgradeMessage .= '
    ' . ts("Scheduled Reminders must be linked to one or more 'entities' (Events, Event Templates, Activity Types, Membership Types). The following reminders are not configured properly and will not be run. Please review them and update or delete them: %1", array(1 => $list)); + $postUpgradeMessage .= '
    ' . ts("Scheduled Reminders must be linked to one or more 'entities' (Events, Event Templates, Activity Types, Membership Types). The following reminders are not configured properly and will not be run. Please review them and update or delete them: %1", array(1 => $list)); } } if ($rev == '4.3.beta2') { @@ -227,7 +230,7 @@ WHERE ceft.entity_id IS NULL; } if ($rev == '4.3.4') { $postUpgradeMessage .= '
    ' . ts('System Administrator Alert: If you are running scheduled jobs using CLI.php, you will need to reconfigure cron tasks to include a password. Scheduled jobs will no longer run if the password is not provided (learn more).', - array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs')); + array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs')); } if ($rev == '4.3.5') { $postUpgradeMessage .= '
    ' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).'); @@ -238,7 +241,7 @@ INNER JOIN civicrm_product cp ON ccp.product_id = cp.id WHERE ccp.financial_type_id IS NULL and cp.cost > 0'); if ($flag) { $postUpgradeMessage .= '
    ' . ts('Your database contains one or more premiums which have a cost but are not linked to a financial type. If you are exporting transations to an accounting package, this will result in unbalanced transactions. You can review steps to correct this situation on the wiki.', - array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Issues+Caused+by+Missing+Cost+of+Goods+Account+-+4.3+Upgrades')); + array(1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Issues+Caused+by+Missing+Cost+of+Goods+Account+-+4.3+Upgrades')); } } } @@ -379,7 +382,7 @@ ADD COLUMN premiums_nothankyou_label varchar(255) COLLATE utf8_unicode_ci DEFA public function upgrade_4_3_5($rev) { // CRM-12156 $config = CRM_Core_Config::singleton(); - $dbname = DB::parseDSN($config->dsn); + $dbname = DB::parseDSN($config->dsn); $sql = "SELECT DELETE_RULE FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME = 'FK_civicrm_financial_item_contact_id' @@ -583,7 +586,7 @@ AND con.contribution_status_id = {$pendingStatus} //create a temp table to hold financial account id related to payment instruments $tempTableName1 = CRM_Core_DAO::createTempTableName(); - $sql = " + $sql = " CREATE TEMPORARY TABLE {$tempTableName1} SELECT ceft.financial_account_id financial_account_id, cov.value as instrument_id FROM civicrm_entity_financial_account ceft @@ -851,7 +854,7 @@ ALTER TABLE civicrm_domain ADD contact_id INT( 10 ) UNSIGNED NULL DEFAULT NULL C SELECT cd.id, cd.name, ce.email FROM civicrm_domain cd LEFT JOIN civicrm_loc_block clb ON clb.id = cd. loc_block_id LEFT JOIN civicrm_email ce ON ce.id = clb.email_id ; -' ; +'; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $query = " @@ -892,10 +895,22 @@ WHERE cc.contact_type = 'Organization' AND cc.organization_name = %1 $config = CRM_Core_Config::singleton(); $dbUf = DB::parseDSN($config->dsn); $tables = array( - 'autorenewal_msg_id' => array('tableName' => 'civicrm_membership_type', 'fkey' => 'FK_civicrm_membership_autorenewal_msg_id'), - 'to_account_id' => array('tableName' => 'civicrm_financial_trxn', 'constraintName' => 'civicrm_financial_trxn_ibfk_2'), - 'from_account_id' => array('tableName' => 'civicrm_financial_trxn', 'constraintName' => 'civicrm_financial_trxn_ibfk_1'), - 'contribution_type_id' => array('tableName' => 'civicrm_contribution_recur', 'fkey' => 'FK_civicrm_contribution_recur_contribution_type_id'), + 'autorenewal_msg_id' => array( + 'tableName' => 'civicrm_membership_type', + 'fkey' => 'FK_civicrm_membership_autorenewal_msg_id', + ), + 'to_account_id' => array( + 'tableName' => 'civicrm_financial_trxn', + 'constraintName' => 'civicrm_financial_trxn_ibfk_2', + ), + 'from_account_id' => array( + 'tableName' => 'civicrm_financial_trxn', + 'constraintName' => 'civicrm_financial_trxn_ibfk_1', + ), + 'contribution_type_id' => array( + 'tableName' => 'civicrm_contribution_recur', + 'fkey' => 'FK_civicrm_contribution_recur_contribution_type_id', + ), ); $query = " SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS @@ -916,7 +931,7 @@ AND TABLE_SCHEMA = %1 } if ($foreignKeyExists || $value['tableName'] == 'civicrm_financial_trxn') { if ($value['tableName'] != 'civicrm_contribution_recur' || ($value['tableName'] == 'civicrm_contribution_recur' && $dao->N)) { - $constraintName = $foreignKeyExists ? $fKey : $value['constraintName']; + $constraintName = $foreignKeyExists ? $fKey : $value['constraintName']; $query = "ALTER TABLE {$value['tableName']} DROP FOREIGN KEY {$constraintName}"; CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, FALSE); } @@ -1025,9 +1040,9 @@ ORDER BY cft.id "; while ($dao->fetch()) { if (!array_key_exists($dao->contribution_recur_id, $financialTrxn)) { $financialTrxn[$dao->contribution_recur_id] = array( - 'from_financial_account_id' => $dao->to_financial_account_id, - 'payment_processor_id' => $dao->payment_processor_id, - $dao->contribution_id => 1, + 'from_financial_account_id' => $dao->to_financial_account_id, + 'payment_processor_id' => $dao->payment_processor_id, + $dao->contribution_id => 1, ); if (!is_null($dao->from_financial_account_id)) { $sql = 'UPDATE civicrm_financial_trxn SET from_financial_account_id = NULL WHERE id = %1'; @@ -1037,10 +1052,11 @@ ORDER BY cft.id "; } elseif (!array_key_exists($dao->contribution_id, $financialTrxn[$dao->contribution_recur_id])) { if (($dao->entity_table == 'civicrm_line_item' && $dao->to_financial_account_id == $financialTrxn[$dao->contribution_recur_id]['from_financial_account_id']) - || ($dao->entity_table == 'civicrm_financial_trxn' && $dao->from_financial_account_id == $financialTrxn[$dao->contribution_recur_id]['from_financial_account_id'])) { + || ($dao->entity_table == 'civicrm_financial_trxn' && $dao->from_financial_account_id == $financialTrxn[$dao->contribution_recur_id]['from_financial_account_id']) + ) { continue; } - $subsequentPayments[$dao->contribution_recur_id][$dao->entity_table][] = $dao->financial_trxn_id; + $subsequentPayments[$dao->contribution_recur_id][$dao->entity_table][] = $dao->financial_trxn_id; } } foreach ($subsequentPayments as $key => $value) { @@ -1086,18 +1102,18 @@ ORDER BY cli.id"; while ($dao->fetch()) { if (!array_key_exists($dao->contribution_recur_id, $financialTrxn)) { $financialTrxn[$dao->contribution_recur_id] = array( - 'price_field_id' => $dao->price_field_id, - 'price_field_value_id' => $dao->price_field_value_id, - 'label' => strval($dao->label), - 'financial_account_id' => $dao->financial_account_id, - $dao->contribution_id => 1, + 'price_field_id' => $dao->price_field_id, + 'price_field_value_id' => $dao->price_field_value_id, + 'label' => strval($dao->label), + 'financial_account_id' => $dao->financial_account_id, + $dao->contribution_id => 1, ); } else { if ($dao->price_field_value_id == $financialTrxn[$dao->contribution_recur_id]['price_field_value_id']) { continue; } - $subsequentPayments[$dao->contribution_recur_id][] = $dao->line_item_id; + $subsequentPayments[$dao->contribution_recur_id][] = $dao->line_item_id; } } foreach ($subsequentPayments as $key => $value) { @@ -1112,7 +1128,7 @@ cfi.description = %5, cli.financial_type_id = %6 WHERE cfi.entity_table = 'civicrm_line_item' AND cli.entity_table = 'civicrm_contribution' AND cli.id IN (" . implode(',', $value) . ');'; - $params = array( + $params = array( 1 => array($financialTrxn[$key]['label'], 'String'), 2 => array($financialTrxn[$key]['price_field_id'], 'Integer'), 3 => array($financialTrxn[$key]['price_field_value_id'], 'Integer'), @@ -1212,7 +1228,7 @@ AND cli.entity_table = 'civicrm_contribution' AND cli.id IN (" . implode(',', $v public function task_4_3_x_checkConstraints(CRM_Queue_TaskContext $ctx) { CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_financial_account` CHANGE `contact_id` `contact_id` INT( 10 ) UNSIGNED NULL DEFAULT NULL'); $config = CRM_Core_Config::singleton(); - $dbname = DB::parseDSN($config->dsn); + $dbname = DB::parseDSN($config->dsn); $constraintArray = array( "'FK_civicrm_financial_account_contact_id'", "'FK_civicrm_financial_item_contact_id'", @@ -1234,7 +1250,8 @@ AND CONSTRAINT_SCHEMA = %1"; $onDelete = CRM_Core_DAO::executeQuery($sql, $params, TRUE, FALSE); while ($onDelete->fetch()) { if (($onDelete->TABLE_NAME != 'civicrm_financial_item' && $onDelete->DELETE_RULE != 'SET NULL') || - ($onDelete->TABLE_NAME == 'civicrm_financial_item' && $onDelete->DELETE_RULE != 'CASCADE')) { + ($onDelete->TABLE_NAME == 'civicrm_financial_item' && $onDelete->DELETE_RULE != 'CASCADE') + ) { $tableName = 'civicrm_financial_type'; $onDeleteOption = ' SET NULL '; $columnName = 'financial_type_id'; diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index a499f62e01..15ac43d4b4 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -500,7 +500,7 @@ class CRM_Utils_REST { $smarty->assign_by_ref("request", $param); if (! array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) || - $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest" ) { + $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest" ) { $smarty->assign('tplFile', $tpl); $config = CRM_Core_Config::singleton(); -- 2.25.1