$reservedKeyWords = CRM_Core_SelectValues::customGroupExtends();
//restrict "name" from being a reserved keyword when a new contact subtype is created
- if (!$self->_id && in_array($contactName, array_keys($reservedKeyWords))) {
+ if (!$self->_id && array_key_exists($contactName, $reservedKeyWords)) {
$errors['label'] = ts('Contact type names should not use reserved keywords.');
}
return empty($errors) ? TRUE : $errors;
public function action(&$object, $action, &$values, &$links, $permission, $forceAction = FALSE) {
if ($object->workflow_id) {
// do not expose action link for reverting to default if the template did not diverge or we just reverted it now
- if (!in_array($object->id, array_keys($this->_revertible)) or
+ if (!array_key_exists($object->id, $this->_revertible) or
($this->_action & CRM_Core_Action::REVERT and $object->id == $this->_revertedId)
) {
$action &= ~CRM_Core_Action::REVERT;
$elementCmpName = 'phone';
}
- if (in_array($elementCmpName, array_keys($addressCustomFields))) {
+ if (array_key_exists($elementCmpName, $addressCustomFields)) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($elementCmpName)) {
$addressCustomFieldIds[$cfID][$name] = 1;
}
$value = $formValues[$element] ?? NULL;
if ($value) {
if (is_array($value)) {
- if (in_array($element, array_keys($changeNames))) {
+ if (array_key_exists($element, $changeNames)) {
unset($formValues[$element]);
$element = $changeNames[$element];
}
$componentPanes = [];
foreach ($components as $name => $component) {
- if (in_array($name, array_keys($this->_searchOptions)) &&
+ if (array_key_exists($name, $this->_searchOptions) &&
$this->_searchOptions[$name] &&
CRM_Core_Permission::access($component->name)
) {
return array_keys($possibleMatches['values']);
}
if ($possibleMatches['count']) {
- if (in_array($extIDMatch, array_keys($possibleMatches['values']))) {
+ if (array_key_exists($extIDMatch, $possibleMatches['values'])) {
return [$extIDMatch];
}
throw new CRM_Core_Exception(ts(
'Chargeback' => 'Chargeback Account is',
];
- if (in_array($contributionStatus, array_keys($preferredAccountsRelationships))) {
+ if (array_key_exists($contributionStatus, $preferredAccountsRelationships)) {
$financialTypeID = !empty($params['financial_type_id']) ? $params['financial_type_id'] : $params['prevContribution']->financial_type_id;
return CRM_Financial_BAO_FinancialAccount::getFinancialAccountForFinancialTypeByRelationship(
$financialTypeID,
}
if ($customDataType && !is_array($customDataType)) {
- if (in_array($customDataType, CRM_Contact_BAO_ContactType::subTypes())) {
+ if (in_array($customDataType, CRM_Contact_BAO_ContactType::subTypes(), TRUE)) {
// This is the case when getFieldsForImport() requires fields
// limited strictly to a subtype.
$customDataSubType = $customDataType;
$onlySubType = TRUE;
}
- if (in_array($customDataType, array_keys(CRM_Core_SelectValues::customGroupExtends()))) {
+ if (array_key_exists($customDataType, CRM_Core_SelectValues::customGroupExtends())) {
// this makes the method flexible to support retrieving fields
// for multiple extends value.
$customDataType = [$customDataType];
if (is_array($customDataType)) {
$value = NULL;
foreach ($customDataType as $dataType) {
- if (in_array($dataType, array_keys(CRM_Core_SelectValues::customGroupExtends()))) {
+ if (array_key_exists($dataType, CRM_Core_SelectValues::customGroupExtends())) {
if (in_array($dataType, ['Individual', 'Household', 'Organization'])) {
$val = "'" . CRM_Utils_Type::escape($dataType, 'String') . "', 'Contact' ";
}
$addressCustom = FALSE;
if (in_array($permissionType, [CRM_Core_Permission::CREATE, CRM_Core_Permission::EDIT]) &&
- in_array($field->field_name, array_keys($addressCustomFields))
+ array_key_exists($field->field_name, $addressCustomFields)
) {
$addressCustom = TRUE;
$name = "address_{$name}";
$dao->query("DESCRIBE {$table}", FALSE);
while ($dao->fetch()) {
// view non-internationalized columns directly
- if (!in_array($dao->Field, array_keys($columns[$table])) and
+ if (!array_key_exists($dao->Field, $columns[$table]) &&
!preg_match('/_[a-z][a-z]_[A-Z][A-Z]$/', $dao->Field)
) {
$cols[] = '`' . $dao->Field . '`';
}
$tableCols[] = $dao->Field;
}
- // view intrernationalized columns through an alias
+ // view internationalized columns through an alias
foreach ($columns[$table] as $column => $_) {
if (!$isUpgradeMode) {
$cols[] = "`{$column}_{$locale}` `{$column}`";
$val = explode(',', $val);
if ($key == 'participant_role_id') {
foreach ($val as $role) {
- if (!in_array(trim($role), array_keys($roleIDs))) {
+ if (!array_key_exists(trim($role), $roleIDs)) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Role Id', $errorMessage);
break;
}
elseif ($val && (($key == 'participant_status_id') || ($key == 'participant_status'))) {
$statusIDs = CRM_Event_PseudoConstant::participantStatus();
if ($key == 'participant_status_id') {
- if (!in_array(trim($val), array_keys($statusIDs))) {
+ if (!array_key_exists(trim($val), $statusIDs)) {
CRM_Contact_Import_Parser_Contact::addToErrorMsg('Participant Status Id', $errorMessage);
break;
}
// custom data tables
- case in_array($table, array_keys($ctypes)):
+ case array_key_exists($table, $ctypes):
foreach ($row as $id => $changes) {
$inserts = ['id' => '%1'];
$updates = [];
$selectedAmounts[$opId] = $options[$opId]['amount'];
}
}
- elseif (in_array($fields["price_{$fieldId}"], array_keys($options))) {
+ elseif (array_key_exists($fields["price_{$fieldId}"], $options)) {
$selectedAmounts[$fields["price_{$fieldId}"]] = $options[$fields["price_{$fieldId}"]]['amount'];
}
}
$relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL
) {
$clauses = [];
- if (in_array($relative, array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)))) {
+ if (array_key_exists($relative, $this->getOperationPair(CRM_Report_Form::OP_DATE))) {
$sqlOP = $this->getSQLOperator($relative);
return "( {$fieldName} {$sqlOP} )";
}
$fieldName,
$relative, $from, $to, $type = NULL) {
$clauses = [];
- if (in_array($relative, array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)))) {
+ if (array_key_exists($relative, $this->getOperationPair(CRM_Report_Form::OP_DATE))) {
return NULL;
}
$op = CRM_Core_Action::UPDATE;
}
CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types, $op);
- if (!in_array($params['financial_type_id'], array_keys($types))) {
+ if (!array_key_exists($params['financial_type_id'], $types)) {
throw new API_Exception('You do not have permission to create this contribution');
}
}
if (empty($params['financial_type_id'])) {
$params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_LineItem', $params['id'], 'financial_type_id');
}
- if (!in_array($params['financial_type_id'], array_keys($types))) {
+ if (!array_key_exists($params['financial_type_id'], $types)) {
throw new API_Exception('You do not have permission to ' . $op . ' this line item');
}
}
FALSE, FALSE
);
//Check if custom table is included in $query->_tables.
- $this->assertTrue(in_array($cgTableName, array_keys($query->_tables)));
+ $this->assertTrue(array_key_exists($cgTableName, $query->_tables));
//Assert if from clause joins the custom table.
$this->assertTrue(strpos($query->_fromClause, $cgTableName) !== FALSE);
$this->callAPISuccess('CustomField', 'delete', ['id' => $customField['id']]);
//Check if both indices are deleted.
$indices = CRM_Core_BAO_SchemaHandler::getIndexes($tables);
foreach ($tables as $index => $tableName) {
- $this->assertFalse(in_array($index, array_keys($indices[$tableName])));
+ $this->assertFalse(array_key_exists($index, $indices[$tableName]));
}
//Drop false index and create again.
CRM_Core_BAO_SchemaHandler::createMissingIndices($missingIndices);