CRM - Cleanup boolean expressions
authorColeman Watts <coleman@civicrm.org>
Tue, 17 Mar 2020 23:34:12 +0000 (19:34 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 19 Mar 2020 16:26:24 +0000 (12:26 -0400)
19 files changed:
CRM/Campaign/Form/Search/Campaign.php
CRM/Campaign/Form/Search/Petition.php
CRM/Campaign/Form/Search/Survey.php
CRM/Case/BAO/Case.php
CRM/Dedupe/Merger.php
CRM/Event/Form/Registration/Confirm.php
CRM/Event/Form/Registration/ThankYou.php
CRM/Event/Selector/Search.php
CRM/Financial/BAO/PaymentProcessor.php
CRM/Financial/Page/AJAX.php
CRM/Import/ImportProcessor.php
CRM/Mailing/BAO/Mailing.php
CRM/Mailing/Info.php
CRM/Member/Form/MembershipView.php
CRM/Report/BAO/ReportInstance.php
CRM/Report/Form/Contribute/Summary.php
CRM/UF/Page/ProfileEditor.php
CRM/Upgrade/Form.php
CRM/Upgrade/Incremental/php/FourFour.php

index 3b9928a63469b2841d0ded102b6517ea7a4ad0fc..a6cc366820bb8c7845a2a8267b6d859c2a3838b3 100644 (file)
@@ -45,7 +45,7 @@ class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form {
     $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'campaign');
 
     //when we do load tab, lets load the default objects.
-    $this->assign('force', ($this->_force || $this->_searchTab) ? TRUE : FALSE);
+    $this->assign('force', $this->_force || $this->_searchTab);
     $this->assign('searchParams', json_encode($this->get('searchParams')));
     $this->assign('buildSelector', $this->_search);
     $this->assign('searchFor', $this->_searchTab);
index bf26cc626ba2831b0b9c3115889fdbbdc44f7e1b..438b885dbfd1f2723ea517b9cf5629a1ac1a2020 100644 (file)
@@ -36,7 +36,7 @@ class CRM_Campaign_Form_Search_Petition extends CRM_Core_Form {
     $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'petition');
 
     //when we do load tab, lets load the default objects.
-    $this->assign('force', ($this->_force || $this->_searchTab) ? TRUE : FALSE);
+    $this->assign('force', $this->_force || $this->_searchTab);
     $this->assign('searchParams', json_encode($this->get('searchParams')));
     $this->assign('buildSelector', $this->_search);
     $this->assign('searchFor', $this->_searchTab);
index cdc54144da1c3731bebc253735feaa0cd691a275..968b99eafafda2679d343f9cf1672dcda94fc6fc 100644 (file)
@@ -36,7 +36,7 @@ class CRM_Campaign_Form_Search_Survey extends CRM_Core_Form {
     $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'survey');
 
     //when we do load tab, lets load the default objects.
-    $this->assign('force', ($this->_force || $this->_searchTab) ? TRUE : FALSE);
+    $this->assign('force', $this->_force || $this->_searchTab);
     $this->assign('searchParams', json_encode($this->get('searchParams')));
     $this->assign('buildSelector', $this->_search);
     $this->assign('searchFor', $this->_searchTab);
index 0d12748dfe33e353a73a5459f9af8901718cd329..7df858bf6c8825b21f74dd9bb3d61cdbb8ac7b59 100644 (file)
@@ -2550,15 +2550,15 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
       if (in_array($actTypeName, $singletonNames)) {
         $allow = FALSE;
         if ($operation == 'File On Case') {
-          $allow = (in_array($actTypeName, $doNotFileNames)) ? FALSE : TRUE;
+          $allow = !in_array($actTypeName, $doNotFileNames);
         }
         if (in_array($operation, $actionOperations)) {
           $allow = TRUE;
           if ($operation == 'edit') {
-            $allow = (in_array($actTypeName, $allowEditNames)) ? TRUE : FALSE;
+            $allow = in_array($actTypeName, $allowEditNames);
           }
           elseif ($operation == 'delete') {
-            $allow = (in_array($actTypeName, $doNotDeleteNames)) ? FALSE : TRUE;
+            $allow = !in_array($actTypeName, $doNotDeleteNames);
           }
         }
       }
@@ -2740,7 +2740,7 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
 
     //lets check for case configured.
     $allCasesCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE);
