Commit cf9ccf98 authored by totten's avatar totten

(NFC) Various updates for future version of civicrm/coder

parent 7237222f
......@@ -360,12 +360,7 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address {
);
if ($parseStreetAddress && !empty($params['street_address'])) {
foreach ([
'street_number',
'street_name',
'street_unit',
'street_number_suffix',
] as $fld) {
foreach (['street_number', 'street_name', 'street_unit', 'street_number_suffix'] as $fld) {
unset($params[$fld]);
}
// main parse string.
......@@ -494,12 +489,7 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address {
while ($address->fetch()) {
// deprecate reference.
if ($count > 1) {
foreach ([
'state',
'state_name',
'country',
'world_region',
] as $fld) {
foreach (['state', 'state_name', 'country', 'world_region'] as $fld) {
if (isset($address->$fld)) {
unset($address->$fld);
}
......@@ -733,10 +723,8 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC,
$streetAddress = trim($streetAddress);
$matches = [];
if (in_array($locale, [
'en_CA',
'fr_CA',
]) && preg_match('/^([A-Za-z0-9]+)[ ]*\-[ ]*/', $streetAddress, $matches)
if (in_array($locale, ['en_CA', 'fr_CA'])
&& preg_match('/^([A-Za-z0-9]+)[ ]*\-[ ]*/', $streetAddress, $matches)
) {
$parseFields['street_unit'] = $matches[1];
// unset from rest of street address
......
......@@ -213,7 +213,7 @@ class CRM_Core_BAO_CMSUser {
}
// now check that the cms db does not have the user name and/or email
if ($isDrupal OR $isJoomla OR $isWordPress) {
if ($isDrupal or $isJoomla or $isWordPress) {
$params = [
'name' => $fields['cms_name'],
'mail' => $fields[$emailName],
......
......@@ -45,7 +45,8 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache {
*
* @var int, number of second
*/
const DEFAULT_SESSION_TTL = 172800; // Two days: 2*24*60*60
// Two days: 2*24*60*60
const DEFAULT_SESSION_TTL = 172800;
/**
* @var array ($cacheKey => $cacheValue)
......@@ -174,7 +175,8 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache {
$table = self::getTableName();
$where = self::whereCache($group, $path, $componentID);
$dataExists = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM $table WHERE {$where}");
$now = date('Y-m-d H:i:s'); // FIXME - Use SQL NOW() or CRM_Utils_Time?
// FIXME - Use SQL NOW() or CRM_Utils_Time?
$now = date('Y-m-d H:i:s');
$dataSerialized = self::encode($data);
// This table has a wonky index, so we cannot use REPLACE or
......
......@@ -189,11 +189,21 @@ class CRM_Core_BAO_Cache_Psr16 {
'custom data',
// Universe
'dashboard', // be.chiro.civi.atomfeeds
'lineitem-editor', // biz.jmaconsulting.lineitemedit
'HRCore_Info', // civihr/uk.co.compucorp.civicrm.hrcore
'CiviCRM setting Spec', // nz.co.fuzion.entitysetting
'descendant groups for an org', // org.civicrm.multisite
// be.chiro.civi.atomfeeds
'dashboard',
// biz.jmaconsulting.lineitemedit
'lineitem-editor',
// civihr/uk.co.compucorp.civicrm.hrcore
'HRCore_Info',
// nz.co.fuzion.entitysetting
'CiviCRM setting Spec',
// org.civicrm.multisite
'descendant groups for an org',
];
}
......
......@@ -303,7 +303,8 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup {
if (self::hasCustomGroup('Activity', NULL, $activityTypeId)) {
return TRUE;
}
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE); // everything
// everything
$activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE);
$params = [
'version' => 3,
'extends' => 'Activity',
......@@ -484,7 +485,7 @@ LEFT JOIN civicrm_custom_field ON (civicrm_custom_field.custom_group_id = civicr
foreach ($subTypes as $key => $subType) {
$subTypeClauses[] = self::whereListHas("civicrm_custom_group.extends_entity_column_value", self::validateSubTypeByEntity($entityType, $subType));
}
$subTypeClause = '(' . implode(' OR ', $subTypeClauses) . ')';
$subTypeClause = '(' . implode(' OR ', $subTypeClauses) . ')';
if (!$onlySubType) {
$subTypeClause = '(' . $subTypeClause . ' OR civicrm_custom_group.extends_entity_column_value IS NULL )';
}
......@@ -716,7 +717,8 @@ ORDER BY civicrm_custom_group.weight,
* SQL condition.
*/
static private function whereListHas($column, $value, $delimiter = CRM_Core_DAO::VALUE_SEPARATOR) {
$bareValue = trim($value, $delimiter); // ?
// ?
$bareValue = trim($value, $delimiter);
$escapedValue = CRM_Utils_Type::escape("%{$delimiter}{$bareValue}{$delimiter}%", 'String', FALSE);
return "($column LIKE \"$escapedValue\")";
}
......
......@@ -181,9 +181,9 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard {
public static function initializeDashlets() {
$dashlets = [];
$getDashlets = civicrm_api3("Dashboard", "get", [
'domain_id' => CRM_Core_Config::domainID(),
'option.limit' => 0,
]);
'domain_id' => CRM_Core_Config::domainID(),
'option.limit' => 0,
]);
$contactID = CRM_Core_Session::getLoggedInContactID();
$allDashlets = CRM_Utils_Array::index(['name'], $getDashlets['values']);
$defaultDashlets = [];
......@@ -271,10 +271,8 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard {
}
// hack to handle case permissions
if (!$componentName && in_array($key, [
'access my cases and activities',
'access all cases and activities',
])
if (!$componentName
&& in_array($key, ['access my cases and activities', 'access all cases and activities'])
) {
$componentName = 'CiviCase';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment