(NFC) Various updates for future version of civicrm/coder
authorTim Otten <totten@civicrm.org>
Fri, 5 Apr 2019 20:46:10 +0000 (13:46 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 5 Apr 2019 20:46:10 +0000 (13:46 -0700)
CRM/Core/BAO/Address.php
CRM/Core/BAO/CMSUser.php
CRM/Core/BAO/Cache.php
CRM/Core/BAO/Cache/Psr16.php
CRM/Core/BAO/CustomGroup.php
CRM/Core/BAO/Dashboard.php

index 8b574850176895c56360b4272b4152cf63d6b211..b5ec97d74863f4ae97c01a1364d571eddc120270 100644 (file)
@@ -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
index 368bcd97dee95c56e079a2950d3ba071332b53f4..36bb8bdb6f0c31741d5054a7947df32ceb5db8e2 100644 (file)
@@ -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],
index ffdcfa7b31d2adb6e521a1d3f9e79dfdd00091e3..3347f978d86e5f37d7630227a720674d04c19006 100644 (file)
@@ -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
index 986a4bcbf4b8271be9a2fdff31deb5d968255f6a..03463d473ee56df7615266d6c2ee0faae1e7de56 100644 (file)
@@ -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',
     ];
   }
 
index 8fa78cbf7ae456689cea4204ace6b719c74a73e3..01e65fc4cefd12d895d0e7b7e090ea69205abf29 100644 (file)
@@ -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\")";
   }
index 1bfd6812d2126136b8dfe7288d0913b3e6b15353..091348624bb4ac09911323501b332c6e61e84ea5 100644 (file)
@@ -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';
         }