-    $configured['configured'] = ($allCasesCount) ? TRUE : FALSE;
+    $configured['configured'] = (bool) $allCasesCount;
     if (!$configured['configured']) {
       //do check for case type and case status.
       $caseTypes = CRM_Case_PseudoConstant::caseType('title', FALSE);
index d5d1c5a132d400b4608954429c6953f9f9c6cbdb..7e2354a01ab71f9204d5553a22e7ab16e06db529 100644 (file)
@@ -687,7 +687,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    * @throws \CiviCRM_API3_Exception
    */
   public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $batchLimit = 1, $isSelected = 2, $criteria = [], $checkPermissions = TRUE, $reloadCacheIfEmpty = NULL, $searchLimit = 0) {
-    $redirectForPerformance = ($batchLimit > 1) ? TRUE : FALSE;
+    $redirectForPerformance = $batchLimit > 1;
     if ($mode === 'aggressive' && $checkPermissions && !CRM_Core_Permission::check('force merge duplicate contacts')) {
       throw new CRM_Core_Exception(ts('Insufficient permissions for aggressive mode batch merge'));
     }
index de6fbdda90e422ef3c475223a9fa48c38147082e..4d2888b253e95c73772c129c045d51de17abd33f 100644 (file)
@@ -274,7 +274,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
     self::assignProfiles($this);
 
     //consider total amount.
-    $this->assign('isAmountzero', ($this->_totalAmount <= 0) ? TRUE : FALSE);
+    $this->assign('isAmountzero', $this->_totalAmount <= 0);
 
     $contribButton = ts('Continue');
     $this->addButtons([
@@ -562,7 +562,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
           $value['participant_register_date'] = $this->_values['participant']['register_date'];
         }
 
-        $createContrib = ($value['amount'] != 0) ? TRUE : FALSE;
+        $createContrib = $value['amount'] != 0;
         // force to create zero amount contribution, CRM-5095
         if (!$createContrib && ($value['amount'] == 0)
           && $this->_priceSetId && $this->_lineItem
index 01b19c5b25f8521b8234b8a9da01b9a5fa658334..d186528e1877f414de3449af464e138cb2f25024 100644 (file)
@@ -120,7 +120,7 @@ class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration {
     $this->assign('trxn_id', $this->_trxnId);
 
     //cosider total amount.
-    $this->assign('isAmountzero', ($this->_totalAmount <= 0) ? TRUE : FALSE);
+    $this->assign('isAmountzero', $this->_totalAmount <= 0);
 
     $this->assign('defaultRole', FALSE);
     if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) {
index 46dcfeb2e2c8d4c23870a2983a56e050a069ea44..adbc83513fcb6b9a4aed1aae85ec440ff14bf21f 100644 (file)
@@ -344,7 +344,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
         $statusClass = $statusClasses[$statusId];
       }
 
-      $row['showConfirmUrl'] = ($statusClass == 'Pending') ? TRUE : FALSE;
+      $row['showConfirmUrl'] = $statusClass == 'Pending';
 
       if (!empty($row['participant_is_test'])) {
         $row['participant_status'] = CRM_Core_TestEntity::appendTestText($row['participant_status']);
index 21d26259ac2af9fc26f15315521e75e2e21fbf1a..363828f31a76c00e5cccfd25461cc12b733f17af 100644 (file)
@@ -448,7 +448,7 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
     $capabilitiesString = implode('', $capabilities);
     if (!isset(\Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString])) {
       $result = self::getPaymentProcessors($capabilities);
-      \Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString] = (!empty($result) && array_keys($result) !== [0]) ? TRUE : FALSE;
+      \Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString] = (!empty($result) && array_keys($result) !== [0]);
     }
     return \Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString];
   }
