Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM - Cleanup boolean expressions #16854

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Search/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function preProcess() {
$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);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Search/Petition.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function preProcess() {
$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);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Campaign/Form/Search/Survey.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function preProcess() {
$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);
Expand Down
8 changes: 4 additions & 4 deletions CRM/Case/BAO/Case.php
Original file line number Diff line number Diff line change
Expand Up @@ -2550,15 +2550,15 @@ public static function checkPermission($activityId, $operation, $actTypeId = NUL
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);
}
}
}
Expand Down Expand Up @@ -2740,7 +2740,7 @@ public static function isCaseConfigured($contactId = NULL) {

//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);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Dedupe/Merger.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ public static function retrieveFields($main, $other) {
* @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'));
}
Expand Down
4 changes: 2 additions & 2 deletions CRM/Event/Form/Registration/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function buildQuickForm() {
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([
Expand Down Expand Up @@ -562,7 +562,7 @@ public function postProcess() {
$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
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Registration/ThankYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function buildQuickForm() {
$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) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Selector/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) {
$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']);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Financial/BAO/PaymentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ public static function hasPaymentProcessorSupporting($capabilities = []) {
$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];
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Financial/Page/AJAX.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public static function getFinancialTransactionsList() {
$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) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Import/ImportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ protected function getNameFromLabel($label) {
* @return bool
*/
protected function isValidRelationshipKey($key) {
return !empty($this->getValidRelationships()[$key]) ? TRUE : FALSE;
return !empty($this->getValidRelationships()[$key]);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions CRM/Mailing/BAO/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ public function compose(
$pEmails = [];

foreach ($pTemplates as $type => $pTemplate) {
$html = ($type == 'html') ? TRUE : FALSE;
$html = $type == 'html';
$pEmails[$type] = [];
$pEmail = &$pEmails[$type];
$template = &$pTemplates[$type]['template'];
Expand Down Expand Up @@ -1148,7 +1148,7 @@ public function compose(

$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
Expand Down Expand Up @@ -1300,7 +1300,7 @@ public static function tokenReplace(&$mailing) {
$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]);
Expand Down Expand Up @@ -1329,7 +1329,7 @@ private function getTokenData(&$token_a, $html = FALSE, &$contact, &$verp, &$url
$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 = [];
Expand Down
4 changes: 1 addition & 3 deletions CRM/Mailing/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ public static function workflowEnabled() {

$enableWorkflow = Civi::settings()->get('civimail_workflow');

return ($enableWorkflow &&
$config->userSystem->is_drupal
) ? TRUE : FALSE;
return $enableWorkflow && $config->userSystem->is_drupal;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Member/Form/MembershipView.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public function preProcess() {

$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'])) {
Expand Down
2 changes: 1 addition & 1 deletion CRM/Report/BAO/ReportInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static function &create(&$params) {
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']);
Expand Down
6 changes: 3 additions & 3 deletions CRM/Report/Form/Contribute/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,8 @@ public function buildChart(&$rows) {
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']) {
Expand Down Expand Up @@ -817,7 +817,7 @@ public function alterDisplay(&$rows) {
$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();
Expand Down
2 changes: 1 addition & 1 deletion CRM/UF/Page/ProfileEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public static function convertCiviModelToBackboneModel($extends, $title, $availa
'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;
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Upgrade/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function checkVersion($version) {
$version, 'id',
'version'
);
return $domainID ? TRUE : FALSE;
return (bool) $domainID;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion CRM/Upgrade/Incremental/php/FourFour.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ public static function getConfigArraysAsAPIParams($rebuildEach) {
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;
Expand Down