index 5eaae27c1cbfc31b322e06b9b12105bde7cbe8b2..bc2e2f7b5324ef8774965c666315c1240a1ca939 100644 (file)
@@ -255,7 +255,7 @@ class CRM_Financial_Page_AJAX {
     $entityID = isset($_REQUEST['entityID']) ? CRM_Utils_Type::escape($_REQUEST['entityID'], 'String') : NULL;
     $notPresent = isset($_REQUEST['notPresent']) ? CRM_Utils_Type::escape($_REQUEST['notPresent'], 'String') : NULL;
     $statusID = isset($_REQUEST['statusID']) ? CRM_Utils_Type::escape($_REQUEST['statusID'], 'String') : NULL;
-    $search = isset($_REQUEST['search']) ? TRUE : FALSE;
+    $search = isset($_REQUEST['search']);
 
     $params = $_POST;
     if ($sort && $sortOrder) {
index 79ddc3b640e357b5a8974f71f6a861ca61792a3c..514c4c6bbc3a1f7626393d03ea738d38f8537cfd 100644 (file)
@@ -499,7 +499,7 @@ class CRM_Import_ImportProcessor {
    * @return bool
    */
   protected function isValidRelationshipKey($key) {
-    return !empty($this->getValidRelationships()[$key]) ? TRUE : FALSE;
+    return !empty($this->getValidRelationships()[$key]);
   }
 
   /**
index 436588ed3b35e6f321a537bc2f3fec47a0a65bf4..4951fe4bea9cbdbedd6bff354a4da8627b0435b0 100644 (file)
@@ -1107,7 +1107,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
     $pEmails = [];
 
     foreach ($pTemplates as $type => $pTemplate) {
-      $html = ($type == 'html') ? TRUE : FALSE;
+      $html = $type == 'html';
       $pEmails[$type] = [];
       $pEmail = &$pEmails[$type];
       $template = &$pTemplates[$type]['template'];
@@ -1148,7 +1148,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
 
     $message = new Mail_mime("\n");
 
-    $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE;
+    $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY;
     if ($useSmarty) {
       $smarty = CRM_Core_Smarty::singleton();
       // also add the contact tokens to the template
@@ -1300,7 +1300,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
         $mailing->templates[$type] = CRM_Utils_Token::replaceDomainTokens(
           $mailing->templates[$type],
           $domain,
-          $type == 'html' ? TRUE : FALSE,
+          $type == 'html',
           $tokens[$type]
         );
         $mailing->templates[$type] = CRM_Utils_Token::replaceMailingTokens($mailing->templates[$type], $mailing, NULL, $tokens[$type]);
@@ -1329,7 +1329,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
     $token = $token_a['token'];
     $data = $token;
 
-    $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE;
+    $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY;
 
     if ($type == 'embedded_url') {
       $embed_data = [];
index 7a37da69d9aa02858cef1e5b54e3460669f349fa..cfba5ccde0d9ed2f16061276facf097b932b515b 100644 (file)
@@ -178,9 +178,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info {
 
     $enableWorkflow = Civi::settings()->get('civimail_workflow');
 
-    return ($enableWorkflow &&
-      $config->userSystem->is_drupal
-    ) ? TRUE : FALSE;
+    return $enableWorkflow && $config->userSystem->is_drupal;
   }
 
   /**
index db184562e945d5f7e90989c83021e34de65fd8cd..85d207281f20e5467a53ffae306702c42fa4b9d6 100644 (file)
@@ -379,7 +379,7 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment,
 
       $isRecur = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->membershipID, 'contribution_recur_id');
 
-      $autoRenew = $isRecur ? TRUE : FALSE;
+      $autoRenew = (bool) $isRecur;
     }
 
     if (!empty($values['is_test'])) {
index e42a566ee96ea5c7d0ab3243e9156a93a2a63d79..daeff31df15443d3e3d3841d4d72029fb9f5ba0b 100644 (file)
@@ -144,7 +144,7 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance {
       unset($params['is_navigation']);
     }
 
-    $viewMode = !empty($params['view_mode']) ? $params['view_mode'] : FALSE;
+    $viewMode = !empty($params['view_mode']);
     if ($viewMode) {
       // Do not save to the DB - it's saved in the url.
       unset($params['view_mode']);
index 35df8417748e0821686b814e75ece6f8bf264a75..724efc03a18f6a4c72ecaa40660a74027e851e50 100644 (file)
@@ -760,8 +760,8 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
     if (!empty($this->_params['charts'])) {
       if (!empty($this->_params['group_bys']['receive_date'])) {
 
-        $contrib = !empty($this->_params['fields']['total_amount']) ? TRUE : FALSE;
-        $softContrib = !empty($this->_params['fields']['soft_amount']) ? TRUE : FALSE;
+        $contrib = !empty($this->_params['fields']['total_amount']);
+        $softContrib = !empty($this->_params['fields']['soft_amount']);
 
         foreach ($rows as $key => $row) {
           if ($row['civicrm_contribution_receive_date_subtotal']) {
@@ -817,7 +817,7 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
     $contributionPages = CRM_Contribute_PseudoConstant::contributionPage();
     //CRM-16338 if both soft-credit and contribution are enabled then process the contribution's
     //total amount's average, count and sum separately and add it to the respective result list
-    $softCredit = (!empty($this->_params['fields']['soft_amount']) && !empty($this->_params['fields']['total_amount'])) ? TRUE : FALSE;
+    $softCredit = (!empty($this->_params['fields']['soft_amount']) && !empty($this->_params['fields']['total_amount']));
     if ($softCredit) {
       $this->from('contribution');
       $this->customDataFrom();
index bbd6c1f49b9abd120a77cf2acbd7df2b026a7629..c665c46aa7b945a2deebbda6421591f9f068d909 100644 (file)
@@ -299,7 +299,7 @@ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page {
         'custom_group_id' => $customGroup->id,
         'extends_entity_column_id' => $customGroup->extends_entity_column_id,
         'extends_entity_column_value' => CRM_Utils_Array::explodePadded($customGroup->extends_entity_column_value),
-        'is_reserved' => $customGroup->is_reserved ? TRUE : FALSE,
+        'is_reserved' => (bool) $customGroup->is_reserved,
       ];
       $result['sections'][$sectionName] = $section;
     }
index 176b0db558ffac311185d3403ef22788d453baed..85dbe34413e457f88e55e49d2f303e38b4a9886e 100644 (file)
@@ -310,7 +310,7 @@ SET    version = '$version'
       $version, 'id',
       'version'
     );
-    return $domainID ? TRUE : FALSE;
+    return (bool) $domainID;
   }
 
   /**
index 055ab62d8bd88c70dfbf996e2419e85ac756fbfb..d4d83ee49da4ff61c6baf1497f843e7a79e15292 100644 (file)
@@ -719,7 +719,7 @@ CREATE TABLE IF NOT EXISTS `civicrm_word_replacement` (
           foreach ($localeCustomArray as $localCustomData) {
             // Traverse status array "enabled" "disabled"
             foreach ($localCustomData as $status => $matchTypes) {
-              $params["is_active"] = ($status == "enabled") ? TRUE : FALSE;
+              $params["is_active"] = $status == "enabled";
               // Traverse Match Type array "wildcardMatch" "exactMatch"
               foreach ($matchTypes as $matchType => $words) {
                 $params["match_type"] = $matchType;